java.lang.Object
net.i2p.router.peermanager.PeerTestJob.ReplySelector
- All Implemented Interfaces:
MessageSelector
- Enclosing class:
PeerTestJob
Simple selector looking for a dbStore of the peer specified.
Field Summary
Constructor Summary
ConstructorsConstructorDescriptionReplySelector(Hash peer, long nonce, long expiration) Records the peer, nonce and expiry this outstanding test expects.Method Summary
Modifier and TypeMethodDescriptionbooleanWhether to keep matching replies for this test.longExpiration time of this reply match.private voidhandleSlowTier(PeerProfile prof) Handles a successful test of a slow-tier peer.private booleanhandleSuccessfulTest(PeerTestJob.PeerData data, int timeout, float testAvg, long timeLeft) Records a successful test and updates the profile.private voidhandleTimeout(PeerTestJob.PeerData data, long timeLeft) Handles a peer test timeout.private booleanChecks whether the peer is in the high bandwidth tier.private booleanChecks whether the peer is high or mid bandwidth.booleanisMatch(I2NPMessage message) Whether the message matches this test.private booleanChecks whether the peer is in the slow tier.booleanWhether a matching reply was found.toString()String form of this selector for logging.
Field Details
_expiration
private final long _expirationWhen the selector stops matching._nonce
private final long _nonceThe nonce the reply must carry._peer
The peer being tested._shortHash
Base64 prefix of the peer, for the logs._matchFound
private boolean _matchFoundTrue once the reply matched.
Constructor Details
ReplySelector
Records the peer, nonce and expiry this outstanding test expects.- Parameters:
peer- the peer being testednonce- the nonce the reply must carryexpiration- when the selector stops matching
Method Details
continueMatching
public boolean continueMatching()Whether to keep matching replies for this test.- Specified by:
continueMatchingin interfaceMessageSelector- Returns:
- true to keep searching for further matches, false to stop searching
getExpiration
public long getExpiration()Expiration time of this reply match.- Specified by:
getExpirationin interfaceMessageSelector- Returns:
- the time in milliseconds after which this selector stops matching replies to the outstanding test
isMatch
Whether the message matches this test.- Specified by:
isMatchin interfaceMessageSelector- 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
Checks whether the peer is in the slow tier.- Parameters:
data- the peer's test data- Returns:
- true if the peer is slow
handleSlowTier
Handles a successful test of a slow-tier peer.- Parameters:
prof- the peer's profile
handleTimeout
Handles a peer test timeout.- Parameters:
data- the peer's test datatimeLeft- time left in the job
isHighBandwidthTier
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 datatimeout- the test timeout usedtestAvg- the peer's average test timetimeLeft- time left in the job- Returns:
- true if the peer should be failed
isHighOrMidBandwidthTier
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