public class TestJob extends JobImpl
| Modifier and Type | Field and Description |
|---|---|
static int | maxQueuedTests |
(package private) static long | TRAFFIC_PROOF_MSHow recently a tunnel must have carried real (non-test) traffic for
the pool to clear its FAILING flag and mark it GOOD. |
| Constructor and Description |
|---|
TestJob(RouterContext ctx,
PooledTunnelCreatorConfig cfg,
TunnelPool pool)TestJob. |
| Modifier and Type | Method and Description |
|---|---|
(package private) static int | computeMaxTestJobs(int maxQueuedTests,
int activeRunners,
int numPools)Test-job capacity derived from the queue state: at least 12 jobs (or
3 per pool), scaled up by active runners, but never above the hard
queued limit. |
(package private) static int | computeTestPeriod(double successTimeAvgMs,
double sendProcessingMs,
int outLen,
int replyLen,
int minPeriod,
int maxPeriod)Compute the tunnel test failure window: how long a test may take before
the tunnel is declared failed. |
void | dropped()Called when the job is dropped due to router overload. |
static int | getCurrentTestJobCount()Current number of queued + active test jobs for capacity planning. |
static int | getHardLimit(RouterContext ctx)Hard limit for total TestJob instances (queued + active). |
static int | getMaxTestJobs()Maximum number of queued test jobs allowed before deferring. |
String | getName()The name of this job. |
(package private) static boolean | hasValidTunnelIds(PooledTunnelCreatorConfig cfg)Whether the tunnel config has non-zero tunnel IDs at hop 0, i.e. |
(package private) static boolean | isEarlyExpiry(PooledTunnelCreatorConfig cfg,
long now)Whether the tunnel expires so soon it is not worth testing — it has
already been pruned for early expiry. |
(package private) static boolean | isPingTunnel(PooledTunnelCreatorConfig cfg)Whether the tunnel belongs to a ping pool, which is short-lived and
does not need testing. |
(package private) static boolean | isPoolCritical(int activeCount,
int target)Whether a pool is critically low on tunnels: no active tunnels at all,
or at most 2 active against a larger target. |
(package private) static boolean | isTestQueueOverloaded(boolean critical,
int readyCount,
int activeRunners,
long maxLag,
long expeditedLagLimit,
int currentTestJobs,
int expeditedJobLimit)Whether the job queue is too backed up to accept another test job. |
boolean | isValid()Check if this TestJob instance is valid and should be queued. |
(package private) static boolean | isZeroActivePool(TunnelPool pool)Whether a client pool has zero active tunnels, i.e. |
void | runJob()Run the tunnel test and report success or failure. |
static boolean | shouldSchedule(RouterContext ctx,
PooledTunnelCreatorConfig cfg)Static method to check if a TestJob should be created and scheduled. |
void | testSuccessful(int ms)Called when the tunnel test completes successfully. |
getContext, getJobId, getMadeReadyOn, getTiming, madeReady, requeue, toStringpublic static volatile int maxQueuedTests
static final long TRAFFIC_PROOF_MS
public TestJob(RouterContext ctx, PooledTunnelCreatorConfig cfg, TunnelPool pool)
static int computeMaxTestJobs(int maxQueuedTests,
int activeRunners,
int numPools)maxQueuedTests - hard cap from maxQueuedTestsactiveRunners - current job-queue runner countnumPools - number of tunnel poolsstatic int computeTestPeriod(double successTimeAvgMs,
double sendProcessingMs,
int outLen,
int replyLen,
int minPeriod,
int maxPeriod)successTimeAvgMs - average tunnel.testSuccessTime over the last minute,
NaN if never measuredsendProcessingMs - average transport.sendProcessingTime, NaN if unknownoutLen - outbound tunnel length, <= 0 if no outbound tunnelreplyLen - reply tunnel length, <= 0 if no reply tunnelminPeriod - minTestPeriod configmaxPeriod - maxTestPeriod configpublic void dropped()
public static int getCurrentTestJobCount()
public static int getHardLimit(RouterContext ctx)
public static int getMaxTestJobs()
public String getName()
static boolean hasValidTunnelIds(PooledTunnelCreatorConfig cfg)
cfg - the tunnel config, never nullstatic boolean isEarlyExpiry(PooledTunnelCreatorConfig cfg, long now)
cfg - the tunnel config, never nullnow - current time in msstatic boolean isPingTunnel(PooledTunnelCreatorConfig cfg)
cfg - the tunnel config, never nullstatic boolean isPoolCritical(int activeCount,
int target)activeCount - current active tunnel counttarget - configured total quantitystatic boolean isTestQueueOverloaded(boolean critical,
int readyCount,
int activeRunners,
long maxLag,
long expeditedLagLimit,
int currentTestJobs,
int expeditedJobLimit)critical - whether the pool is critical (bypasses the gate)readyCount - jobs waiting in the queueactiveRunners - jobs being processedmaxLag - measured queue lag in msexpeditedLagLimit - lag threshold (doubled for expedited)currentTestJobs - running test job countexpeditedJobLimit - job threshold (1.5x for expedited)public boolean isValid()
static boolean isZeroActivePool(TunnelPool pool)
pool - the pool, may be null (then not critical)public void runJob()
public static boolean shouldSchedule(RouterContext ctx, PooledTunnelCreatorConfig cfg)
ctx - the router contextcfg - the tunnel configpublic void testSuccessful(int ms)
ms - time in milliseconds the test took to succeed