class UsageTrackingInternalConnection extends java.lang.Object implements InternalConnection
Modifier and Type | Field and Description |
---|---|
private int |
generation |
private long |
lastUsedAt |
private static Logger |
LOGGER |
private long |
openedAt |
private InternalConnection |
wrapped |
Constructor and Description |
---|
UsageTrackingInternalConnection(InternalConnection wrapped,
int generation) |
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes the connection.
|
ByteBuf |
getBuffer(int size)
Gets a buffer with the givens capacity.
|
ConnectionDescription |
getDescription()
Gets the description of this connection.
|
(package private) int |
getGeneration()
Gets the generation of this connection.
|
(package private) long |
getLastUsedAt()
Returns the time at which this connection was last used, or
Long.MAX_VALUE if it has not yet been used. |
(package private) long |
getOpenedAt()
Returns the time at which this connection was opened, or
Long.MAX_VALUE if it has not yet been opened. |
boolean |
isClosed()
Returns the closed state of the connection
|
void |
open()
Opens the connection so its ready for use
|
void |
openAsync(SingleResultCallback<java.lang.Void> callback)
Opens the connection so its ready for use
|
boolean |
opened()
Returns if the connection has been opened
|
ResponseBuffers |
receiveMessage(int responseTo)
Receive a response to a sent message from the server.
|
void |
receiveMessageAsync(int responseTo,
SingleResultCallback<ResponseBuffers> callback)
Asynchronously receive a response to a sent message from the server.
|
<T> T |
sendAndReceive(CommandMessage message,
Decoder<T> decoder,
SessionContext sessionContext)
Send a command message to the server.
|
<T> void |
sendAndReceiveAsync(CommandMessage message,
Decoder<T> decoder,
SessionContext sessionContext,
SingleResultCallback<T> callback)
Send a command message to the server.
|
void |
sendMessage(java.util.List<ByteBuf> byteBuffers,
int lastRequestId)
Send a message to the server.
|
void |
sendMessageAsync(java.util.List<ByteBuf> byteBuffers,
int lastRequestId,
SingleResultCallback<java.lang.Void> callback)
Asynchronously send a message to the server.
|
private static final Logger LOGGER
private volatile long openedAt
private volatile long lastUsedAt
private final int generation
private final InternalConnection wrapped
UsageTrackingInternalConnection(InternalConnection wrapped, int generation)
public void open()
InternalConnection
open
in interface InternalConnection
public void openAsync(SingleResultCallback<java.lang.Void> callback)
InternalConnection
openAsync
in interface InternalConnection
callback
- the callback to be called once the connection has been openedpublic void close()
InternalConnection
close
in interface InternalConnection
public boolean opened()
InternalConnection
opened
in interface InternalConnection
public boolean isClosed()
InternalConnection
isClosed
in interface InternalConnection
public ByteBuf getBuffer(int size)
BufferProvider
getBuffer
in interface BufferProvider
size
- the size required for the bufferpublic void sendMessage(java.util.List<ByteBuf> byteBuffers, int lastRequestId)
InternalConnection
sendMessage
in interface InternalConnection
byteBuffers
- the list of byte buffers to send.lastRequestId
- the request id of the last message in byteBufferspublic <T> T sendAndReceive(CommandMessage message, Decoder<T> decoder, SessionContext sessionContext)
InternalConnection
sendAndReceive
in interface InternalConnection
message
- the command message to sendsessionContext
- the session contextpublic <T> void sendAndReceiveAsync(CommandMessage message, Decoder<T> decoder, SessionContext sessionContext, SingleResultCallback<T> callback)
InternalConnection
sendAndReceiveAsync
in interface InternalConnection
message
- the command message to sendsessionContext
- the session contextcallback
- the callbackpublic ResponseBuffers receiveMessage(int responseTo)
InternalConnection
receiveMessage
in interface InternalConnection
responseTo
- the request id that this message is a response topublic void sendMessageAsync(java.util.List<ByteBuf> byteBuffers, int lastRequestId, SingleResultCallback<java.lang.Void> callback)
InternalConnection
sendMessageAsync
in interface InternalConnection
byteBuffers
- the list of byte buffers to sendlastRequestId
- the request id of the last message in byteBufferscallback
- the callback to invoke on completionpublic void receiveMessageAsync(int responseTo, SingleResultCallback<ResponseBuffers> callback)
InternalConnection
receiveMessageAsync
in interface InternalConnection
responseTo
- the request id that this message is a response tocallback
- the callback to invoke on completionpublic ConnectionDescription getDescription()
InternalConnection
getDescription
in interface InternalConnection
int getGeneration()
long getOpenedAt()
Long.MAX_VALUE
if it has not yet been opened.long getLastUsedAt()
Long.MAX_VALUE
if it has not yet been used.