java.lang.Object
net.i2p.router.JobImpl
net.i2p.router.networkdb.HandleDatabaseLookupMessageJob
All Implemented Interfaces:
Job
Direct Known Subclasses:
HandleFloodfillDatabaseLookupMessageJob

public class HandleDatabaseLookupMessageJobextends JobImpl
Handle a lookup for a key received from a remote peer. Needs to be implemented to send back replies, etc Unused directly - see kademlia/ for extension.
  • Field Details

    • _log

      private final Log _log
      The log for the lookup job.
    • _message

      private final DatabaseLookupMessage _message
      The lookup message being handled.
    • _replyKeyConsumed

      private boolean _replyKeyConsumed
      True once the reply key was used.
    • _us

      private final Hash _us
      Our own router hash.
    • _msgIDBloomXor

      private final long _msgIDBloomXor
      The bloom filter xor of the message id.
    • MAX_ROUTERS_RETURNED

      private static final int MAX_ROUTERS_RETURNED
      Most routers returned in a reply.
      See Also:
    • REPLY_TIMEOUT

      private static final int REPLY_TIMEOUT
      Time allowed for sending a reply.
      See Also:
    • MESSAGE_PRIORITY

      private static final int MESSAGE_PRIORITY
      The priority of the reply messages.
      See Also:
    • EXPIRE_DELAY

      public static final long EXPIRE_DELAY
      If a routerInfo structure isn't this recent, don't send it out. Equal to KNDF.ROUTER_INFO_EXPIRATION_FLOODFILL.
      See Also:
  • Constructor Details

    • HandleDatabaseLookupMessageJob

      public HandleDatabaseLookupMessageJob(RouterContext ctx, DatabaseLookupMessage receivedMessage, RouterIdentity _from, Hash _fromHash, long msgIDBloomXor)
      Creates a new HandleDatabaseLookupMessageJob.
      Parameters:
      ctx - the router context
      receivedMessage - the received message
      _from - the router identity of the sender
      _fromHash - the hash of the sender
      msgIDBloomXor - the message ID bloom XOR value
  • Method Details

    • runJob

      public void runJob()
      Description copied from interface: Job
      Actually perform the task. This call blocks until the Job is complete.
    • getNearestRouters

      private Set<Hash> getNearestRouters(DatabaseLookupMessage.Type lookupType)
      Closest to the message's search key, honoring the message's dontInclude set. Will not include us. Side effect - adds us to the message's dontInclude set.
      Parameters:
      lookupType - the message's lookup type, EXPL also excludes the fake hash
      Returns:
      the nearest routers
    • sendData

      private void sendData(Hash key, DatabaseEntry data, Hash toPeer, TunnelId replyTunnel)
      Sends the data that was found.
      Parameters:
      key - the key that was searched
      data - the entry that was found
      toPeer - the peer to reply to
      replyTunnel - the tunnel for the reply
    • sendClosest

      protected void sendClosest(Hash key, Set<Hash> routerHashes, Hash toPeer, TunnelId replyTunnel)
      Send the closest routers to the requesting peer.
      Parameters:
      key - the search key
      routerHashes - the set of router hashes to send
      toPeer - the destination peer
      replyTunnel - the reply tunnel
    • sendMessage

      protected void sendMessage(I2NPMessage message, Hash toPeer, TunnelId replyTunnel)
      Send an I2NP message to the specified peer.
      Parameters:
      message - the I2NP message being sent as the reply
      toPeer - the destination peer
      replyTunnel - the reply tunnel, or null for direct delivery
    • sendThroughTunnel

      private void sendThroughTunnel(I2NPMessage message, Hash toPeer, TunnelId replyTunnel)
      Sends the message through the reply tunnel.
      Parameters:
      message - the message to send
      toPeer - the peer to send to
      replyTunnel - the tunnel for the reply
    • getName

      public String getName()
      Description copied from interface: Job
      Descriptive name of the task.
      Returns:
      the descriptive name of the task
    • dropped

      public void dropped()
      Description copied from class: JobImpl
      Default implementation does nothing. Called when the job is dropped due to router overload. Subclasses can override to perform cleanup or requeueing of other tasks.
      Specified by:
      dropped in interface Job
      Overrides:
      dropped in class JobImpl