Class Timer

java.lang.Object
com.couchbase.client.core.Timer

@Internal public class Timer extends Object
The Timer acts as the main timing facility for various operations, for example to track and time out requests if they run for too long or for rescheduling needs.
Since:
2.0.0
  • Method Details

    • create

      public static Timer create(long maxNumRequestsInRetry, TimerConfig timerConfig)
      Creates a new Timer with default values.
      Parameters:
      maxNumRequestsInRetry - the maximum number of requests in retry allowed before backpressure hits.
      Returns:
      the created timer.
    • createAndStart

      public static Timer createAndStart(long maxNumRequestsInRetry)
      Creates and starts a timer with default values.
      Parameters:
      maxNumRequestsInRetry - the maximum number of requests in retry allowed before backpressure hits.
      Returns:
      the created and started timer.
    • createAndStart

      public static Timer createAndStart(long maxNumRequestsInRetry, TimerConfig timerConfig)
    • scheduleForRetry

      public void scheduleForRetry(Core core, Request<? extends Response> request, Duration runAfter)
      Schedules a request to be retried after the given duration.

      Note that this operation performs backpressure handling for the SDK by doing account towards a maximum outstanding request limit!

      Parameters:
      core - the core to eventually retry against.
      request - the request to retry.
      runAfter - the duration after which to retry.
    • schedule

      public com.couchbase.client.core.deps.io.netty.util.Timeout schedule(Runnable callback, Duration runAfter)
    • schedule

      public com.couchbase.client.core.deps.io.netty.util.Timeout schedule(Runnable callback, Duration runAfter, boolean respectMax)
      Schedule an arbitrary task for this timer.
      Parameters:
      respectMax - whether maxNumRequestsInRetry should be respected. Will return null if the operation was not scheduled for this reason.
    • register

      public void register(Request<Response> request)
      Registers the given request to be tracked with its timeout value.
      Parameters:
      request - the request to track.
    • start

      public void start()
      Starts this timer.
    • stop

      public void stop()
      Stops this timer.
    • outstandingForRetry

      public long outstandingForRetry()
      Returns the number of requests currently outstanding for retry.
    • toString

      public String toString()
      Overrides:
      toString in class Object