java.lang.Object
net.i2p.router.tunnel.pool.ExcluderBase
net.i2p.router.tunnel.pool.TunnelPeerSelector.Excluder
All Implemented Interfaces:
Iterable<Hash>, Collection<Hash>, Set<Hash>
Enclosing class:
TunnelPeerSelector

protected class TunnelPeerSelector.Excluderextends ExcluderBase
Excluder that automatically adds peers to the set when they should be excluded.
  • Field Details

    • MAX_EXCLUDED_PEERS

      private static final int MAX_EXCLUDED_PEERS
      Cap on classified exclusions. Bulk-loaded diversity entries carry no reason and are therefore never evicted; only reasoned entries are bounded, oldest first.
      See Also:
    • _isIn

      private final boolean _isIn
      Whether this selector builds inbound tunnels.
    • _isExpl

      private final boolean _isExpl
      Whether this selector builds exploratory tunnels.
    • _buildSuccess

      private final double _buildSuccess
      Build success ratio, fetched once per Excluder construction.
    • _activityWindow

      private final long _activityWindow
      Activity window in ms, computed once per Excluder construction. TunnelPeerSelector.getActivityWindow(RouterContext, double) calls countActivePeers(), which scans every non-failing profile under a read lock; recomputing it per candidate made selection O(candidates × peers). It is constant for one selection.
    • _allowNoSignal

      private volatile boolean _allowNoSignal
      When true, the no-signal check in TunnelPeerSelector.getExclusionReason(Hash, boolean, boolean, double, long) is skipped, allowing untested peers to be considered for tunnel builds. Set by relaxNoSignalExclusions() when peer scarcity demands it.
  • Constructor Details

    • Excluder

      public Excluder(boolean isInbound, boolean isExploratory)
      Automatically adds selectPeersInTooManyTunnels(), unless i2np.allowLocal. Fetches the build success ratio once, so the per-peer exclusion checks in contains(Object) never re-read router statistics.
      Parameters:
      isInbound - true for an inbound pool
      isExploratory - true for an exploratory pool
    • Excluder

      public Excluder(boolean isInbound, boolean isExploratory, double buildSuccess)
      Automatically adds selectPeersInTooManyTunnels(), unless i2np.allowLocal. Uses a build success ratio already fetched by the caller.
      Parameters:
      isInbound - true for an inbound pool
      isExploratory - true for an exploratory pool
      buildSuccess - the global build success ratio in [0.0, 1.0]
    • Excluder

      public Excluder(boolean isInbound, boolean isExploratory, Set<Hash> toAdd)
      Does not add selectPeersInTooManyTunnels(). Makes a copy of toAdd. Fetches the build success ratio once, so the per-peer exclusion checks in contains(Object) never re-read router statistics.
      Parameters:
      isInbound - true for an inbound pool
      isExploratory - true for an exploratory pool
      toAdd - initial contents, copied
    • Excluder

      public Excluder(boolean isInbound, boolean isExploratory, Set<Hash> toAdd, double buildSuccess)
      Does not add selectPeersInTooManyTunnels(). Makes a copy of toAdd. Uses a build success ratio already fetched by the caller.
      Parameters:
      isInbound - true for an inbound pool
      isExploratory - true for an exploratory pool
      toAdd - initial contents, copied
      buildSuccess - the global build success ratio in [0.0, 1.0]
  • Method Details

    • contains

      public boolean contains(Object o)
      Description copied from class: ExcluderBase
      Automatically check if peer is allowed and add the Hash to the set if not.
      Specified by:
      contains in interface Collection<Hash>
      Specified by:
      contains in interface Set<Hash>
      Specified by:
      contains in class ExcluderBase
      Parameters:
      o - a peer hash to look up in the underlying set
      Returns:
      true if peer should be excluded
    • relaxNoSignalExclusions

      int relaxNoSignalExclusions()
      Relax no-signal exclusions under peer scarcity: remove all peers previously excluded for "no-signal" from the underlying set, and set a flag so future contains() calls skip the no-signal check. This allows untested peers to be considered as tunnel candidates when we can't build tunnels due to insufficient proven peers.
      Returns:
      number of peers un-excluded
    • formatByReasonWithPeers

      String formatByReasonWithPeers()
      Format excluded peers grouped by reason, sorted by hash within each group.
      Returns:
      multi-line string like "Too many tunnels (128): peer1 peer2..."