public abstract class SynchronousCommandTransport extends CommandTransport
CommandTransport
that implements the read operation in a synchronous fashion.
This class uses a thread to pump commands and pass them to CommandReceiver
.
Constructor and Description |
---|
SynchronousCommandTransport() |
Modifier and Type | Method and Description |
---|---|
void |
setup(Channel channel,
hudson.remoting.CommandTransport.CommandReceiver receiver)
Starts the transport.
|
closeRead, closeWrite, getRemoteCapability
protected Channel channel
public void setup(Channel channel, hudson.remoting.CommandTransport.CommandReceiver receiver)
CommandTransport
Channel
,
after the CommandTransport.getRemoteCapability()
is invoked.
The first purpose of this method is to provide a reference back to Channel
, and
the second purpose of this method is to allow CommandTransport
to message pumping,
where it starts receiving commands from the other side and pass them onto CommandReceiver
.
This abstraction enables asynchronous processing — for example you can have a single thread
serving a large number of Channel
s via NIO.
For subtypes that prefer synchronous operation, extend from SynchronousCommandTransport
.
Channel
implements 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 your CommandTransport.closeRead()
(from the same thread
that invoked 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 CommandReceiver#terminate(IOException)
to initiate the abnormal
channel termination. This in turn calls CommandTransport.closeRead()
to shutdown the reader side.
setup
in class CommandTransport
Copyright © 2016. All rights reserved.