java.lang.Object
net.i2p.router.peermanager.PeerTestJob.ReplySelector
All Implemented Interfaces:
MessageSelector
Enclosing class:
PeerTestJob

private class PeerTestJob.ReplySelectorextends Object implements MessageSelector
Simple selector looking for a dbStore of the peer specified.
  • Field Details

    • _expiration

      private final long _expiration
      When the selector stops matching.
    • _nonce

      private final long _nonce
      The nonce the reply must carry.
    • _peer

      private final Hash _peer
      The peer being tested.
    • _shortHash

      private final String _shortHash
      Base64 prefix of the peer, for the logs.
    • _matchFound

      private boolean _matchFound
      True once the reply matched.
  • Constructor Details

    • ReplySelector

      public ReplySelector(Hash peer, long nonce, long expiration)
      Records the peer, nonce and expiry this outstanding test expects.
      Parameters:
      peer - the peer being tested
      nonce - the nonce the reply must carry
      expiration - when the selector stops matching
  • Method Details

    • continueMatching

      public boolean continueMatching()
      Whether to keep matching replies for this test.
      Specified by:
      continueMatching in interface MessageSelector
      Returns:
      true to keep searching for further matches, false to stop searching
    • getExpiration

      public long getExpiration()
      Expiration time of this reply match.
      Specified by:
      getExpiration in interface MessageSelector
      Returns:
      the time in milliseconds after which this selector stops matching replies to the outstanding test
    • isMatch

      public boolean isMatch(I2NPMessage message)
      Whether the message matches this test.
      Specified by:
      isMatch in interface MessageSelector
      Parameters:
      message - the received message to test against this selector
      Returns:
      true only for a DeliveryStatusMessage whose message ID equals the nonce this test is waiting on
    • isSlowTier

      private boolean isSlowTier(PeerTestJob.PeerData data)
      Checks whether the peer is in the slow tier.
      Parameters:
      data - the peer's test data
      Returns:
      true if the peer is slow
    • handleSlowTier

      private void handleSlowTier(PeerProfile prof)
      Handles a successful test of a slow-tier peer.
      Parameters:
      prof - the peer's profile
    • handleTimeout

      private void handleTimeout(PeerTestJob.PeerData data, long timeLeft)
      Handles a peer test timeout.
      Parameters:
      data - the peer's test data
      timeLeft - time left in the job
    • isHighBandwidthTier

      private boolean isHighBandwidthTier(PeerTestJob.PeerData data)
      Checks whether the peer is in the high bandwidth tier.
      Parameters:
      data - the peer's test data
      Returns:
      true if the peer is high bandwidth
    • handleSuccessfulTest

      private boolean handleSuccessfulTest(PeerTestJob.PeerData data, int timeout, float testAvg, long timeLeft)
      Records a successful test and updates the profile.
      Parameters:
      data - the peer's test data
      timeout - the test timeout used
      testAvg - the peer's average test time
      timeLeft - time left in the job
      Returns:
      true if the peer should be failed
    • isHighOrMidBandwidthTier

      private boolean isHighOrMidBandwidthTier(PeerTestJob.PeerData data)
      Checks whether the peer is high or mid bandwidth.
      Parameters:
      data - the peer's test data
      Returns:
      true if the peer is high or mid bandwidth
    • matchFound

      public boolean matchFound()
      Whether a matching reply was found.
      Returns:
      true if the reply matched
    • toString

      public String toString()
      String form of this selector for logging.
      Overrides:
      toString in class Object