public interface ClientSession
Modifier and Type | Field and Description |
---|---|
static long |
MOCKED_OFFER
Return value to indicate egress to a session is mocked out by the cluster when in follower mode.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Close of this
ContainerClientSession by sending the request to the consensus module. |
byte[] |
encodedPrincipal()
Cluster session encoded principal from when the session was authenticated.
|
long |
id()
Cluster session identity uniquely allocated when the session was opened.
|
boolean |
isClosing()
Indicates that a request to close this session has been made.
|
long |
offer(DirectBuffer buffer,
int offset,
int length)
Non-blocking publish of a partial buffer containing a message to a cluster.
|
long |
offer(DirectBufferVector[] vectors)
Non-blocking publish by gathering buffer vectors into a message.
|
String |
responseChannel()
The response channel for responding to the client.
|
int |
responseStreamId()
The response channel stream id for responding to the client.
|
long |
tryClaim(int length,
BufferClaim bufferClaim)
Try to claim a range in the publication log into which a message can be written with zero copy semantics.
|
static final long MOCKED_OFFER
long id()
int responseStreamId()
String responseChannel()
byte[] encodedPrincipal()
void close()
ContainerClientSession
by sending the request to the consensus module.
This method is idempotent.
boolean isClosing()
long offer(DirectBuffer buffer, int offset, int length)
buffer
- containing message.offset
- offset in the buffer at which the encoded message begins.length
- in bytes of the encoded message.Publication.offer(DirectBuffer, int, int)
when in Cluster.Role.LEADER
,
otherwise MOCKED_OFFER
when a follower.long offer(DirectBufferVector[] vectors)
vectors
- which make up the message.Publication.offer(DirectBufferVector[])
.when in {@link Cluster.Role#LEADER},
otherwise {@link #MOCKED_OFFER} when a follower.
long tryClaim(int length, BufferClaim bufferClaim)
BufferClaim.commit()
should be called thus making it available.
On successful claim, the Cluster egress header will be written to the start of the claimed buffer section.
Clients MUST write into the claimed buffer region at offset + AeronCluster.SESSION_HEADER_LENGTH
.
final DirectBuffer srcBuffer = acquireMessage();
if (session.tryClaim(length, bufferClaim) > 0L)
{
try
{
final MutableDirectBuffer buffer = bufferClaim.buffer();
final int offset = bufferClaim.offset();
// ensure that data is written at the correct offset
buffer.putBytes(offset + AeronCluster.SESSION_HEADER_LENGTH, srcBuffer, 0, length);
}
finally
{
bufferClaim.commit();
}
}
length
- of the range to claim in bytes. The additional bytes for the session header will be added.bufferClaim
- to be populated if the claim succeeds.Publication.tryClaim(int, BufferClaim)
when in Cluster.Role.LEADER
,
otherwise MOCKED_OFFER
when a follower.IllegalArgumentException
- if the length is greater than Publication.maxPayloadLength()
.Publication.tryClaim(int, BufferClaim)
,
BufferClaim.commit()
,
BufferClaim.abort()
Copyright © 2014-2023 Real Logic Limited. All Rights Reserved.