org.apache.avro.ipc
Class Transceiver

java.lang.Object
  extended by org.apache.avro.ipc.Transceiver
All Implemented Interfaces:
Closeable
Direct Known Subclasses:
DatagramTransceiver, HttpTransceiver, LocalTransceiver, NettyTransceiver, SaslSocketTransceiver, SocketTransceiver

public abstract class Transceiver
extends Object
implements Closeable

Base transport class used by Requestor.


Constructor Summary
Transceiver()
           
 
Method Summary
 void close()
           
 Protocol getRemote()
          Returns the protocol passed to setRemote(Protocol).
abstract  String getRemoteName()
           
 boolean isConnected()
          True if a handshake has been completed for this connection.
abstract  List<ByteBuffer> readBuffers()
          Called by the default definition of transceive(List).
 void setRemote(Protocol protocol)
          Called with the remote protocol when a handshake has been completed.
 List<ByteBuffer> transceive(List<ByteBuffer> request)
          Called by Requestor.request(String,Object) for two-way messages.
abstract  void writeBuffers(List<ByteBuffer> buffers)
          Called by Requestor.request(String,Object) for one-way messages.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Transceiver

public Transceiver()
Method Detail

getRemoteName

public abstract String getRemoteName()

transceive

public List<ByteBuffer> transceive(List<ByteBuffer> request)
                            throws IOException
Called by Requestor.request(String,Object) for two-way messages. By default calls writeBuffers(List) followed by readBuffers().

Throws:
IOException

readBuffers

public abstract List<ByteBuffer> readBuffers()
                                      throws IOException
Called by the default definition of transceive(List).

Throws:
IOException

writeBuffers

public abstract void writeBuffers(List<ByteBuffer> buffers)
                           throws IOException
Called by Requestor.request(String,Object) for one-way messages.

Throws:
IOException

isConnected

public boolean isConnected()
True if a handshake has been completed for this connection. Used to determine whether a handshake need be completed prior to a one-way message. Requests and responses are always prefixed by handshakes, but one-way messages. If the first request sent over a connection is one-way, then a handshake-only response is returned. Subsequent one-way messages over the connection will have no response data sent. Returns false by default.


setRemote

public void setRemote(Protocol protocol)
Called with the remote protocol when a handshake has been completed. After this has been called and while a connection is maintained, isConnected() should return true and #getRemote() should return this protocol. Does nothing by default.


getRemote

public Protocol getRemote()
Returns the protocol passed to setRemote(Protocol). Throws IllegalStateException by default.


close

public void close()
           throws IOException
Specified by:
close in interface Closeable
Throws:
IOException


Copyright © 2010 The Apache Software Foundation