All Known Implementing Classes:
PooledTunnelCreatorConfig, TunnelCreatorConfig

public interface TunnelInfo
Defines the information associated with a tunnel.
  • Method Details

    • getLength

      int getLength()
      How many peers are there in the tunnel (including the creator)?
      Returns:
      the number of hops, counting ourselves if we are the gateway
    • getReceiveTunnelId

      TunnelId getReceiveTunnelId(int hop)
      The tunnelId that the given hop receives messages on. The gateway is hop 0.
      Parameters:
      hop - zero-based position in the tunnel, 0 being the gateway
      Returns:
      the receive tunnel id
    • getSendTunnelId

      TunnelId getSendTunnelId(int hop)
      The tunnelId that the given hop sends messages on. The gateway is hop 0.
      Parameters:
      hop - zero-based position in the tunnel, 0 being the gateway
      Returns:
      the send tunnel id
    • getPeer

      Hash getPeer(int hop)
      The peer at the given hop. The gateway is hop 0.
      Parameters:
      hop - zero-based position in the tunnel, 0 being the gateway
      Returns:
      the router hash at that position
    • getGateway

      Hash getGateway()
      For convenience.
      Returns:
      getPeer(0)
    • getEndpoint

      Hash getEndpoint()
      For convenience.
      Returns:
      getPeer(getLength() - 1)
    • getFarEnd

      Hash getFarEnd()
      For convenience.
      Returns:
      isInbound() ? getGateway() : getEndpoint()
    • isInbound

      boolean isInbound()
      Is this an inbound tunnel?
      Returns:
      true if peers at the far end send to us through this tunnel
    • getDestination

      Hash getDestination()
      If this is a client tunnel, what destination is it for?
      Returns:
      the destination hash this tunnel serves, or null for a router tunnel
    • getExpiration

      long getExpiration()
      The tunnel's expiration time.
      Returns:
      expiration time in milliseconds since epoch
    • testSuccessful

      void testSuccessful(int responseTime)
      Record that the tunnel successfully processed a test with the given response time.
      Parameters:
      responseTime - the response time in milliseconds
    • getProcessedMessagesCount

      int getProcessedMessagesCount()
      The count of messages that have been processed through this tunnel.
      Returns:
      the number of processed messages
    • getVerifiedBytesTransferred

      long getVerifiedBytesTransferred()
      Number of bytes known to have travelled through the tunnel in its lifetime.
      Returns:
      the verified byte total accumulated over the tunnel's lifetime
    • incrementVerifiedBytesTransferred

      void incrementVerifiedBytesTransferred(int numBytes)
      Increment the verified byte count for data successfully sent through the tunnel.
      Parameters:
      numBytes - the number of bytes to add to the verified total
    • recordRealTraffic

      void recordRealTraffic()
      Record that the tunnel carried real (non-test) traffic. Updated only at the real traffic delivery sites. Inbound data arrival (InboundEndpointProcessor) and outbound message dispatch (OutboundClientMessageOneShotJob) — never by TestJob, so test traffic cannot pollute the proof that the tunnel works.
    • getLastRealTraffic

      long getLastRealTraffic()
      When the tunnel last carried real traffic.
      Returns:
      the timestamp, or 0 if it never carried real traffic
    • wasReused

      boolean wasReused()
      Did we reuse this tunnel?
      Returns:
      true if the tunnel came from an existing pool rather than a fresh build
    • setReused

      void setReused()
      Note that we reused this tunnel.
    • getTunnelFailed

      boolean getTunnelFailed()
      Has the tunnel failed completely?
      Returns:
      the tunnel failed
    • getTestStatus

      TunnelTestStatus getTestStatus()
      The current test status of this tunnel for UI display.
      Returns:
      the current test status (UNTESTED, TESTING, GOOD, FAILING, or FAILED)
    • setTestStarted

      void setTestStarted()
      The test status when a test is started. Called by TestJob when beginning a tunnel test.
    • setTestFailed

      void setTestFailed()
      The test status when a test fails. Called by TestJob when a tunnel test fails.
    • setTestFailing

      void setTestFailing()
      Mark this tunnel FAILING without consulting the hard-failure counter. Used when a tunnel is retained in the pool on a basis that does not increment getConsecutiveFailures() — soft send timeouts, for example — so setTestFailed() would still report GOOD. Without this the retained tunnel stays selectable and keeps being handed work.
    • getConsecutiveFailures

      int getConsecutiveFailures()
      The number of consecutive test failures.
      Returns:
      the count of consecutive failures
    • incrementTestFailures

      void incrementTestFailures()
      Increment the failure count without triggering pool removal or reuse flag. Used when a previously GOOD tunnel fails a retest or a data-phase send — we want to track the failure for selection deprioritization but keep the tunnel alive for further testing and data delivery.
    • incrementSoftFailures

      void incrementSoftFailures()
      Increment the soft (best-effort timeout) failure count only. Soft status-3 timeouts must not touch the hard/test counter that drives getTunnelFailed() and selection gates.
    • getSoftFailures

      int getSoftFailures()
      Soft best-effort timeout count (status 3). Independent of getConsecutiveFailures().
      Returns:
      the soft failure count
    • getLastLatency

      int getLastLatency()
      The latency of the last tunnel test.
      Returns:
      latency in milliseconds, or -1 if not available
    • setExpiration

      void setExpiration(long when)
      The tunnel's expiration time. Allows proactive tunnel cleanup by marking tunnels for expiry.
      Parameters:
      when - expiration time in milliseconds since epoch
    • hadLocalHopSession

      boolean hadLocalHopSession()
      Whether this tunnel held a transport session to its local hop when it was built, recorded once when the tunnel entered the pool.

      A tunnel cannot complete a build without a session to the peer it sends through, so a true here means the session has since gone away rather than never having existed. That distinction is what lets the pool tell a zombie tunnel from one whose session is still coming up: reading the current session state alone cannot separate the two, and a pool excluding a fifth of its live slots on its own reconnects would be worse than missing a zombie.

      False when the fact was never recorded, in which case the pool declines to attribute a loss rather than risk excluding a live tunnel.

      Returns:
      true when a local-hop session was established at build time
    • getLocalHopMissingSince

      long getLocalHopMissingSince()
      When this tunnel's local transport session was first seen missing, or 0 when it is present or was never observed missing.

      A zombie tunnel — one whose local session is gone but which is still in the pool — occupies a slot that carries nothing until the normal pruning walk removes it, and every health count has to exclude it on the way past. The timestamp is what lets the pool tell a transient loss, which recovers on its own, from a sustained one that is only costing a slot. Dropping on the first observation would trade the wasted slot for rebuild churn, since a peer whose session is re-establishing is not a peer to build away from.

      Recorded by the pool's health walk and cleared when the session returns, so a value here survives across passes and measures duration rather than being reset on each lookup. Zero means never observed missing.

      Returns:
      the time in ms the session was first seen missing, or 0
    • setLocalHopMissingSince

      void setLocalHopMissingSince(long when)
      Record or clear when this tunnel's local transport session was first seen missing.
      Parameters:
      when - the time in ms the session was first seen missing, or 0 to mark the session present
    • setLocalHopSessionEstablished

      void setLocalHopSessionEstablished(boolean established)
      Record whether this tunnel held a transport session to its local hop at build time. Called once, by the pool, as the tunnel is added.
      Parameters:
      established - the session state observed when the tunnel entered the pool