Interface SessionContext



  • public interface SessionContext
    The session context.
    Since:
    3.6
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      void advanceClusterTime​(org.bson.BsonDocument clusterTime)
      Advance the cluster time.
      void advanceOperationTime​(org.bson.BsonTimestamp operationTime)
      Advance the operation time.
      long advanceTransactionNumber​()
      Advance the transaction number.
      org.bson.BsonDocument getClusterTime​()
      Gets the current cluster time for this session context.
      org.bson.BsonTimestamp getOperationTime​()
      Gets the current operation time for this session context
      ReadConcern getReadConcern​()
      Gets the read concern to apply to operations on this binding.
      org.bson.BsonDocument getSessionId​()
      Gets the session identifier if this context has a session backing it.
      long getTransactionNumber​()
      Gets the current transaction number.
      boolean hasActiveTransaction​()
      Gets whether the session has an active transaction
      boolean hasSession​()
      Returns true if there is a true server session associated with this context.
      boolean isCausallyConsistent​()
      Gets whether this context is associated with a causally consistent session.
      boolean isImplicitSession​()
      Returns true if the session is implicit, and false if the application started the session explicity.
      boolean notifyMessageSent​()
      Notify the session context that a message has been sent.
      void setRecoveryToken​(org.bson.BsonDocument recoveryToken)
      Sets the recovery token in the session.
      void unpinServerAddress​()
      Unpin a mongos from a session.
    • Method Detail

      • hasSession

        boolean hasSession​()
        Returns true if there is a true server session associated with this context.
        Returns:
        true if there is a true server session associated with this context.
      • isImplicitSession

        boolean isImplicitSession​()
        Returns true if the session is implicit, and false if the application started the session explicity.
        Returns:
        true if the session is implicit
        Since:
        3.8
      • getSessionId

        org.bson.BsonDocument getSessionId​()
        Gets the session identifier if this context has a session backing it.
        Returns:
        the session id
      • isCausallyConsistent

        boolean isCausallyConsistent​()
        Gets whether this context is associated with a causally consistent session.
        Returns:
        true ift his context is associated with a causally consistent session
      • getTransactionNumber

        long getTransactionNumber​()
        Gets the current transaction number.
        Returns:
        the current transaction number
        Since:
        3.8
      • advanceTransactionNumber

        long advanceTransactionNumber​()
        Advance the transaction number.
        Returns:
        the next transaction number for the session
      • notifyMessageSent

        boolean notifyMessageSent​()
        Notify the session context that a message has been sent.
        Returns:
        true if this is the first message sent, false otherwise
        Since:
        3.8
      • getOperationTime

        org.bson.BsonTimestamp getOperationTime​()
        Gets the current operation time for this session context
        Returns:
        the current operation time, which may be null
      • advanceOperationTime

        void advanceOperationTime​(org.bson.BsonTimestamp operationTime)
        Advance the operation time. If the current operation time is greater than the given operation time, this method has no effect.
        Parameters:
        operationTime - the new operation time time
      • getClusterTime

        org.bson.BsonDocument getClusterTime​()
        Gets the current cluster time for this session context.
        Returns:
        the cluster time, which may be null
      • advanceClusterTime

        void advanceClusterTime​(org.bson.BsonDocument clusterTime)
        Advance the cluster time. If the current cluster time is greater than the given cluster time, this method has no effect.
        Parameters:
        clusterTime - the new cluster time
      • hasActiveTransaction

        boolean hasActiveTransaction​()
        Gets whether the session has an active transaction
        Returns:
        true if the session has an active transaction
        Since:
        3.8
        Since server release
        4.0
      • getReadConcern

        ReadConcern getReadConcern​()
        Gets the read concern to apply to operations on this binding.
        Returns:
        the read concern to apply to operations on this binding
        Since:
        3.8
      • setRecoveryToken

        void setRecoveryToken​(org.bson.BsonDocument recoveryToken)
        Sets the recovery token in the session.
        Parameters:
        recoveryToken - the recovery token
        Since:
        3.11
      • unpinServerAddress

        void unpinServerAddress​()
        Unpin a mongos from a session.
        Since:
        3.11