net.i2p.router.tunnel.pool

## Class TunnelPoolManager

- java.lang.Object
- - net.i2p.router.tunnel.pool.TunnelPoolManager

- All Implemented Interfaces:
    Service, TunnelManagerFacade

      public class TunnelPoolManager
      extends Object
      implements TunnelManagerFacade

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `TunnelPoolManager(RouterContext ctx)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `(package private) void` | `buildComplete(PooledTunnelCreatorConfig cfg)` queue a recurring test job if appropriate
    `void` | `buildTunnels(Destination client, ClientTunnelSettings settings)` Used only at session startup.
    `(package private) BuildExecutor` | `getExecutor()`
    `int` | `getFreeTunnelCount()` how many free inbound tunnels do we have available?
    `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?
    `TunnelPool` | `getInboundExploratoryPool()` for TunnelRenderer in router console
    `TunnelPoolSettings` | `getInboundSettings()`
    `TunnelPoolSettings` | `getInboundSettings(Hash client)`
    `long` | `getLastParticipatingExpiration()` When does the last tunnel we are participating in expire?
    `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
    `TunnelPoolSettings` | `getOutboundSettings()`
    `TunnelPoolSettings` | `getOutboundSettings(Hash client)`
    `int` | `getOutboundTunnelCount()` how many outbound tunnels do we have available?
    `int` | `getParticipatingCount()` how many tunnels are we participating in?
    `double` | `getShareRatio()`
    `TunnelInfo` | `getTunnelInfo(TunnelId id)` Retrieve the information related to a particular tunnel
    `(package private) boolean` | `isShutdown()`
    `boolean` | `isValidTunnel(Hash client, TunnelInfo tunnel)` Is a tunnel a valid member of the pool?
    `void` | `listPools(List<TunnelPool> out)` list of TunnelPool instances currently in play
    `void` | `removeTunnels(Hash destination)` synch with buildTunnels() above
    `void` | `renderStatusHTML(Writer out)` Deprecated. moved to routerconsole
    `void` | `restart()` Perform a soft restart.
    `TunnelInfo` | `selectInboundTunnel()` pick an inbound tunnel not bound to a particular destination
    `TunnelInfo` | `selectInboundTunnel(Hash destination)` pick an inbound tunnel bound to the given destination
    `TunnelInfo` | `selectOutboundTunnel()` pick an outbound tunnel not bound to a particular destination
    `TunnelInfo` | `selectOutboundTunnel(Hash destination)` pick an outbound tunnel bound to the given destination
    `Set<Hash>` | `selectPeersInTooManyTunnels()` For reliability reasons, don't allow a peer in more than x% of client and exploratory tunnels.
    `void` | `setInboundSettings(Hash client, TunnelPoolSettings settings)`
    `void` | `setInboundSettings(TunnelPoolSettings settings)`
    `void` | `setOutboundSettings(Hash client, TunnelPoolSettings settings)`
    `void` | `setOutboundSettings(TunnelPoolSettings settings)`
    `void` | `shutdown()` Instruct the service that the router is shutting down and that it should do whatever is necessary to go down gracefully.
    `void` | `startup()` Instruct the service that it should start normal operation.
    `(package private) void` | `tunnelFailed()`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### TunnelPoolManager

          public TunnelPoolManager(RouterContext ctx)

  - ### Method Detail

    - #### selectInboundTunnel

          public TunnelInfo selectInboundTunnel()

      pick an inbound tunnel not bound to a particular destination
      Specified by:
        `selectInboundTunnel` in interface `TunnelManagerFacade`

    - #### selectInboundTunnel

          public TunnelInfo selectInboundTunnel(Hash destination)

      pick an inbound tunnel bound to the given destination
      Specified by:
        `selectInboundTunnel` in interface `TunnelManagerFacade`

    - #### selectOutboundTunnel

          public TunnelInfo selectOutboundTunnel()

      pick an outbound tunnel not bound to a particular destination
      Specified by:
        `selectOutboundTunnel` in interface `TunnelManagerFacade`

    - #### selectOutboundTunnel

          public TunnelInfo selectOutboundTunnel(Hash destination)

      pick an outbound tunnel bound to the given destination
      Specified by:
        `selectOutboundTunnel` in interface `TunnelManagerFacade`

    - #### getTunnelInfo

          public TunnelInfo getTunnelInfo(TunnelId id)

      Description copied from interface: `TunnelManagerFacade`
      Retrieve the information related to a particular tunnel
      Specified by:
        `getTunnelInfo` in interface `TunnelManagerFacade`
      Parameters:
        `id` - the tunnelId as seen at the gateway

    - #### getFreeTunnelCount

          public int getFreeTunnelCount()

      Description copied from interface: `TunnelManagerFacade`
      how many free inbound tunnels do we have available?
      Specified by:
        `getFreeTunnelCount` in interface `TunnelManagerFacade`

    - #### getOutboundTunnelCount

          public int getOutboundTunnelCount()

      Description copied from interface: `TunnelManagerFacade`
      how many outbound tunnels do we have available?
      Specified by:
        `getOutboundTunnelCount` in interface `TunnelManagerFacade`

    - #### getInboundClientTunnelCount

          public int getInboundClientTunnelCount()

      Description copied from interface: `TunnelManagerFacade`
      how many free inbound client tunnels do we have available?
      Specified by:
        `getInboundClientTunnelCount` in interface `TunnelManagerFacade`

    - #### getOutboundClientTunnelCount

          public int getOutboundClientTunnelCount()

      Description copied from interface: `TunnelManagerFacade`
      how many outbound client tunnels do we have available?
      Specified by:
        `getOutboundClientTunnelCount` in interface `TunnelManagerFacade`

    - #### getOutboundClientTunnelCount

          public int getOutboundClientTunnelCount(Hash destination)

      Use to verify a tunnel pool is alive
      Specified by:
        `getOutboundClientTunnelCount` in interface `TunnelManagerFacade`
      Since:
        0.7.11

    - #### getParticipatingCount

          public int getParticipatingCount()

      Description copied from interface: `TunnelManagerFacade`
      how many tunnels are we participating in?
      Specified by:
        `getParticipatingCount` in interface `TunnelManagerFacade`

    - #### getLastParticipatingExpiration

          public long getLastParticipatingExpiration()

      Description copied from interface: `TunnelManagerFacade`
      When does the last tunnel we are participating in expire?
      Specified by:
        `getLastParticipatingExpiration` in interface `TunnelManagerFacade`

    - #### getShareRatio

          public double getShareRatio()

      Specified by:
        `getShareRatio` in interface `TunnelManagerFacade`
      Returns:
        (number of part. tunnels) / (estimated total number of hops in our expl.+client tunnels) 100 max. We just use length setting, not variance, for speed
      Since:
        0.7.10

    - #### isValidTunnel

          public boolean isValidTunnel(Hash client,
                              TunnelInfo tunnel)

      Description copied from interface: `TunnelManagerFacade`
      Is a tunnel a valid member of the pool?
      Specified by:
        `isValidTunnel` in interface `TunnelManagerFacade`

    - #### getInboundSettings

          public TunnelPoolSettings getInboundSettings()

      Specified by:
        `getInboundSettings` in interface `TunnelManagerFacade`

    - #### getOutboundSettings

          public TunnelPoolSettings getOutboundSettings()

      Specified by:
        `getOutboundSettings` in interface `TunnelManagerFacade`

    - #### setInboundSettings

          public void setInboundSettings(TunnelPoolSettings settings)

      Specified by:
        `setInboundSettings` in interface `TunnelManagerFacade`

    - #### setOutboundSettings

          public void setOutboundSettings(TunnelPoolSettings settings)

      Specified by:
        `setOutboundSettings` in interface `TunnelManagerFacade`

    - #### getInboundSettings

          public TunnelPoolSettings getInboundSettings(Hash client)

      Specified by:
        `getInboundSettings` in interface `TunnelManagerFacade`

    - #### getOutboundSettings

          public TunnelPoolSettings getOutboundSettings(Hash client)

      Specified by:
        `getOutboundSettings` in interface `TunnelManagerFacade`

    - #### setInboundSettings

          public void setInboundSettings(Hash client,
                                TunnelPoolSettings settings)

      Specified by:
        `setInboundSettings` in interface `TunnelManagerFacade`

    - #### setOutboundSettings

          public void setOutboundSettings(Hash client,
                                 TunnelPoolSettings settings)

      Specified by:
        `setOutboundSettings` in interface `TunnelManagerFacade`

    - #### restart

          public void restart()

      Description copied from interface: `Service`
      Perform a soft restart.
      Specified by:
        `restart` in interface `Service`

    - #### buildTunnels

          public void buildTunnels(Destination client,
                          ClientTunnelSettings settings)

      Used only at session startup. Do not use to change settings.
      Specified by:
        `buildTunnels` in interface `TunnelManagerFacade`

    - #### removeTunnels

          public void removeTunnels(Hash destination)

      synch with buildTunnels() above

    - #### buildComplete

          void buildComplete(PooledTunnelCreatorConfig cfg)

      queue a recurring test job if appropriate

    - #### startup

          public void startup()

      Description copied from interface: `Service`
      Instruct the service that it should start normal operation. This call DOES block until the service is ready.
      Specified by:
        `startup` in interface `Service`

    - #### shutdown

          public void shutdown()

      Description copied from interface: `Service`
      Instruct the service that the router is shutting down and that it should do whatever is necessary to go down gracefully. It should not depend on other components at this point. This call DOES block.
      Specified by:
        `shutdown` in interface `Service`

    - #### listPools

          public void listPools(List<TunnelPool> out)

      list of TunnelPool instances currently in play
      Specified by:
        `listPools` in interface `TunnelManagerFacade`

    - #### tunnelFailed

          void tunnelFailed()

    - #### getExecutor

          BuildExecutor getExecutor()

    - #### isShutdown

          boolean isShutdown()

    - #### getInboundBuildQueueSize

          public int getInboundBuildQueueSize()

      Description copied from interface: `TunnelManagerFacade`
      count how many inbound tunnel requests we have received but not yet processed
      Specified by:
        `getInboundBuildQueueSize` in interface `TunnelManagerFacade`

    - #### renderStatusHTML

          public void renderStatusHTML(Writer out)
                                throws IOException

      Deprecated. moved to routerconsole
      Specified by:
        `renderStatusHTML` in interface `Service`
      Throws:
        `IOException`

    - #### selectPeersInTooManyTunnels

          public Set<Hash> selectPeersInTooManyTunnels()

      For reliability reasons, don't allow a peer in more than x% of client and exploratory tunnels. This also will prevent a single huge-capacity (or malicious) peer from taking all the tunnels in the network (although it would be nice to limit the % of total network tunnels to 10% or so, but that appears to be too low to set as a default here... much lower than 33% will push client tunnels out of the fast tier into high cap or beyond...) Possible improvement - restrict based on count per IP, or IP block, to slightly increase costs of collusion
      Specified by:
        `selectPeersInTooManyTunnels` in interface `TunnelManagerFacade`
      Returns:
        Set of peers that should not be allowed in another tunnel

    - #### getInboundClientPools

          public Map<Hash,TunnelPool> getInboundClientPools()

      for TunnelRenderer in router console
      Specified by:
        `getInboundClientPools` in interface `TunnelManagerFacade`

    - #### getOutboundClientPools

          public Map<Hash,TunnelPool> getOutboundClientPools()

      for TunnelRenderer in router console
      Specified by:
        `getOutboundClientPools` in interface `TunnelManagerFacade`

    - #### getInboundExploratoryPool

          public TunnelPool getInboundExploratoryPool()

      for TunnelRenderer in router console
      Specified by:
        `getInboundExploratoryPool` in interface `TunnelManagerFacade`

    - #### getOutboundExploratoryPool

          public TunnelPool getOutboundExploratoryPool()

      for TunnelRenderer in router console
      Specified by:
        `getOutboundExploratoryPool` in interface `TunnelManagerFacade`