hudson.remoting
Class SynchronousCommandTransport
java.lang.Object
hudson.remoting.CommandTransport
hudson.remoting.SynchronousCommandTransport
- Direct Known Subclasses:
- AbstractSynchronousByteArrayCommandTransport
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
.
- Author:
- Kohsuke Kawaguchi
Method Summary |
void |
setup(Channel channel,
hudson.remoting.CommandTransport.CommandReceiver receiver)
Starts the transport. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
channel
protected Channel channel
SynchronousCommandTransport
public SynchronousCommandTransport()
setup
public void setup(Channel channel,
hudson.remoting.CommandTransport.CommandReceiver receiver)
- Description copied from class:
CommandTransport
- Starts the transport.
This method is called once and only once at the end of the initialization of
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
.
Closing the read pump
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.
- Specified by:
setup
in class CommandTransport
Copyright © 2013. All Rights Reserved.