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
,NettyTransceiver
,SaslSocketTransceiver
,SocketTransceiver
Base transport class used by
Requestor
.-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Returns the protocol passed tosetRemote(Protocol)
.abstract String
boolean
True if a handshake has been completed for this connection.void
Acquires an exclusive lock on the transceiver's channel.abstract List
<ByteBuffer> Called by the default definition oftransceive(List)
.void
Called with the remote protocol when a handshake has been completed.transceive
(List<ByteBuffer> request) Called byRequestor.request(String,Object)
for two-way messages.void
transceive
(List<ByteBuffer> request, Callback<List<ByteBuffer>> callback) Called byRequestor.request(String,Object,Callback)
for two-way messages using callbacks.void
Releases the lock on the transceiver's channel if held by the calling thread.abstract void
writeBuffers
(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
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
Returns the protocol passed tosetRemote(Protocol)
. Throws IllegalStateException by default. -
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
-