public class TunnelPoolManager extends Object implements TunnelManagerFacade
| Modifier and Type | Field and Description |
|---|---|
(package private) static String | PROP_OUTBOUND_STARTUP_RETRIESP r o p o u t b o u n d s t a r t u p r e t r i e s |
| Constructor and Description |
|---|
TunnelPoolManager(RouterContext ctx) |
| Modifier and Type | Method and Description |
|---|---|
boolean | addAlias(Destination dest,
ClientTunnelSettings settings,
Destination existingClient)Add another destination to the same tunnels. |
void | adjustBuildHandlerThreads(int target)Dynamically adjust BuildHandler thread count to match target. |
(package private) void | buildComplete(PooledTunnelCreatorConfig cfg)queue a recurring test job if appropriate |
void | buildTunnels(Destination client,
ClientTunnelSettings settings)Used only at session startup. |
int | checkAndRecoverPools()Emergency pool recovery: Check all registered clients have valid tunnel pools. |
boolean | disableTunnelTesting()Tunnel testing status. |
void | fail(Hash peer)Fail all outbound tunnels with this peer as first hop,
and all inbound tunnels with this peer as the last hop,
baecause we can't contact it any more. |
void | forceRemoveTunnels(Hash destination)Force immediate removal of a pool - used for router shutdown. |
int | getBuildHandlerThreadCount()Actual number of running BuildHandler threads. |
static int | getBuildHandlerThreads()Tuned by Tuner — min 1, max 8 |
(package private) BuildExecutor | getExecutor() |
int | getFreeTunnelCount()how many free inbound tunnels do we have available? |
GhostPeerManager | getGhostPeerManager()Get the ghost peer manager for tracking peers with consistent tunnel build timeouts. |
int | getInboundBuildQueueSize()count how many inbound tunnel requests we have received but not yet processed |
Map<Hash,TunnelPool> | getInboundClientPools()for TunnelRenderer in router console |
int | getInboundClientTunnelCount()how many free inbound client tunnels do we have available? |
int | getInboundClientTunnelCount(Hash destination)Use to verify a tunnel pool is alive. |
TunnelPool | getInboundExploratoryPool()For TunnelRenderer in router console |
TunnelPool | getInboundPool(Hash client) |
TunnelPoolSettings | getInboundSettings()Get the inbound exploratory tunnel pool settings. |
TunnelPoolSettings | getInboundSettings(Hash client)Get settings for a client's inbound tunnel pool. |
long | getLastParticipatingExpiration()Get the expiration time of the last participating tunnel. |
Map<Hash,TunnelPool> | getOutboundClientPools()for TunnelRenderer in router console |
int | getOutboundClientTunnelCount()how many outbound client tunnels do we have available? |
int | getOutboundClientTunnelCount(Hash destination)Use to verify a tunnel pool is alive. |
TunnelPool | getOutboundExploratoryPool()For TunnelRenderer in router console |
TunnelPool | getOutboundPool(Hash client) |
TunnelPoolSettings | getOutboundSettings()Get the outbound exploratory tunnel pool settings. |
TunnelPoolSettings | getOutboundSettings(Hash client)Get settings for a client's outbound tunnel pool. |
int | getOutboundTunnelCount()how many outbound tunnels do we have available? |
int | getParticipatingCount()Get the number of tunnels we're participating in as a gateway or endpoint. |
double | getShareRatio()Get the share ratio of participating tunnels. |
int | getUsableInboundClientTunnelCount(Hash destination)Get USABLE inbound client tunnel count for a specific destination. |
int | getUsableOutboundClientTunnelCount(Hash destination)Get USABLE outbound client tunnel count for a specific destination. |
boolean | isFirewalled()Firewall status. |
(package private) boolean | isShutdown() |
boolean | isValidTunnel(Hash client,
TunnelInfo tunnel)Check if a tunnel is valid and belongs to the client's pool. |
void | listPools(List<TunnelPool> out)list of TunnelPool instances currently in play |
void | logPoolHealth()Log pool health summary for monitoring. |
void | pruneAllPools()Prune excess tunnels from all pools to stay within budget. |
void | removeAlias(Destination dest)Remove a destination for the same tunnels as another. |
(package private) void | removeFromExpiration(PooledTunnelCreatorConfig cfg)Remove a tunnel from the expiration queue to prevent memory leak |
void | removeFromExpirationHop(HopConfig cfg)Remove a participating tunnel from the expiration queue. |
void | removeTunnels(Destination dest)Must be called AFTER deregistration by the client manager. |
void | removeTunnels(Hash destination)This will be called twice, once by the inbound and once by the outbound pool. |
boolean | replaceSlowTunnels()Find and remove tunnels exceeding the latency threshold. |
void | restart()Restart all tunnel handlers and rebuild all tunnels |
TunnelInfo | selectAnyInboundTunnel()Pick a random inbound tunnel from any pool — client pools first,
then exploratory. |
TunnelInfo | selectAnyOutboundTunnel()Pick a random outbound tunnel from any pool — client pools first,
then exploratory. |
TunnelInfo | selectInboundExploratoryTunnel(Hash closestTo)Pick the inbound exploratory tunnel with the gateway closest to the given hash. |
TunnelInfo | selectInboundTunnel()Pick a random inbound exploratory tunnel. |
TunnelInfo | selectInboundTunnel(Hash destination)Pick a random inbound tunnel from the given destination's pool. |
TunnelInfo | selectInboundTunnel(Hash destination,
Hash closestTo)Pick the inbound tunnel with the gateway closest to the given hash
from the given destination's pool. |
TunnelInfo | selectOutboundExploratoryTunnel(Hash closestTo)Pick the outbound exploratory tunnel with the endpoint closest to the given hash. |
TunnelInfo | selectOutboundTunnel()Pick a random outbound exploratory tunnel. |
TunnelInfo | selectOutboundTunnel(Hash destination)Pick a random outbound tunnel from the given destination's pool. |
TunnelInfo | selectOutboundTunnel(Hash destination,
Hash closestTo)Pick the outbound tunnel with the endpoint closest to the given hash
from the given destination's pool. |
Set<Hash> | selectPeersInTooManyTunnels()For reliability reasons, don't allow a peer in more than x% of
client and exploratory tunnels. |
static void | setBuildHandlerThreads(int val)Set the number of build handler threads. |
void | setInboundSettings(Hash client,
TunnelPoolSettings settings)Set settings for a client's inbound tunnel pool. |
void | setInboundSettings(TunnelPoolSettings settings)Set the inbound exploratory tunnel pool settings. |
void | setOutboundSettings(Hash client,
TunnelPoolSettings settings)Set settings for a client's outbound tunnel pool. |
void | setOutboundSettings(TunnelPoolSettings settings)Set the outbound exploratory tunnel pool settings. |
void | shutdown()Cannot be restarted |
void | startup()Start the tunnel pool manager and build initial tunnels |
(package private) void | tunnelFailed()Poke the build executor to build more tunnels. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitrenderStatusHTMLstatic final String PROP_OUTBOUND_STARTUP_RETRIES
public TunnelPoolManager(RouterContext ctx)
ctx - the router contextpublic boolean addAlias(Destination dest, ClientTunnelSettings settings, Destination existingClient)
addAlias in interface TunnelManagerFacadeIllegalArgumentException - if notpublic void adjustBuildHandlerThreads(int target)
target - desired thread countvoid buildComplete(PooledTunnelCreatorConfig cfg)
public void buildTunnels(Destination client, ClientTunnelSettings settings)
buildTunnels in interface TunnelManagerFacadepublic int checkAndRecoverPools()
public boolean disableTunnelTesting()
public void fail(Hash peer)
fail in interface TunnelManagerFacadepublic void forceRemoveTunnels(Hash destination)
destination - the destinationpublic int getBuildHandlerThreadCount()
getBuildHandlerThreads() if threads
were interrupted or failed to start.public static int getBuildHandlerThreads()
BuildExecutor getExecutor()
public int getFreeTunnelCount()
TunnelManagerFacadegetFreeTunnelCount in interface TunnelManagerFacadepublic GhostPeerManager getGhostPeerManager()
TunnelManagerFacadegetGhostPeerManager in interface TunnelManagerFacadepublic int getInboundBuildQueueSize()
TunnelManagerFacadegetInboundBuildQueueSize in interface TunnelManagerFacadepublic Map<Hash,TunnelPool> getInboundClientPools()
getInboundClientPools in interface TunnelManagerFacadepublic int getInboundClientTunnelCount()
TunnelManagerFacadegetInboundClientTunnelCount in interface TunnelManagerFacadepublic int getInboundClientTunnelCount(Hash destination)
getInboundClientTunnelCount in interface TunnelManagerFacadepublic TunnelPool getInboundExploratoryPool()
getInboundExploratoryPool in interface TunnelManagerFacadepublic TunnelPool getInboundPool(Hash client)
getInboundPool in interface TunnelManagerFacadepublic TunnelPoolSettings getInboundSettings()
getInboundSettings in interface TunnelManagerFacadepublic TunnelPoolSettings getInboundSettings(Hash client)
getInboundSettings in interface TunnelManagerFacadeclient - destination hashpublic long getLastParticipatingExpiration()
getLastParticipatingExpiration in interface TunnelManagerFacadepublic Map<Hash,TunnelPool> getOutboundClientPools()
getOutboundClientPools in interface TunnelManagerFacadepublic int getOutboundClientTunnelCount()
TunnelManagerFacadegetOutboundClientTunnelCount in interface TunnelManagerFacadepublic int getOutboundClientTunnelCount(Hash destination)
getOutboundClientTunnelCount in interface TunnelManagerFacadepublic TunnelPool getOutboundExploratoryPool()
getOutboundExploratoryPool in interface TunnelManagerFacadepublic TunnelPool getOutboundPool(Hash client)
getOutboundPool in interface TunnelManagerFacadepublic TunnelPoolSettings getOutboundSettings()
getOutboundSettings in interface TunnelManagerFacadepublic TunnelPoolSettings getOutboundSettings(Hash client)
getOutboundSettings in interface TunnelManagerFacadeclient - destination hashpublic int getOutboundTunnelCount()
TunnelManagerFacadegetOutboundTunnelCount in interface TunnelManagerFacadepublic int getParticipatingCount()
getParticipatingCount in interface TunnelManagerFacadepublic double getShareRatio()
getShareRatio in interface TunnelManagerFacadepublic int getUsableInboundClientTunnelCount(Hash destination)
destination - the client hashpublic int getUsableOutboundClientTunnelCount(Hash destination)
destination - the client hashpublic boolean isFirewalled()
boolean isShutdown()
public boolean isValidTunnel(Hash client, TunnelInfo tunnel)
isValidTunnel in interface TunnelManagerFacadeclient - destination hashtunnel - tunnel to validatepublic void listPools(List<TunnelPool> out)
listPools in interface TunnelManagerFacadepublic void logPoolHealth()
public void pruneAllPools()
public void removeAlias(Destination dest)
removeAlias in interface TunnelManagerFacadevoid removeFromExpiration(PooledTunnelCreatorConfig cfg)
public void removeFromExpirationHop(HopConfig cfg)
cfg - the hop config to removepublic void removeTunnels(Destination dest)
removeTunnels in interface TunnelManagerFacadepublic void removeTunnels(Hash destination)
destination - the destinationpublic boolean replaceSlowTunnels()
public void restart()
public TunnelInfo selectAnyInboundTunnel()
selectAnyInboundTunnel in interface TunnelManagerFacadepublic TunnelInfo selectAnyOutboundTunnel()
selectAnyOutboundTunnel in interface TunnelManagerFacadepublic TunnelInfo selectInboundExploratoryTunnel(Hash closestTo)
selectInboundExploratoryTunnel in interface TunnelManagerFacadeclosestTo - non-nullpublic TunnelInfo selectInboundTunnel()
selectInboundTunnel in interface TunnelManagerFacadepublic TunnelInfo selectInboundTunnel(Hash destination)
selectInboundTunnel in interface TunnelManagerFacadedestination - if null, returns inbound exploratory tunnelpublic TunnelInfo selectInboundTunnel(Hash destination, Hash closestTo)
selectInboundTunnel in interface TunnelManagerFacadedestination - if null, returns inbound exploratory tunnelclosestTo - non-nullpublic TunnelInfo selectOutboundExploratoryTunnel(Hash closestTo)
selectOutboundExploratoryTunnel in interface TunnelManagerFacadeclosestTo - non-nullpublic TunnelInfo selectOutboundTunnel()
selectOutboundTunnel in interface TunnelManagerFacadepublic TunnelInfo selectOutboundTunnel(Hash destination)
selectOutboundTunnel in interface TunnelManagerFacadedestination - if null, returns outbound exploratory tunnelpublic TunnelInfo selectOutboundTunnel(Hash destination, Hash closestTo)
selectOutboundTunnel in interface TunnelManagerFacadedestination - if null, returns outbound exploratory tunnelclosestTo - non-nullpublic Set<Hash> selectPeersInTooManyTunnels()
selectPeersInTooManyTunnels in interface TunnelManagerFacadepublic static void setBuildHandlerThreads(int val)
val - thread count (clamped 2-8)public void setInboundSettings(Hash client, TunnelPoolSettings settings)
setInboundSettings in interface TunnelManagerFacadeclient - destination hashpublic void setInboundSettings(TunnelPoolSettings settings)
setInboundSettings in interface TunnelManagerFacadepublic void setOutboundSettings(Hash client, TunnelPoolSettings settings)
setOutboundSettings in interface TunnelManagerFacadeclient - destination hashpublic void setOutboundSettings(TunnelPoolSettings settings)
setOutboundSettings in interface TunnelManagerFacadepublic void startup()
void tunnelFailed()