@Stability.Internal public class Timer extends Object
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.Modifier and Type | Method and Description |
---|---|
static Timer |
create(long maxNumRequestsInRetry,
TimerConfig timerConfig)
Creates a new
Timer with default values. |
static Timer |
createAndStart(long maxNumRequestsInRetry)
Creates and starts a timer with default values.
|
static Timer |
createAndStart(long maxNumRequestsInRetry,
TimerConfig timerConfig) |
long |
outstandingForRetry()
Returns the number of requests currently outstanding for retry.
|
void |
register(Request<Response> request)
Registers the given request to be tracked with its timeout value.
|
com.couchbase.client.core.deps.io.netty.util.Timeout |
schedule(Runnable callback,
Duration runAfter) |
com.couchbase.client.core.deps.io.netty.util.Timeout |
schedule(Runnable callback,
Duration runAfter,
boolean respectMax)
Schedule an arbitrary task for this timer.
|
void |
scheduleForRetry(Core core,
Request<? extends Response> request,
Duration runAfter)
Schedules a request to be retried after the given duration.
|
void |
start()
Starts this timer.
|
void |
stop()
Stops this timer.
|
String |
toString() |
public static Timer create(long maxNumRequestsInRetry, TimerConfig timerConfig)
Timer
with default values.maxNumRequestsInRetry
- the maximum number of requests in retry allowed before backpressure hits.public static Timer createAndStart(long maxNumRequestsInRetry)
maxNumRequestsInRetry
- the maximum number of requests in retry allowed before backpressure hits.public static Timer createAndStart(long maxNumRequestsInRetry, TimerConfig timerConfig)
public void scheduleForRetry(Core core, Request<? extends Response> request, Duration runAfter)
Note that this operation performs backpressure handling for the SDK by doing account towards a maximum outstanding request limit!
core
- the core to eventually retry against.request
- the request to retry.runAfter
- the duration after which to retry.public com.couchbase.client.core.deps.io.netty.util.Timeout schedule(Runnable callback, Duration runAfter)
public com.couchbase.client.core.deps.io.netty.util.Timeout schedule(Runnable callback, Duration runAfter, boolean respectMax)
respectMax
- whether maxNumRequestsInRetry should be respected. Will return null if the operation was not scheduled for this reason.public void register(Request<Response> request)
request
- the request to track.public void start()
public void stop()
public long outstandingForRetry()
Copyright © 2024 Couchbase, Inc.. All rights reserved.