public static class Dispatcher.RequestTime
extends java.lang.Object
Constructor and Description |
---|
RequestTime(long createdAtNanos) |
RequestTime(long enqueuedAtNanos,
long startedAtNanos) |
Modifier and Type | Method and Description |
---|---|
long |
baseTimeNanos()
Base time is used by timeouts, and can be set to either when the request was added to the queue,
or when the processing has started.
|
long |
clientDeadline() |
long |
computeDeadline(long verbExpiresAfterNanos)
Given the current time and a base timeout for the verb return a request's expiration deadline,
the time at which it becomes eligible for load shedding.
|
long |
computeTimeout(long now,
long verbExpiresAfterNanos) |
long |
enqueuedAtNanos() |
static Dispatcher.RequestTime |
forImmediateExecution() |
boolean |
shouldSendHints()
No request should survive native request deadline, but in order to err on the side of caution, we have this
swtich that allows hints to be submitted to mutation stage when cluster is potentially overloaded.
|
long |
startedAtNanos() |
long |
timeSpentInQueueNanos() |
public RequestTime(long createdAtNanos)
public RequestTime(long enqueuedAtNanos, long startedAtNanos)
public static Dispatcher.RequestTime forImmediateExecution()
public long startedAtNanos()
public long enqueuedAtNanos()
public long baseTimeNanos()
public long computeDeadline(long verbExpiresAfterNanos)
baseTimeNanos()
for details.
The client timeout represents how long the sender of a request is prepared to wait for a response. By
implication, after this window has passed any further work done on the server side is wasted effort. Ideally,
the base for this timeout would be set on a per-request basis but as this not currently supported in the
protocol, it is configured uniformly for all requests. See .
For this calculation, elapsed time is always measured from the point when a request is received and enqueued.
Where verb timeout is based on queue admission, deadline computation is straightforward. The expiration
deadline is simply the current time plus the smaller of the verb and client timeouts.
However, if verb timeout is based on when the request is dequeued, the implications are more nuanced.
In this scenario, while there may still be "headroom" available within the verb timeout, using it could
exceed the client timeout (which is always based on admission time).
For example:
* Client timeout base is 10 (cb), verb timeout base is 5 (vb)
* Request is enqueued at t1 (e)
* Request is dequeued at t8 (d)
* computeDeadline is called at t9 (n)
If verb timeout is based on dequeuing, there would still some time remaining before a verb-based deadline.
elapsed = (n - d) ; 1
timeout = (vb - elapsed) ; 4
deadline = (n + timeout) ; t13
ostensibly, the coordinator has until t13 to complete processing
But as client timeout is measured from admission time, the request may exceeded the maximum wait period for
the client sooner.
elapsed = (n - e) ; 8
timeout = (cb - elapsed) ; 2
deadline = (n + timeout) ; t11
So the coordinator actually only has until t11 to complete processing, beyond then the client will not accept
any response.verbExpiresAfterNanos
- the base timeout value for the verb being executedpublic long computeTimeout(long now, long verbExpiresAfterNanos)
public boolean shouldSendHints()
public long clientDeadline()
public long timeSpentInQueueNanos()
Copyright © 2009- The Apache Software Foundation