Package org.apache.avro.ipc
Class Transceiver
java.lang.Object
org.apache.avro.ipc.Transceiver
- All Implemented Interfaces:
Closeable,AutoCloseable
- Direct Known Subclasses:
DatagramTransceiver,HttpTransceiver,LocalTransceiver,SaslSocketTransceiver,SocketTransceiver
Base transport class used by
Requestor.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()org.apache.avro.ProtocolReturns the protocol passed tosetRemote(Protocol).abstract StringbooleanTrue if a handshake has been completed for this connection.voidAcquires an exclusive lock on the transceiver's channel.abstract List<ByteBuffer> Called by the default definition oftransceive(List).voidsetRemote(org.apache.avro.Protocol protocol) Called with the remote protocol when a handshake has been completed.transceive(List<ByteBuffer> request) Called byRequestor.request(String,Object)for two-way messages.voidtransceive(List<ByteBuffer> request, Callback<List<ByteBuffer>> callback) Called byRequestor.request(String,Object,Callback)for two-way messages using callbacks.voidReleases the lock on the transceiver's channel if held by the calling thread.abstract voidwriteBuffers(List<ByteBuffer> buffers) Called byRequestor.request(String,Object)for one-way messages.
-
Constructor Details
-
Transceiver
public Transceiver()
-
-
Method Details
-
getRemoteName
- Throws:
IOException
-
lockChannel
public void lockChannel()Acquires an exclusive lock on the transceiver's channel. -
unlockChannel
public void unlockChannel()Releases the lock on the transceiver's channel if held by the calling thread. -
transceive
Called byRequestor.request(String,Object)for two-way messages. By default callswriteBuffers(List)followed byreadBuffers().- Throws:
IOException
-
transceive
public void transceive(List<ByteBuffer> request, Callback<List<ByteBuffer>> callback) throws IOException Called byRequestor.request(String,Object,Callback)for two-way messages using callbacks.- Throws:
IOException
-
readBuffers
Called by the default definition oftransceive(List).- Throws:
IOException
-
writeBuffers
Called byRequestor.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(org.apache.avro.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 org.apache.avro.Protocol getRemote()Returns the protocol passed tosetRemote(Protocol). Throws IllegalStateException by default. -
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-