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.
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.deephaven.enterprise.comm.api.ApplicationStateHolder
ApplicationStateHolder.Impl -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final com.fishlib.base.clock.Clockthe clock used to set send timestamps and measure incoming lagprotected InetAddressthe job's host address, cached if it's been looked up previouslyprotected Stringthe job's host name, cached if it's been looked up previouslyprotected final IOJobthe job with which we communicateprotected final com.fishlib.io.logger.Loggerwhere we log toprotected final Stringthe identifier of this connection, for log entriesprotected final MessageSequenceSinka message sequence for outgoing messagesprotected final WObjectReaderan object reader for incoming dataprotected final WObjectWriteran object writer for serializing outgoing messages -
Constructor Summary
ConstructorsConstructorDescriptionCommandConnection(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.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 Summary
Modifier and TypeMethodDescriptioncom.fishlib.base.log.LogOutputappend(com.fishlib.base.log.LogOutput logOutput) voidintvoidvoidhandleError(IOJob job, IOException x) abstract voidhandleIncoming(WObjectUtil.Envelope<com.fishlib.base.Command> cmd, long now) booleanhandleIncoming(IOJob job) Handle input from an IOJob.voidhandleOutgoing(IOJob job, long numFlushed) voidhandleTimeout(IOJob job) voidsendObject(Object obj, boolean allowFlush) Sends an object to the connection's peer.voidtoString()Return a string representation for this connection.Methods inherited from class io.deephaven.enterprise.comm.api.ApplicationStateHolder.Impl
getApplicationState, setApplicationState
-
Field Details
-
log
protected final com.fishlib.io.logger.Logger logwhere we log to -
logId
the identifier of this connection, for log entries -
job
the job with which we communicate -
reader
an object reader for incoming data -
messages
a message sequence for outgoing messages -
writer
an object writer for serializing outgoing messages -
clock
protected final com.fishlib.base.clock.Clock clockthe clock used to set send timestamps and measure incoming lag -
hostName
the job's host name, cached if it's been looked up previously -
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
Return a string representation for this connection. -
append
public com.fishlib.base.log.LogOutput append(com.fishlib.base.log.LogOutput logOutput) - Specified by:
appendin interfacecom.fishlib.base.log.LogOutputAppendable
-
getHostName
-
getHostAddr
-
getHostPort
public int getHostPort() -
startJob
-
endJob
-
handleIncoming
Description copied from interface:IOHandlerHandle 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:
handleIncomingin interfaceIOHandler- 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
- Specified by:
handleOutgoingin interfaceIOHandler
-
handleEOF
-
handleTimeout
- Specified by:
handleTimeoutin interfaceIOHandler
-
handleError
- Specified by:
handleErrorin interfaceIOHandler
-
handleIncoming
-
sendObject
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
-