net.i2p.router.tunnel.pool
Class TunnelPeerSelector

java.lang.Object
  extended by net.i2p.router.tunnel.pool.TunnelPeerSelector
Direct Known Subclasses:
ClientPeerSelector, ExploratoryPeerSelector

public abstract class TunnelPeerSelector
extends Object

Coordinate the selection of peers to go into a tunnel for one particular pool. Todo: there's nothing non-static in here


Field Summary
protected  RouterContext ctx
           
 
Constructor Summary
protected TunnelPeerSelector(RouterContext context)
           
 
Method Summary
protected  boolean filterSlow(boolean isInbound, boolean isExploratory)
          do we want to skip peers that are slow?
protected  boolean filterUnreachable(boolean isInbound, boolean isExploratory)
          do we want to skip peers who haven't been up for long?
protected  Set<Hash> getClosestHopExclude(boolean isInbound)
          Pick peers that we want to avoid for the first OB hop or last IB hop.
 Set<Hash> getExclude(boolean isInbound, boolean isExploratory)
          Pick peers that we want to avoid
protected  int getLength(TunnelPoolSettings settings)
           
protected  void orderPeers(List<Hash> rv, Hash hash)
          see HashComparator
protected  List<Hash> selectExplicit(TunnelPoolSettings settings, int length)
          For debugging, also possibly for restricted routes? Needs analysis and testing
abstract  List<Hash> selectPeers(TunnelPoolSettings settings)
          Which peers should go into the next tunnel for the given settings?
static boolean shouldExclude(RouterContext ctx, RouterInfo peer)
          warning, this is also called by ProfileOrganizer.isSelectable()
protected  boolean shouldSelectExplicit(TunnelPoolSettings settings)
          For debugging, also possibly for restricted routes? Needs analysis and testing
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ctx

protected final RouterContext ctx
Constructor Detail

TunnelPeerSelector

protected TunnelPeerSelector(RouterContext context)
Method Detail

selectPeers

public abstract List<Hash> selectPeers(TunnelPoolSettings settings)
Which peers should go into the next tunnel for the given settings?

Returns:
ordered list of Hash objects (one per peer) specifying what order they should appear in a tunnel (ENDPOINT FIRST). This includes the local router in the list. If there are no tunnels or peers to build through, and the settings reject 0 hop tunnels, this will return null.

getLength

protected int getLength(TunnelPoolSettings settings)
Returns:
randomized number of hops 0-7, not including ourselves

shouldSelectExplicit

protected boolean shouldSelectExplicit(TunnelPoolSettings settings)
For debugging, also possibly for restricted routes? Needs analysis and testing

Returns:
should always be false

selectExplicit

protected List<Hash> selectExplicit(TunnelPoolSettings settings,
                                    int length)
For debugging, also possibly for restricted routes? Needs analysis and testing

Returns:
should always be false

getExclude

public Set<Hash> getExclude(boolean isInbound,
                            boolean isExploratory)
Pick peers that we want to avoid


getClosestHopExclude

protected Set<Hash> getClosestHopExclude(boolean isInbound)
Pick peers that we want to avoid for the first OB hop or last IB hop. This is only filled in if our router sig type is not DSA.

Parameters:
isInbound - unused
Returns:
null if none
Since:
0.9.17

shouldExclude

public static boolean shouldExclude(RouterContext ctx,
                                    RouterInfo peer)
warning, this is also called by ProfileOrganizer.isSelectable()


filterUnreachable

protected boolean filterUnreachable(boolean isInbound,
                                    boolean isExploratory)
do we want to skip peers who haven't been up for long?

Returns:
true for inbound, false for outbound, unless configured otherwise

filterSlow

protected boolean filterSlow(boolean isInbound,
                             boolean isExploratory)
do we want to skip peers that are slow?

Returns:
true unless configured otherwise

orderPeers

protected void orderPeers(List<Hash> rv,
                          Hash hash)
see HashComparator