java.lang.Object
net.i2p.router.networkdb.kademlia.StoreMessageSelector
- All Implemented Interfaces:
MessageSelector
Message selector for matching database store operation confirmations.
Filters incoming DeliveryStatusMessage responses to identify acknowledgments for specific store operations. Tracks message IDs, peer information, and expiration times to correlate delivery confirmations with pending store jobs.
Provides logging support for store operation monitoring and implements simple match-once logic to prevent duplicate processing of delivery confirmations.
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final longTime past which the reply is no longer wanted.private booleanTrue once the reply has been matched.private final LogLogger for this class.private final HashThe peer whose reply we are waiting for.private final longMessage id of the store we sent.private final longMessage id of the reply we expect.Constructor Summary
ConstructorsConstructorDescriptionStoreMessageSelector(RouterContext ctx, long storeJobId, RouterInfo peer, long waitingForId, long expiration) Creates a new message selector for database store confirmations.Method Summary
All MethodsModifier and TypeMethodDescriptionbooleanReturns true if the selector should still keep searching for further matches.longReturns the # of milliseconds since the epoch after which this selector should stop searching for matches.booleanisMatch(I2NPMessage message) Returns true if the received message matches the selector.toString()
Field Details
_log
Logger for this class._peer
The peer whose reply we are waiting for._storeJobId
private final long _storeJobIdMessage id of the store we sent._waitingForId
private final long _waitingForIdMessage id of the reply we expect._expiration
private final long _expirationTime past which the reply is no longer wanted._found
private volatile boolean _foundTrue once the reply has been matched.
Constructor Details
StoreMessageSelector
public StoreMessageSelector(RouterContext ctx, long storeJobId, RouterInfo peer, long waitingForId, long expiration) Creates a new message selector for database store confirmations.- Parameters:
ctx- the context supplying the log this selector reports matches tostoreJobId- just for loggingpeer- just for loggingwaitingForId- the unique ID carried by the DeliveryStatusMessage that confirms our storeexpiration- the time in milliseconds after which the reply is no longer waited for
Method Details
continueMatching
public boolean continueMatching()Description copied from interface:MessageSelectorReturns true if the selector should still keep searching for further matches. This is called only if isMatch() returns true. If this returns true, isMatch() will not be called again.- Specified by:
continueMatchingin interfaceMessageSelector- Returns:
- true to keep searching for further matches, false to stop searching
getExpiration
public long getExpiration()Description copied from interface:MessageSelectorReturns the # of milliseconds since the epoch after which this selector should stop searching for matches. At some time after expiration, ifMessageSelector.continueMatching()has not returned false, the job specified byOutNetMessage.getOnFailedReplyJob()will be run for every OutNetMessage associated with this selector (by OutboundMessageRegistry).- Specified by:
getExpirationin interfaceMessageSelector- Returns:
- the number of milliseconds since the epoch at which to stop searching
isMatch
Description copied from interface:MessageSelectorReturns true if the received message matches the selector. If this returns true, the job specified byOutNetMessage.getOnReplyJob()will be run for every OutNetMessage associated with this selector (byInNetMessagePool), after calling setMessage() for that ReplyJob.WARNING this is called from within
OutboundMessageSelector.getOriginalMessages()inside a lock and can lead to deadlocks if the selector does too much inMessageSelector.isMatch(I2NPMessage). Until the lock is removed, take care to keep it simple.- Specified by:
isMatchin interfaceMessageSelector- Parameters:
message- the received message to test against this selector- Returns:
- true if the received message is one this selector was waiting for
toString