java.lang.Object
net.i2p.router.peermanager.PeerManagerFacadeImpl
All Implemented Interfaces:
PeerManagerFacade, Service

public class PeerManagerFacadeImplextends Object implements PeerManagerFacade
Base implementation that has simple algorithms and periodically saves state.
  • Field Details

    • _log

      private final Log _log
      Logger for this class.
    • _manager

      private PeerManager _manager
      The manager doing the actual work, null until started.
    • _context

      private final RouterContext _context
      The router the manager runs on.
    • _persistenceHelper

      private final ProfilePersistenceHelper _persistenceHelper
      Saves and restores the peer profiles.
    • _testJob

      private final PeerTestJob _testJob
      Job that tests peers for transport support.
    • ENABLE_PEER_TEST

      private static final boolean ENABLE_PEER_TEST
      Switch for the peer testing subsystem.
      See Also:
  • Constructor Details

    • PeerManagerFacadeImpl

      public PeerManagerFacadeImpl(RouterContext ctx)
      Opens this facade's log and builds the profile persistence helper and peer tester.
      Parameters:
      ctx - the router context whose log manager, profile persistence store and peer tester this facade will use
  • Method Details

    • startup

      public void startup()
      Start the peer manager and begin testing peers.
      Specified by:
      startup in interface Service
    • shutdown

      public void shutdown()
      Shut down the peer manager, storing and clearing the profiles.
      Specified by:
      shutdown in interface Service
    • restart

      public void restart()
      Store the profiles and reload them from disk.
      Specified by:
      restart in interface Service
    • setCapabilities

      public void setCapabilities(Hash peer, String caps)
      Record a peer's capability flags.
      Specified by:
      setCapabilities in interface PeerManagerFacade
      Parameters:
      peer - the router hash of the peer whose capabilities are to be set
      caps - non-null
    • removeCapabilities

      public void removeCapabilities(Hash peer)
      Remove all capabilities for the peer from the index.
      Specified by:
      removeCapabilities in interface PeerManagerFacade
      Parameters:
      peer - the router hash of the peer to clear capabilities from
    • getPeerTestJob

      public PeerTestJob getPeerTestJob()
      The peer test job for scheduling priority peer tests.
      Specified by:
      getPeerTestJob in interface PeerManagerFacade
      Returns:
      the PeerTestJob instance, or null if not available
    • getPeersByCapability

      public Set<Hash> getPeersByCapability(char capability)
      Peers advertising the given capability.
      Specified by:
      getPeersByCapability in interface PeerManagerFacade
      Parameters:
      capability - the address capability letter, matched without regard to case
      Returns:
      non-null unmodifiable set
    • countPeersByCapability

      public int countPeersByCapability(char capability)
      How many peers advertise the given capability.
      Specified by:
      countPeersByCapability in interface PeerManagerFacade
      Parameters:
      capability - the address capability letter, matched without regard to case
      Returns:
      the number of profiles advertising that capability