Class GatedRateLimiter

  • All Implemented Interfaces:
    RateLimiter

    @Internal
    public class GatedRateLimiter
    extends Object
    implements RateLimiter
    An implementation of RateLimiter that completes defined number of futures in-between the external notification events. The first cycle completes immediately, without waiting for the external notifications.
    • Constructor Detail

      • GatedRateLimiter

        public GatedRateLimiter​(int capacityPerCycle)
        Instantiates a new GatedRateLimiter.
        Parameters:
        capacityPerCycle - The number of completed futures per cycle.
    • Method Detail

      • acquire

        public CompletionStage<Void> acquire()
        Description copied from interface: RateLimiter
        Returns a future that is completed once another event would not exceed the rate limit. For correct functioning, the next invocation of this method should only happen after the previously returned future has been completed.
        Specified by:
        acquire in interface RateLimiter
      • notifyCheckpointComplete

        public void notifyCheckpointComplete​(long checkpointId)
        Description copied from interface: RateLimiter
        Notifies this RateLimiter that the checkpoint with the given checkpointId completed and was committed. Makes it possible to implement rate limiters that control data emission per checkpoint cycle.
        Specified by:
        notifyCheckpointComplete in interface RateLimiter
        Parameters:
        checkpointId - The ID of the checkpoint that has been completed.