net.i2p.router.peermanager

## Class PeerManager

- java.lang.Object
- - net.i2p.router.peermanager.PeerManager

-     class PeerManager
      extends Object

  Tracks peer capabilities and maintains performance statistics for router peers. Organizes peers by capability sets and manages peer state information for tunnel building and routing decisions.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `(package private) static long` | `REORGANIZE_TIME_LONG` We don't want this much longer than the average connect time, as the CapacityCalculator now includes connection as a factor.
    `(package private) static int` | `REORGANIZES_PER_DAY` After first two hours of uptime ~= 246
    `static String` | `TRACKED_CAPS`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `PeerManager(RouterContext context)` Profiles are now loaded in a separate thread, so this should return quickly.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `(package private) void` | `clearProfiles()`
    `int` | `countPeersByCapability(char capability)`
    `Set<Hash>` | `getPeersByCapability(char capability)`
    `(package private) void` | `loadProfiles()` This may take a long time - 30 seconds or more
    `void` | `removeCapabilities(Hash peer)`
    `(package private) Set<Hash>` | `selectPeers()`
    `(package private) List<Hash>` | `selectPeers(PeerSelectionCriteria criteria)` Find some peers that meet the criteria and we have the netDb info for locally.
    `void` | `setCapabilities(Hash peer, String caps)`
    `(package private) void` | `storeProfiles()`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### REORGANIZE_TIME_LONG

          static final long REORGANIZE_TIME_LONG

      We don't want this much longer than the average connect time, as the CapacityCalculator now includes connection as a factor. This must also be less than 10 minutes, which is the shortest Rate contained in the profile, as the Rates must be coalesced.
      See Also:
        Constant Field Values

    - #### REORGANIZES_PER_DAY

          static final int REORGANIZES_PER_DAY

      After first two hours of uptime ~= 246
      See Also:
        Constant Field Values

    - #### TRACKED_CAPS

          public static final String TRACKED_CAPS

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### PeerManager

          public PeerManager(RouterContext context)

      Profiles are now loaded in a separate thread, so this should return quickly.

  - ### Method Detail

    - #### clearProfiles

          void clearProfiles()

    - #### countPeersByCapability

          public int countPeersByCapability(char capability)

      Parameters:
        `capability` - case-insensitive
      Returns:
        how many

    - #### getPeersByCapability

          public Set<Hash> getPeersByCapability(char capability)

      Parameters:
        `capability` - case-insensitive
      Returns:
        non-null unmodifiable set

    - #### loadProfiles

          void loadProfiles()

      This may take a long time - 30 seconds or more

    - #### removeCapabilities

          public void removeCapabilities(Hash peer)

    - #### selectPeers

          Set<Hash> selectPeers()

    - #### selectPeers

          List<Hash> selectPeers(PeerSelectionCriteria criteria)

      Find some peers that meet the criteria and we have the netDb info for locally. Returned list will not include ourselves. Only used by PeerTestJob (PURPOSE_TEST)

    - #### setCapabilities

          public void setCapabilities(Hash peer,
                                      String caps)

      Parameters:
        `caps` - non-null, case is ignored

    - #### storeProfiles

          void storeProfiles()