Interface ClientSession


public interface ClientSession
Session representing a connected external client to the cluster.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final long
    Return value to indicate egress to a session is mocked out by the cluster when in follower mode.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Close of this ContainerClientSession by sending the request to the consensus module.
    byte[]
    Cluster session encoded principal from when the session was authenticated.
    long
    id()
    Cluster session identity uniquely allocated when the session was opened.
    boolean
    Indicates that a request to close this session has been made.
    long
    Non-blocking publish by gathering buffer vectors into a message.
    long
    offer(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.
    int
    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.
  • Field Details

    • MOCKED_OFFER

      static final long MOCKED_OFFER
      Return 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 this ContainerClientSession by 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

      long offer(DirectBuffer buffer, int offset, int length)
      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 in Cluster.Role.LEADER, otherwise MOCKED_OFFER when a follower.
    • offer

      long offer(DirectBufferVector[] vectors)
      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

      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. Once the message has been written then 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();
               }
           }
       
      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 in Cluster.Role.LEADER, otherwise MOCKED_OFFER when a follower.
      Throws:
      IllegalArgumentException - if the length is greater than Publication.maxPayloadLength().
      See Also: