Class SinkUtils

    • Constructor Detail

      • SinkUtils

        public SinkUtils()
    • Method Detail

      • tryAcquire

        public static void tryAcquire​(int permits,
                                      int maxConcurrentRequests,
                                      java.time.Duration maxConcurrentRequestsTimeout,
                                      Semaphore semaphore)
                               throws InterruptedException,
                                      TimeoutException
        Acquire permits on the given semaphore within a given allowed timeout and deal with errors.
        Parameters:
        permits - the mumber of permits to acquire.
        maxConcurrentRequests - the maximum number of permits the semaphore was initialized with.
        maxConcurrentRequestsTimeout - the timeout to acquire the permits.
        semaphore - the semaphore to acquire permits to.
        Throws:
        InterruptedException - if the current thread was interrupted.
        TimeoutException - if the waiting time elapsed before all permits were acquired.