## net.i2p.router.peermanager
Class ProfileOrganizer

    java.lang.Object
      net.i2p.router.peermanager.ProfileOrganizer

    public class ProfileOrganizer

extends java.lang.Object

Keep the peer profiles organized according to the tiered model. This does not actively update anything - the reorganize() method should be called periodically to recalculate thresholds and move profiles into the appropriate tiers, and addProfile() should be used to add new profiles (placing them into the appropriate groupings).

Field Summary
`static int` `DEFAULT_MINIMUM_FAST_PEERS`
`static int` `DEFAULT_MINIMUM_HIGH_CAPACITY_PEERS`
`static java.lang.String` `PROP_MINIMUM_FAST_PEERS` Defines the minimum number of 'fast' peers that the organizer should select.
`static java.lang.String` `PROP_MINIMUM_HIGH_CAPACITY_PEERS` Defines the minimum number of 'high capacity' peers that the organizer should select when using the mean - if less than this many are available, select the capacity by the median.

Constructor Summary
`ProfileOrganizer(RouterContext context)`

Method Summary
`PeerProfile` `addProfile(PeerProfile profile)` Add the new profile, returning the old value (or null if no profile existed)
`int` `countActivePeers()`
`int` `countFailingPeers()`
`int` `countFastPeers()`
`int` `countHighCapacityPeers()`
`int` `countNotFailingPeers()`
`int` `countWellIntegratedPeers()`
`void` `exportProfile(Hash profile, java.io.OutputStream out)`
`double` `getCapacityThreshold()`
`double` `getIntegrationThreshold()`
`protected int` `getMinimumFastPeers()` Defines the minimum number of 'fast' peers that the organizer should select.
`protected int` `getMinimumHighCapacityPeers()` Defines the minimum number of 'fast' peers that the organizer should select.
`PeerProfile` `getProfile(Hash peer)` Retrieve the profile for the given peer, if one exists (else null)
`double` `getSpeedThreshold()`
`(package private) Hash` `getUs()`
`boolean` `isFailing(Hash peer)`
`boolean` `isFast(Hash peer)`
`boolean` `isHighCapacity(Hash peer)`
`boolean` `isSelectable(Hash peer)`
`boolean` `isWellIntegrated(Hash peer)`
`static void` `main(java.lang.String[] args)` Read in all of the profiles specified and print out their calculated values.
`boolean` `peerSendsBadReplies(Hash peer)` Does the given peer send us bad replies - either invalid store messages (expired, corrupt, etc) or unreachable replies (pointing towards routers that don't exist).
`void` `renderStatusHTML(java.io.Writer out)`
`void` `reorganize()` Place peers into the correct tier, as well as expand/contract and even drop profiles according to whatever limits are in place.
`void` `reorganize(boolean shouldCoalesce)`
`java.util.Set` `selectAllPeers()` Find the hashes for all peers we are actively profiling
`void` `selectFailingPeers(int howMany, java.util.Set exclude, java.util.Set matches)` I'm not quite sure why you'd want this...
`void` `selectFastPeers(int howMany, java.util.Set exclude, java.util.Set matches)` Return a set of Hashes for peers that are both fast and reliable.
`void` `selectHighCapacityPeers(int howMany, java.util.Set exclude, java.util.Set matches)` Return a set of Hashes for peers that have a high capacity
`void` `selectNotFailingPeers(int howMany, java.util.Set exclude, java.util.Set matches)` Return a set of Hashes for peers that are not failing, preferring ones that we are already talking with
`void` `selectNotFailingPeers(int howMany, java.util.Set exclude, java.util.Set matches, boolean onlyNotFailing)` Return a set of Hashes for peers that are not failing, preferring ones that we are already talking with
`void` `selectWellIntegratedPeers(int howMany, java.util.Set exclude, java.util.Set matches)` Return a set of Hashes for peers that are well integrated into the network.
`void` `setUs(Hash us)`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### PROP_MINIMUM_FAST_PEERS

    public static final java.lang.String PROP_MINIMUM_FAST_PEERS

  Defines the minimum number of 'fast' peers that the organizer should select. See `getMinimumFastPeers()`

  See Also:
    Constant Field Values

### DEFAULT_MINIMUM_FAST_PEERS

    public static final int DEFAULT_MINIMUM_FAST_PEERS

See Also:
  Constant Field Values

### PROP_MINIMUM_HIGH_CAPACITY_PEERS

    public static final java.lang.String PROP_MINIMUM_HIGH_CAPACITY_PEERS

  Defines the minimum number of 'high capacity' peers that the organizer should select when using the mean - if less than this many are available, select the capacity by the median.

  See Also:
    Constant Field Values

### DEFAULT_MINIMUM_HIGH_CAPACITY_PEERS

    public static final int DEFAULT_MINIMUM_HIGH_CAPACITY_PEERS

See Also:
  Constant Field Values

Constructor Detail

### ProfileOrganizer

    public ProfileOrganizer(RouterContext context)

Method Detail

### setUs

    public void setUs(Hash us)

### getUs

    Hash getUs()

### getSpeedThreshold

    public double getSpeedThreshold()

### getCapacityThreshold

    public double getCapacityThreshold()

### getIntegrationThreshold

    public double getIntegrationThreshold()

### getProfile

    public PeerProfile getProfile(Hash peer)

  Retrieve the profile for the given peer, if one exists (else null)

### addProfile

    public PeerProfile addProfile(PeerProfile profile)
                           throws java.lang.IllegalStateException

  Add the new profile, returning the old value (or null if no profile existed)

  Throws:
    `java.lang.IllegalStateException`

### countFastPeers

    public int countFastPeers()

### countHighCapacityPeers

    public int countHighCapacityPeers()

### countWellIntegratedPeers

    public int countWellIntegratedPeers()

### countNotFailingPeers

    public int countNotFailingPeers()

### countFailingPeers

    public int countFailingPeers()

### countActivePeers

    public int countActivePeers()

### isFast

    public boolean isFast(Hash peer)

### isHighCapacity

    public boolean isHighCapacity(Hash peer)

### isWellIntegrated

    public boolean isWellIntegrated(Hash peer)

### isFailing

    public boolean isFailing(Hash peer)

### peerSendsBadReplies

    public boolean peerSendsBadReplies(Hash peer)

  Does the given peer send us bad replies - either invalid store messages (expired, corrupt, etc) or unreachable replies (pointing towards routers that don't exist).

### exportProfile

    public void exportProfile(Hash profile,
                              java.io.OutputStream out)
                       throws java.io.IOException

  Throws:
    `java.io.IOException`

### renderStatusHTML

    public void renderStatusHTML(java.io.Writer out)
                          throws java.io.IOException

  Throws:
    `java.io.IOException`

### selectFastPeers

    public void selectFastPeers(int howMany,
                                java.util.Set exclude,
                                java.util.Set matches)

  Return a set of Hashes for peers that are both fast and reliable. If an insufficient number of peers are both fast and reliable, fall back onto high capacity peers, and if that doesn't contain sufficient peers, fall back onto not failing peers, and even THAT doesn't have sufficient peers, fall back onto failing peers.

  Parameters:
    `howMany` - how many peers are desired
    `exclude` - set of Hashes for routers that we don't want selected
    `matches` - set to store the return value in

### selectHighCapacityPeers

    public void selectHighCapacityPeers(int howMany,
                                        java.util.Set exclude,
                                        java.util.Set matches)

  Return a set of Hashes for peers that have a high capacity

### selectWellIntegratedPeers

    public void selectWellIntegratedPeers(int howMany,
                                          java.util.Set exclude,
                                          java.util.Set matches)

  Return a set of Hashes for peers that are well integrated into the network.

### selectNotFailingPeers

    public void selectNotFailingPeers(int howMany,
                                      java.util.Set exclude,
                                      java.util.Set matches)

  Return a set of Hashes for peers that are not failing, preferring ones that we are already talking with

### selectNotFailingPeers

    public void selectNotFailingPeers(int howMany,
                                      java.util.Set exclude,
                                      java.util.Set matches,
                                      boolean onlyNotFailing)

  Return a set of Hashes for peers that are not failing, preferring ones that we are already talking with

  Parameters:
    `howMany` - how many peers to find
    `exclude` - what peers to skip (may be null)
    `matches` - set to store the matches in
    `onlyNotFailing` - if true, don't include any high capacity peers

### selectFailingPeers

    public void selectFailingPeers(int howMany,
                                   java.util.Set exclude,
                                   java.util.Set matches)

  I'm not quite sure why you'd want this... (other than for failover from the better results)

### selectAllPeers

    public java.util.Set selectAllPeers()

  Find the hashes for all peers we are actively profiling

### reorganize

    public void reorganize()

  Place peers into the correct tier, as well as expand/contract and even drop profiles according to whatever limits are in place. Peer profiles are not coalesced during this method, but the averages are recalculated.

### reorganize

    public void reorganize(boolean shouldCoalesce)

### isSelectable

    public boolean isSelectable(Hash peer)

### getMinimumFastPeers

    protected int getMinimumFastPeers()

  Defines the minimum number of 'fast' peers that the organizer should select. If the profile calculators derive a threshold that does not select at least this many peers, the threshold will be overridden to make sure this many peers are in the fast+reliable group. This parameter should help deal with a lack of diversity in the tunnels created when some peers are particularly fast.

  Returns:
    minimum number of peers to be placed in the 'fast' group

### getMinimumHighCapacityPeers

    protected int getMinimumHighCapacityPeers()

  Defines the minimum number of 'fast' peers that the organizer should select. If the profile calculators derive a threshold that does not select at least this many peers, the threshold will be overridden to make sure this many peers are in the fast+reliable group. This parameter should help deal with a lack of diversity in the tunnels created when some peers are particularly fast.

  Returns:
    minimum number of peers to be placed in the 'fast' group

### main

    public static void main(java.lang.String[] args)

  Read in all of the profiles specified and print out their calculated values. Usage:

        ProfileOrganizer [filename]*