Class SynchronousCommandTransport
- Direct Known Subclasses:
AbstractSynchronousByteArrayCommandTransport
CommandTransport
that implements the read operation in a synchronous fashion.
This class uses a thread to pump commands and pass them to CommandTransport.CommandReceiver
.
- Author:
- Kohsuke Kawaguchi
-
Nested Class Summary
Nested classes/interfaces inherited from class hudson.remoting.CommandTransport
CommandTransport.CommandReceiver
-
Field Summary
-
Constructor Summary
-
Method Summary
Methods inherited from class hudson.remoting.CommandTransport
closeRead, closeWrite, getRemoteCapability, write
-
Field Details
-
channel
-
-
Constructor Details
-
SynchronousCommandTransport
public SynchronousCommandTransport()
-
-
Method Details
-
read
Called byChannel
to read the next command to arrive from the stream. -
setup
Description copied from class:CommandTransport
Starts the transport. This method is called once and only once at the end of the initialization ofChannel
, after theCommandTransport.getRemoteCapability()
is invoked. The first purpose of this method is to provide a reference back toChannel
, and the second purpose of this method is to allowCommandTransport
to message pumping, where it starts receiving commands from the other side and pass them ontoCommandTransport.CommandReceiver
. This abstraction enables asynchronous processing — for example you can have a single thread serving a large number ofChannel
s via NIO. For subtypes that prefer synchronous operation, extend fromSynchronousCommandTransport
.Closing the read pump:
Channel
implementsChannel.CloseCommand
its own "end of command stream" marker, and therefore under the orderly shutdown scenario, it doesn't rely on the transport to provide EOF-like marker. Instead,Channel
will call yourCommandTransport.closeRead()
(from the same thread that invokedCommandTransport.CommandReceiver.handle(Command)
) to indicate that it is done with the reading.If the transport encounters any error from the lower layer (say, the underlying TCP/IP socket encountered a REST), then call
CommandTransport.CommandReceiver.terminate(IOException)
to initiate the abnormal channel termination. This in turn callsCommandTransport.closeRead()
to shutdown the reader side.- Specified by:
setup
in classCommandTransport
-