Package io.aeron.cluster.service
Interface ClientSession
public interface ClientSession
Session representing a connected external client to the cluster.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final longReturn value to indicate egress to a session is mocked out by the cluster when in follower mode. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Close of thisContainerClientSessionby sending the request to the consensus module.byte[]Cluster session encoded principal from when the session was authenticated.longid()Cluster session identity uniquely allocated when the session was opened.booleanIndicates that a request to close this session has been made.longoffer(DirectBufferVector[] vectors) Non-blocking publish by gathering buffer vectors into a message.longoffer(DirectBuffer buffer, int offset, int length) Non-blocking publish of a partial buffer containing a message to a cluster.The response channel for responding to the client.intThe response channel stream id for responding to the client.longtryClaim(int length, BufferClaim bufferClaim) Try to claim a range in the publication log into which a message can be written with zero copy semantics.
-
Field Details
-
MOCKED_OFFER
static final long MOCKED_OFFERReturn value to indicate egress to a session is mocked out by the cluster when in follower mode.- See Also:
-
-
Method Details
-
id
long id()Cluster session identity uniquely allocated when the session was opened.- Returns:
- the cluster session identity uniquely allocated when the session was opened.
-
responseStreamId
int responseStreamId()The response channel stream id for responding to the client.- Returns:
- response channel stream id for responding to the client.
-
responseChannel
String responseChannel()The response channel for responding to the client.- Returns:
- response channel for responding to the client.
-
encodedPrincipal
byte[] encodedPrincipal()Cluster session encoded principal from when the session was authenticated.- Returns:
- The encoded Principal passed. May be 0 length to indicate none present.
-
close
void close()Close of thisContainerClientSessionby sending the request to the consensus module.This method is idempotent.
-
isClosing
boolean isClosing()Indicates that a request to close this session has been made.- Returns:
- whether a request to close this session has been made.
-
offer
Non-blocking publish of a partial buffer containing a message to a cluster.- Parameters:
buffer- containing message.offset- offset in the buffer at which the encoded message begins.length- in bytes of the encoded message.- Returns:
- the same as
Publication.offer(DirectBuffer, int, int)when inCluster.Role.LEADER, otherwiseMOCKED_OFFERwhen a follower.
-
offer
Non-blocking publish by gathering buffer vectors into a message. The first vector will be replaced by the cluster egress header so must be left unused.- Parameters:
vectors- which make up the message.- Returns:
- the same as
Publication.offer(DirectBufferVector[]). - See Also:
-
tryClaim
Try to claim a range in the publication log into which a message can be written with zero copy semantics. Once the message has been written thenBufferClaim.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(); } }- Parameters:
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.- Returns:
- The new stream position, otherwise a negative error value as specified in
Publication.tryClaim(int, BufferClaim)when inCluster.Role.LEADER, otherwiseMOCKED_OFFERwhen a follower. - Throws:
IllegalArgumentException- if the length is greater thanPublication.maxPayloadLength().- See Also:
-