java.lang.Object
net.i2p.router.networkdb.kademlia.StoreMessageSelector
All Implemented Interfaces:
MessageSelector

class StoreMessageSelectorextends Object implements 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

    Fields
    Modifier and Type
    Field
    Description
    private final long
    Time past which the reply is no longer wanted.
    private boolean
    True once the reply has been matched.
    private final Log
    Logger for this class.
    private final Hash
    The peer whose reply we are waiting for.
    private final long
    Message id of the store we sent.
    private final long
    Message id of the reply we expect.
  • Constructor Summary

    Constructors
    Constructor
    Description
    StoreMessageSelector(RouterContext ctx, long storeJobId, RouterInfo peer, long waitingForId, long expiration)
    Creates a new message selector for database store confirmations.
  • Method Summary

    All Methods
    Modifier and Type
    Method
    Description
    boolean
    Returns true if the selector should still keep searching for further matches.
    long
    Returns the # of milliseconds since the epoch after which this selector should stop searching for matches.
    boolean
    Returns true if the received message matches the selector.
     

    Methods inherited from class Object

    clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • _log

      private final Log _log
      Logger for this class.
    • _peer

      private final Hash _peer
      The peer whose reply we are waiting for.
    • _storeJobId

      private final long _storeJobId
      Message id of the store we sent.
    • _waitingForId

      private final long _waitingForId
      Message id of the reply we expect.
    • _expiration

      private final long _expiration
      Time past which the reply is no longer wanted.
    • _found

      private volatile boolean _found
      True 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 to
      storeJobId - just for logging
      peer - just for logging
      waitingForId - the unique ID carried by the DeliveryStatusMessage that confirms our store
      expiration - the time in milliseconds after which the reply is no longer waited for
  • Method Details

    • continueMatching

      public boolean continueMatching()
      Description copied from interface: MessageSelector
      Returns 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:
      continueMatching in interface MessageSelector
      Returns:
      true to keep searching for further matches, false to stop searching
    • getExpiration

      public long getExpiration()
      Description copied from interface: MessageSelector
      Returns the # of milliseconds since the epoch after which this selector should stop searching for matches. At some time after expiration, if MessageSelector.continueMatching() has not returned false, the job specified by OutNetMessage.getOnFailedReplyJob() will be run for every OutNetMessage associated with this selector (by OutboundMessageRegistry).
      Specified by:
      getExpiration in interface MessageSelector
      Returns:
      the number of milliseconds since the epoch at which to stop searching
    • isMatch

      public boolean isMatch(I2NPMessage message)
      Description copied from interface: MessageSelector
      Returns true if the received message matches the selector. If this returns true, the job specified by OutNetMessage.getOnReplyJob() will be run for every OutNetMessage associated with this selector (by InNetMessagePool), 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 in MessageSelector.isMatch(I2NPMessage). Until the lock is removed, take care to keep it simple.

      Specified by:
      isMatch in interface MessageSelector
      Parameters:
      message - the received message to test against this selector
      Returns:
      true if the received message is one this selector was waiting for
    • toString

      public String toString()
      Overrides:
      toString in class Object