Class CommandConnection

java.lang.Object
io.deephaven.enterprise.comm.api.ApplicationStateHolder.Impl
io.deephaven.enterprise.comm.impl.nio.CommandConnection
All Implemented Interfaces:
com.fishlib.base.log.LogOutputAppendable, ApplicationStateHolder, IOHandler

public abstract class CommandConnection extends ApplicationStateHolder.Impl implements IOHandler, com.fishlib.base.log.LogOutputAppendable
Provides a common implementation for connection handlers which read and write objects using the WObject protocol. Created by IntelliJ IDEA. User: jrauser Date: Feb 22, 2007 Time: 8:31:04 AM To change this template use File | Settings | File Templates.
  • Field Details

    • log

      protected final com.fishlib.io.logger.Logger log
      where we log to
    • logId

      protected final String logId
      the identifier of this connection, for log entries
    • job

      protected final IOJob job
      the job with which we communicate
    • reader

      protected final WObjectReader reader
      an object reader for incoming data
    • messages

      protected final MessageSequenceSink messages
      a message sequence for outgoing messages
    • writer

      protected final WObjectWriter writer
      an object writer for serializing outgoing messages
    • clock

      protected final com.fishlib.base.clock.Clock clock
      the clock used to set send timestamps and measure incoming lag
    • hostName

      protected String hostName
      the job's host name, cached if it's been looked up previously
    • hostAddr

      protected InetAddress hostAddr
      the job's host address, cached if it's been looked up previously
  • Constructor Details

    • CommandConnection

      public CommandConnection(com.fishlib.io.logger.Logger log, String logId, IOJob job, WObjectReader reader, WObjectWriter writer, MessageSequenceSink messages, com.fishlib.base.clock.Clock clock)
      Construct a new client entry for an IOJob. Use the logId as the statistics item prefix.
    • CommandConnection

      public CommandConnection(com.fishlib.io.logger.Logger log, String logId, String statsItemPrefix, IOJob job, WObjectReader reader, WObjectWriter writer, MessageSequenceSink messages, com.fishlib.base.clock.Clock clock)
      Construct a new client entry for an IOJob using the specified statistics item prefix.
  • Method Details

    • toString

      public String toString()
      Return a string representation for this connection.
      Overrides:
      toString in class Object
    • append

      public com.fishlib.base.log.LogOutput append(com.fishlib.base.log.LogOutput logOutput)
      Specified by:
      append in interface com.fishlib.base.log.LogOutputAppendable
    • getHostName

      public String getHostName()
    • getHostAddr

      public InetAddress getHostAddr()
    • getHostPort

      public int getHostPort()
    • startJob

      public void startJob(IOJob job)
      Specified by:
      startJob in interface IOHandler
    • endJob

      public void endJob(IOJob job)
      Specified by:
      endJob in interface IOHandler
    • handleIncoming

      public boolean handleIncoming(IOJob job)
      Description copied from interface: IOHandler
      Handle input from an IOJob. This method will be called again if it returns true, and it must do so if the handler does not consume all the data (or it might never be called to finish processing the buffer).
      Specified by:
      handleIncoming in interface IOHandler
      Parameters:
      job - the IOJob containing the input data
      Returns:
      true if there is or might be enough data to process another message, false if the buffer is empty or there was an error
    • handleOutgoing

      public void handleOutgoing(IOJob job, long numFlushed)
      Specified by:
      handleOutgoing in interface IOHandler
    • handleEOF

      public void handleEOF(IOJob job)
      Specified by:
      handleEOF in interface IOHandler
    • handleTimeout

      public void handleTimeout(IOJob job)
      Specified by:
      handleTimeout in interface IOHandler
    • handleError

      public void handleError(IOJob job, IOException x)
      Specified by:
      handleError in interface IOHandler
    • handleIncoming

      public abstract void handleIncoming(WObjectUtil.Envelope<com.fishlib.base.Command> cmd, long now)
    • sendObject

      public void sendObject(Object obj, boolean allowFlush) throws IOException
      Sends an object to the connection's peer. This sends an Object instead of a Command, because the Walleye client/server protocol requires that the first object sent from the client to the server be a bare string, not a Command.
      Throws:
      IOException