java.lang.Object
net.i2p.router.JobImpl
net.i2p.router.client.RequestLeaseSetJob
- All Implemented Interfaces:
Job
Async job to walk the client through generating a lease set. Sends the request to the client and queues a CheckLeaseRequestStatus job for timeout cleanup. On failure, calls failLeaseRequest() to clean up the pending LeaseRequestState so new requests can proceed.
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate classTimeout check for the LeaseSet request.Field Summary
FieldsModifier and TypeFieldDescriptionprivate final LogThe log for the lease request.private final LeaseRequestStateThe state of the lease request.private final ClientConnectionRunnerThe runner that asked for the lease set.private static final longClock fudge allowed for lease times.private static final longDefault maximum clock fudge.(package private) static final intAttempts before giving up on a backed-up client.(package private) static final longDefault wait for the client to make room in its I2CP queue before giving up.private static final longMost a lease may be in the future, the ten minute lease ceiling plus a small clock fudge, so requested leases never extend past the eleven minute tunnel lifetime.private static final StringConfig key of the maximum clock fudge.(package private) static final StringProperty overridingDEFAULT_SEND_ATTEMPTS: how many times to try the send before the request is declared failed.(package private) static final StringProperty overridingDEFAULT_SEND_WAIT: ms to wait for the client to drain its I2CP queue before failing the LeaseSet request.private static final longTen minutes, in milliseconds.private static final longJitter added to timeout to spread thundering-herd retries.Constructor Summary
ConstructorsConstructorDescriptionRequestLeaseSetJob(RouterContext ctx, ClientConnectionRunner runner, LeaseRequestState state) Create the job.Method Summary
Modifier and TypeMethodDescriptionprivate voidfailEarlyRequest(String reason) Resolve a request that cannot be sent to the client.getName()Descriptive name of the task.voidrunJob()Actually perform the task.Methods inherited from class JobImpl
dropped, getContext, getJobId, getMadeReadyOn, getTiming, madeReady, requeue, toStringModifier and TypeMethodDescriptionvoiddropped()Default implementation does nothing.final RouterContextThe router context that this job belongs to.longgetJobId()The unique job ID for this job.longThe timestamp when this job was last made ready for execution.The timing object for this job.voidmadeReady(long now) For JobQueue only, not for external use.protected voidrequeue(long delayMs) Requeue this job to run after the specified delay.toString()
Field Details
_log
The log for the lease request._runner
The runner that asked for the lease set._requestState
The state of the lease request.DEFAULT_MAX_FUDGE
private static final long DEFAULT_MAX_FUDGEDefault maximum clock fudge.- See Also:
PROP_MAX_FUDGE
Config key of the maximum clock fudge.- See Also:
PROP_SEND_WAIT
Property overridingDEFAULT_SEND_WAIT: ms to wait for the client to drain its I2CP queue before failing the LeaseSet request.- See Also:
TEN_MINUTES_MS
MAX_LEASE_FUTURE
private static final long MAX_LEASE_FUTUREMost a lease may be in the future, the ten minute lease ceiling plus a small clock fudge, so requested leases never extend past the eleven minute tunnel lifetime. Must stay inside the fifteen minute network database lease cap.- See Also:
CLOCK_FUDGE_FACTOR
private static final long CLOCK_FUDGE_FACTORClock fudge allowed for lease times.- See Also:
TIMEOUT_JITTER_MS
private static final long TIMEOUT_JITTER_MSJitter added to timeout to spread thundering-herd retries.- See Also:
DEFAULT_SEND_WAIT
static final long DEFAULT_SEND_WAITDefault wait for the client to make room in its I2CP queue before giving up.Deliberately far shorter than the request timeout this failure would otherwise cost: a client that is draining at all has usually freed a slot within a few dispatcher passes, and a client that is wedged should be failed quickly so the caller can rebuild rather than left holding a request that cannot succeed.
- See Also:
PROP_SEND_ATTEMPTS
Property overridingDEFAULT_SEND_ATTEMPTS: how many times to try the send before the request is declared failed.- See Also:
DEFAULT_SEND_ATTEMPTS
static final int DEFAULT_SEND_ATTEMPTSAttempts before giving up on a backed-up client. The router's request timeout is around a minute, so with a one-second first wait and doubling, five attempts span roughly 15 seconds. The client has to read one message in that time, and anything that cannot is not going to recover inside the request timeout either.- See Also:
Constructor Details
RequestLeaseSetJob
public RequestLeaseSetJob(RouterContext ctx, ClientConnectionRunner runner, LeaseRequestState state) Create the job.- Parameters:
ctx- the router contextrunner- the client connection to answerstate- the leases the client asked for
Method Details
getName
runJob
public void runJob()Description copied from interface:JobActually perform the task. This call blocks until the Job is complete.failEarlyRequest
Resolve a request that cannot be sent to the client. The claim makes onFailed fire at most once even when several paths (early validation, send failure, a timeout check) detect the same dead request, and the slot is always cleared through failLeaseRequest() so a later request can proceed.- Parameters:
reason- short description of the early failure, for the debug log