java.lang.Object
net.i2p.router.tunnel.TunnelCreatorConfig
net.i2p.router.tunnel.pool.PooledTunnelCreatorConfig
All Implemented Interfaces:
TunnelInfo

public class PooledTunnelCreatorConfigextends TunnelCreatorConfig
Data about a tunnel we created.
  • Field Details

    • _pool

      private final TunnelPool _pool
      The pool this config belongs to.
    • _pairedGW

      private TunnelId _pairedGW
      The gateway tunnel paired with this one, by id only - storing the config itself leads to OOM.
    • _lastActivity

      private volatile long _lastActivity
      When the tunnel last carried a message.
    • _lastResort

      private volatile boolean _lastResort
      True to use the tunnel only when nothing better is available.
    • _bypassPacing

      private volatile boolean _bypassPacing
      True to send through the tunnel without waiting for pacing.
    • _lastRequestMsgId

      private volatile long _lastRequestMsgId
      I2NP message ID of the most recent build request sent for this config.

      This is the join key between the send side (BuildRequestor logs it as [MsgID ...], on both the direct and exploratory send paths) and the expiry side ( BuildExecutor.logExpiredBuildWarn logs it as reqMsgId=...), so a build that expires unanswered can be attributed to a specific send. Without it, "established, silent" is indistinguishable between a hop that never answered and a reply that was lost, which is why no amount of deadline tuning could be shown to help.

      0 means not yet sent, or not a PooledTunnelCreatorConfig. Written on the build executor thread and read on the expiry path, hence volatile; a stale read costs only a missing correlation ID, never correctness.

    • ACTIVITY_TIMEOUT

      private static final long ACTIVITY_TIMEOUT
      Quiet time past which the tunnel counts as inactive: 30 seconds.
      See Also:
  • Constructor Details

    • PooledTunnelCreatorConfig

      public PooledTunnelCreatorConfig(RouterContext ctx, int length, boolean isInbound, Hash destination, TunnelPool pool)
      Creates a new instance of PooledTunnelCreatorConfig.
      Parameters:
      ctx - the router context supplying the transport and profile lookups
      length - the tunnel length in hops, 1 minimum (a 0-hop tunnel is length 1)
      isInbound - true for a client inbound tunnel, false for an outbound one
      destination - may be null
      pool - the owning pool, never null
  • Method Details

    • testJobSuccessful

      public void testJobSuccessful(int ms)
      Record that a test of this tunnel succeeded, as TestJob does after a round trip.
      Parameters:
      ms - the round-trip time of the successful tunnel test, in milliseconds
    • tunnelFailed

      public boolean tunnelFailed()
      The tunnel failed a test, so (maybe) stop using it.
      Overrides:
      tunnelFailed in class TunnelCreatorConfig
      Returns:
      false if we stopped using it, true if still ok
    • tunnelFailedFirstHop

      public void tunnelFailedFirstHop()
      We failed to contact the first hop for an outbound tunnel, so immediately stop using it. For outbound non-zero-hop tunnels only.

      Does not blame any peer: first-hop send failures are local congestion, not a dead peer. Proportional blame still accumulated ~50 points per failure per hop — 8 consecutive failures banlisted the first hop and collapsed the pool.

      Overrides:
      tunnelFailedFirstHop in class TunnelCreatorConfig
    • firstHopSendFailureStreak

      public void firstHopSendFailureStreak(int streak)
      Re-warm the session to the first hop of an outbound tunnel whose send failures are approaching the fatal threshold. A direct transport send forces the connection up again, so the next tunnel message is not queued behind a stale session.

      Gated by shouldPreConnect(int), so the DatabaseLookupMessage round-trip only ever reaches a hop the router has not yet given up on.

      Overrides:
      firstHopSendFailureStreak in class TunnelCreatorConfig
      Parameters:
      streak - the current first-hop failure streak
    • shouldPreConnect

      static boolean shouldPreConnect(int streak)
      Whether a first-hop send-failure streak warrants a pre-connect re-warm.

      Fires only on the strike immediately below TunnelCreatorConfig.FIRST_HOP_FAILURE_THRESHOLD — the last point at which the tunnel is still alive to benefit. Earlier strikes have not yet committed to blaming the peer, so a round-trip would only add load to a path that may merely be congested; the threshold strike itself retires the tunnel as soon as the hook returns, so re-warming there would send a lookup to a hop the router has already decided to blame.

      Parameters:
      streak - the current first-hop failure streak
      Returns:
      true if the first-hop session should be re-warmed
    • getOptions

      public Properties getOptions()
      Get the extra options configured on the owning pool.
      Overrides:
      getOptions in class TunnelCreatorConfig
      Returns:
      the pool's unknown options, never null
    • getTunnelPool

      public TunnelPool getTunnelPool()
      Get the pool this tunnel belongs to.
      Returns:
      the owning pool, never null
    • isLastResort

      public boolean isLastResort()
      Test whether this tunnel was built because the pool had nothing else.
      Returns:
      true if this tunnel was built as a last-resort fallback
    • setLastResort

      public void setLastResort()
      Mark this tunnel as a last-resort fallback.
    • isBypassPacing

      public boolean isBypassPacing()
      Test whether this build may ignore the per-peer in-flight guard.
      Returns:
      true if this build bypasses the per-peer in-flight guard in
    • setBypassPacing

      public void setBypassPacing()
      Mark this build as emergency recovery: it must be sent even if the first-hop peer already has a build in flight. Set by the pool when it has zero usable tunnels and cannot wait for the guard to clear.
    • recordActivity

      public void recordActivity()
      Record activity on this tunnel (message processed).
    • getLastActivity

      public long getLastActivity()
      Get the time this tunnel last processed a message.
      Returns:
      timestamp of last activity, or 0 if never used
    • isRecentlyActive

      public boolean isRecentlyActive()
      Test whether this tunnel has been used recently enough to count as live.
      Returns:
      true if this tunnel has been recently active (within ACTIVITY_TIMEOUT)
    • setPairedGW

      public void setPairedGW(TunnelId gw)
      The ID of the gateway of the paired tunnel used to send/receive the build request.
      Parameters:
      gw - for paired inbound, the GW rcv tunnel ID; for paired outbound, the GW send tunnel ID.
    • getPairedGW

      public TunnelId getPairedGW()
      The ID of the gateway of the paired tunnel used to send/receive the build request.
      Returns:
      for paired inbound, the GW rcv tunnel ID; for paired outbound, the GW send tunnel ID. null if not previously set
    • setLastRequestMsgId

      public void setLastRequestMsgId(long msgId)
      Record the I2NP message ID of a build request just sent for this config.

      A config may be retried, so this holds the most recent attempt rather than the first; the expiry report wants the send that actually went out.

      Parameters:
      msgId - the getUniqueId() of the TunnelBuildMessage handed to the transport or dispatcher
    • getLastRequestMsgId

      public long getLastRequestMsgId()
      The I2NP message ID of the most recent build request sent for this config.
      Returns:
      the message ID, or 0 if no request has been sent yet