hudson.remoting
Class AbstractSynchronousByteArrayCommandTransport

java.lang.Object
  extended by hudson.remoting.CommandTransport
      extended by hudson.remoting.SynchronousCommandTransport
          extended by hudson.remoting.AbstractSynchronousByteArrayCommandTransport

public abstract class AbstractSynchronousByteArrayCommandTransport
extends SynchronousCommandTransport

SynchronousCommandTransport that works with byte[] instead of command object. This base class hides away some of the Command serialization details. One less thing for transport implementers to worry about.

Since:
2.13
Author:
Kohsuke Kawaguchi

Field Summary
 
Fields inherited from class hudson.remoting.SynchronousCommandTransport
channel
 
Constructor Summary
AbstractSynchronousByteArrayCommandTransport()
           
 
Method Summary
 hudson.remoting.Command read()
          Called by Channel to read the next command to arrive from the stream.
abstract  byte[] readBlock(Channel channel)
          Read a byte[] from the underlying transport for the given channel.
 void write(hudson.remoting.Command cmd, boolean last)
          Called by Channel to send one command to the other side.
abstract  void writeBlock(Channel channel, byte[] payload)
          Writes a byte[] to the transport.
 
Methods inherited from class hudson.remoting.SynchronousCommandTransport
setup
 
Methods inherited from class hudson.remoting.CommandTransport
closeRead, closeWrite, getRemoteCapability
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractSynchronousByteArrayCommandTransport

public AbstractSynchronousByteArrayCommandTransport()
Method Detail

readBlock

public abstract byte[] readBlock(Channel channel)
                          throws java.io.IOException,
                                 java.lang.ClassNotFoundException
Read a byte[] from the underlying transport for the given channel.

Throws:
java.io.IOException
java.lang.ClassNotFoundException

writeBlock

public abstract void writeBlock(Channel channel,
                                byte[] payload)
                         throws java.io.IOException
Writes a byte[] to the transport. The block boundary is significant. A transport needs to ensure that that the same byte[] is read by the peer through readBlock(Channel) (unlike TCP, where a single write can be split into multiple read()s on the other side.)

Throws:
java.io.IOException

read

public hudson.remoting.Command read()
                             throws java.io.IOException,
                                    java.lang.ClassNotFoundException
Description copied from class: SynchronousCommandTransport
Called by Channel to read the next command to arrive from the stream.

Throws:
java.io.IOException
java.lang.ClassNotFoundException

write

public void write(hudson.remoting.Command cmd,
                  boolean last)
           throws java.io.IOException
Description copied from class: CommandTransport
Called by Channel to send one command to the other side. Channel serializes 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.)

Parameters:
cmd - The command object that needs to be sent. Never null. This must be serialized via Command.writeTo(Channel, ObjectOutputStream)
last - Informational flag that indicates that this is the last call of the CommandTransport.write(Command, boolean).
Throws:
java.io.IOException


Copyright © 2013. All Rights Reserved.