public class BuildExecutor extends Object implements Runnable
| Modifier and Type | Class and Description |
|---|---|
(package private) static class | BuildExecutor.ResultBuild result enumeration. |
| Constructor and Description |
|---|
BuildExecutor(RouterContext ctx,
TunnelPoolManager mgr,
GhostPeerManager ghostMgr)Create a new BuildExecutor. |
| Modifier and Type | Method and Description |
|---|---|
void | buildComplete(PooledTunnelCreatorConfig cfg,
BuildExecutor.Result result)Handle a completed tunnel build. |
void | buildComplete(PooledTunnelCreatorConfig cfg,
BuildExecutor.Result result,
String detail)Handle a completed tunnel build with additional detail. |
(package private) void | buildTunnel(PooledTunnelCreatorConfig cfg)Build a tunnel with the given configuration. |
boolean | fullStats()Check if full statistics are enabled. |
static long | getGoodDeficitThrottle(RouterContext ctx)Get the GOOD deficit throttle interval from config or default (30s). |
static int | getMaxConcurrentBuilds()Get the maximum number of concurrent builds allowed. |
static long | getPoolBackoffMs()Get the pool backoff time in milliseconds. |
static int | getPoolFailureThreshold()Get the pool failure threshold. |
(package private) static int | getTunnelLifetime(RouterContext ctx)Get the tunnel lifetime from config. |
(package private) static int | getTunnelTargetBuffer(RouterContext ctx)Get the target build buffer from config or default (0). |
(package private) boolean | isPoolInBackoff(TunnelPool pool)Check if a pool is in backoff due to consecutive build failures. |
boolean | isRunning()Check if the executor is currently running. |
(package private) PooledTunnelCreatorConfig | removeFromBuilding(long id)This returns the PTCC up to a minute after it 'expired', thus allowing us to
still use a tunnel if it was accepted, and to update peer stats. |
(package private) void | removePoolState(TunnelPool pool)Remove failure state for a pool that is being removed. |
void | repoll()Signal the executor to repoll for tunnel building opportunities. |
void | restart()Restart the build executor, clearing recent build state. |
void | run()Starts the tunnel building process in a loop and takes care of error handling. |
static void | setMaxConcurrentBuilds(int val)Set the maximum number of concurrent builds allowed. |
static void | setPoolBackoffMs(long val)Set the pool backoff time in milliseconds. |
static void | setPoolFailureThreshold(int val)Set the pool failure threshold. |
void | shutdown()Cannot be restarted. |
boolean | wasRecentlyBuilding(long replyId)Check if a tunnel build was recently attempted. |
public BuildExecutor(RouterContext ctx, TunnelPoolManager mgr, GhostPeerManager ghostMgr)
ctx - the router contextmgr - the tunnel pool managerghostMgr - the ghost peer manager for tracking timeoutspublic void buildComplete(PooledTunnelCreatorConfig cfg, BuildExecutor.Result result)
cfg - the tunnel configuration that completedresult - the build result (success, failure, etc.)public void buildComplete(PooledTunnelCreatorConfig cfg, BuildExecutor.Result result, String detail)
cfg - the tunnel configuration that completedresult - the build result (success, failure, etc.)detail - additional detail on the resultvoid buildTunnel(PooledTunnelCreatorConfig cfg)
cfg - the tunnel configuration to buildpublic boolean fullStats()
public static long getGoodDeficitThrottle(RouterContext ctx)
ctx - the router contextpublic static int getMaxConcurrentBuilds()
public static long getPoolBackoffMs()
public static int getPoolFailureThreshold()
static int getTunnelLifetime(RouterContext ctx)
ctx - the router contextstatic int getTunnelTargetBuffer(RouterContext ctx)
ctx - the router contextboolean isPoolInBackoff(TunnelPool pool)
pool - the tunnel pool to checkpublic boolean isRunning()
PooledTunnelCreatorConfig removeFromBuilding(long id)
id - the build message IDvoid removePoolState(TunnelPool pool)
pool - the pool to remove state forpublic void repoll()
public void restart()
public void run()
public static void setMaxConcurrentBuilds(int val)
val - the maximum concurrent buildspublic static void setPoolBackoffMs(long val)
val - the backoff in ms (1000-60000)public static void setPoolFailureThreshold(int val)
val - the threshold value (1-20)public void shutdown()
public boolean wasRecentlyBuilding(long replyId)
replyId - the reply message ID to check