java.lang.Object
net.i2p.router.client.ClientConnectionRunner
net.i2p.router.client.QueuedClientConnectionRunner

class QueuedClientConnectionRunnerextends ClientConnectionRunner
Zero-copy in-JVM. While super() starts both a reader and a writer thread, we only need a reader thread here.
  • Field Details

  • Constructor Details

    • QueuedClientConnectionRunner

      public QueuedClientConnectionRunner(RouterContext context, ClientManager manager, I2CPMessageQueue queue)
      Create a new runner with the given queues.
      Parameters:
      context - the router context
      manager - the client manager
      queue - the I2CP message queue
  • Method Details

    • startRunning

      public void startRunning()
      Starts the reader thread. Does not call super().
      Overrides:
      startRunning in class ClientConnectionRunner
    • stopRunning

      public void stopRunning()
      Calls super() to stop the reader, and sends a poison message to the client.
      Overrides:
      stopRunning in class ClientConnectionRunner
    • writeMessage

      void writeMessage(I2CPMessage msg)
      In super(), doSend queues it to the writer thread and the writer thread calls writeMessage() to write to the output stream. Since we have no writer thread this shouldn't happen.
      Overrides:
      writeMessage in class ClientConnectionRunner
      Parameters:
      msg - the message to write
    • doSend

      void doSend(I2CPMessage msg) throws I2CPMessageException
      Actually send the I2CPMessage to the client. Non-blocking.
      Overrides:
      doSend in class ClientConnectionRunner
      Parameters:
      msg - the message to send
      Throws:
      I2CPMessageException - if queue full or on other errors
    • doSendWait

      void doSendWait(I2CPMessage msg, long timeoutMs) throws I2CPMessageException
      Send the I2CPMessage, giving the client's queue up to timeoutMs to make room.

      The in-JVM dispatcher drains this queue every few milliseconds, so a full queue means the client is briefly behind rather than gone. Refusing the message outright costs far more than the wait does: a dropped LeaseSet request spends a whole request timing out and then rebuilds the tunnel, for a message that would have been handed over milliseconds later.

      Overrides:
      doSendWait in class ClientConnectionRunner
      Parameters:
      msg - the message to send
      timeoutMs - how long to wait for space in the client's queue
      Throws:
      I2CPMessageException - if the queue is still full after the wait, or on other errors
    • queueFull

      private I2CPMessageException queueFull()
      The error for a client that is not draining its I2CP queue.

      Names the client's side of the queue rather than saying only that a write failed, because that is the fact the operator needs: the router's own writer is healthy and the client is the side that has stopped reading.

      Returns:
      a fresh exception carrying the pending and free-slot counts of the queue
    • setClientVersion

      public void setClientVersion(String version)
      Does nothing. Client version is the core version.
      Overrides:
      setClientVersion in class ClientConnectionRunner
      Parameters:
      version - the client version string
    • getClientVersion

      public String getClientVersion()
      The client version.
      Overrides:
      getClientVersion in class ClientConnectionRunner
      Returns:
      always the published core version; the client version is fixed and cannot be set