net.i2p.router.tunnel.pool
Class TunnelPool

java.lang.Object
  extended by net.i2p.router.tunnel.pool.TunnelPool

public class TunnelPool
extends java.lang.Object


Nested Class Summary
(package private)  class TunnelPool.LeaseComparator
          Always build a LeaseSet with Leases in sorted order, so that LeaseSet.equals() and lease-by-lease equals() always work.
 
Constructor Summary
TunnelPool(RouterContext ctx, TunnelPoolManager mgr, TunnelPoolSettings settings, TunnelPeerSelector sel)
           
 
Method Summary
 void addTunnel(TunnelInfo info)
           
(package private)  void buildComplete(PooledTunnelCreatorConfig cfg)
           
(package private)  boolean buildFallback()
          Return true if a fallback tunnel is built
(package private)  PooledTunnelCreatorConfig configureNewTunnel()
           
 int countHowManyToBuild()
          Gather the data to see how many tunnels to build, and then actually compute that value (delegated to the countHowManyToBuild function below)
 long getLifetimeProcessed()
           
(package private)  TunnelPoolManager getManager()
           
 TunnelPeerSelector getSelector()
           
 TunnelPoolSettings getSettings()
           
 TunnelInfo getTunnel(TunnelId gatewayId)
           
(package private)  int getTunnelCount()
          duplicate of size(), let's pick one
 boolean isAlive()
           
 java.util.List listPending()
          list of tunnelInfo instances of tunnels currently being built
 java.util.List<TunnelInfo> listTunnels()
          Return a list of tunnels in the pool
 boolean needFallback()
          Do we really need more fallbacks?
(package private)  void refreshLeaseSet()
           
(package private)  void refreshSettings()
           
 void removeTunnel(TunnelInfo info)
           
 TunnelInfo selectTunnel()
          Pull a random tunnel out of the pool.
 void setSettings(TunnelPoolSettings settings)
           
 void shutdown()
           
 int size()
          duplicate of getTunnelCount(), let's pick one
 void startup()
           
 java.lang.String toString()
           
 void tunnelFailed(PooledTunnelCreatorConfig cfg)
          This may be called multiple times from TestJob
(package private)  void updateRate()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TunnelPool

public TunnelPool(RouterContext ctx,
                  TunnelPoolManager mgr,
                  TunnelPoolSettings settings,
                  TunnelPeerSelector sel)
Method Detail

startup

public void startup()

shutdown

public void shutdown()

getManager

TunnelPoolManager getManager()

refreshSettings

void refreshSettings()

selectTunnel

public TunnelInfo selectTunnel()
Pull a random tunnel out of the pool. If there are none available but the pool is configured to allow 0hop tunnels, this builds a fake one and returns it.


getTunnel

public TunnelInfo getTunnel(TunnelId gatewayId)

listTunnels

public java.util.List<TunnelInfo> listTunnels()
Return a list of tunnels in the pool

Returns:
list of TunnelInfo objects

needFallback

public boolean needFallback()
Do we really need more fallbacks? Used to prevent a zillion of them


listPending

public java.util.List listPending()
list of tunnelInfo instances of tunnels currently being built


getTunnelCount

int getTunnelCount()
duplicate of size(), let's pick one


getSettings

public TunnelPoolSettings getSettings()

setSettings

public void setSettings(TunnelPoolSettings settings)

getSelector

public TunnelPeerSelector getSelector()

isAlive

public boolean isAlive()

size

public int size()
duplicate of getTunnelCount(), let's pick one


addTunnel

public void addTunnel(TunnelInfo info)

removeTunnel

public void removeTunnel(TunnelInfo info)

tunnelFailed

public void tunnelFailed(PooledTunnelCreatorConfig cfg)
This may be called multiple times from TestJob


updateRate

void updateRate()

refreshLeaseSet

void refreshLeaseSet()

buildFallback

boolean buildFallback()
Return true if a fallback tunnel is built


getLifetimeProcessed

public long getLifetimeProcessed()

countHowManyToBuild

public int countHowManyToBuild()
Gather the data to see how many tunnels to build, and then actually compute that value (delegated to the countHowManyToBuild function below)


configureNewTunnel

PooledTunnelCreatorConfig configureNewTunnel()

buildComplete

void buildComplete(PooledTunnelCreatorConfig cfg)

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object