Class AbstractByteBufferCommandTransport
- Since:
- 3.0
-
Nested Class Summary
Nested classes/interfaces inherited from class hudson.remoting.CommandTransport
CommandTransport.CommandReceiver -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedDeprecated.protectedAbstractByteBufferCommandTransport(boolean combineBuffers) -
Method Summary
Modifier and TypeMethodDescriptionprotected ChannelGets the channel.final voidreceive(ByteBuffer data) Handle receiving some data.voidsetFrameSize(int transportFrameSize) Set the frame size.final voidsetup(Channel channel, CommandTransport.CommandReceiver receiver) Starts the transport.voidIndicates that the endpoint has encountered a problem.final voidCalled byChannelto send one command to the other side.protected voidwrite(ByteBuffer headerAndData) Write the packet.protected voidwrite(ByteBuffer header, ByteBuffer data) Deprecated.pass true toAbstractByteBufferCommandTransport(boolean)and implementwrite(ByteBuffer)Methods inherited from class hudson.remoting.CommandTransport
closeRead, closeWrite, getRemoteCapability
-
Constructor Details
-
AbstractByteBufferCommandTransport
Deprecated.PasstruetoAbstractByteBufferCommandTransport(boolean)and switchwrite(ByteBuffer, ByteBuffer)towrite(ByteBuffer). -
AbstractByteBufferCommandTransport
protected AbstractByteBufferCommandTransport(boolean combineBuffers)
-
-
Method Details
-
write
Deprecated.pass true toAbstractByteBufferCommandTransport(boolean)and implementwrite(ByteBuffer)- Throws:
IOException
-
write
Write the packet.- Parameters:
headerAndData- the header and data to write.- Throws:
IOException- if the data could not be written.
-
receive
Handle receiving some data.- Parameters:
data- the data that has been received.- Throws:
IOException- if something goes wrong during the receive.InterruptedException- if interrupted during the receive.
-
setFrameSize
public void setFrameSize(int transportFrameSize) Set the frame size.- Parameters:
transportFrameSize- the new frame size (must be in the range1-Short.MAX_VALUE).
-
getChannel
Gets the channel.- Returns:
- the channel.
-
setup
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 allowCommandTransportto 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 ofChannels via NIO. For subtypes that prefer synchronous operation, extend fromSynchronousCommandTransport.Closing the read pump:
ChannelimplementsChannel.CloseCommandits 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,Channelwill 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:
setupin classCommandTransport
-
write
Called byChannelto send one command to the other side.Channelserializes the invocation of this method for ordering. That is, at any given point in time only one thread executes this method.Asynchronous transport must serialize the given command object before returning from this method, as its content can be modified by the calling thread as soon as this method returns. Also, if an asynchronous transport chooses to return from this method without committing data to the network, then it is also responsible for a flow control (by blocking this method if too many commands are queueing up waiting for the network to unclog.)
- Specified by:
writein classCommandTransport- Parameters:
cmd- The command object that needs to be sent. Never null. This must be serialized viaCommand.writeTo(Channel, ObjectOutputStream)last- Informational flag that indicates that this is the last call of theCommandTransport.write(Command, boolean).- Throws:
IOException
-
terminate
Indicates that the endpoint has encountered a problem. This tells the transport that it shouldn't expect future invocation ofreceive(ByteBuffer), and it'll abort the communication.
-
truetoAbstractByteBufferCommandTransport(boolean)and switchwrite(ByteBuffer, ByteBuffer)towrite(ByteBuffer).