Package com.mongodb.session
Interface SessionContext
-
- All Known Implementing Classes:
ClientSessionContext
,ClusterClockAdvancingSessionContext
,NoOpSessionContext
,ReadConcernAwareNoOpSessionContext
public interface SessionContext
The session context.- Since:
- 3.6
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
advanceClusterTime(BsonDocument clusterTime)
Advance the cluster time.void
advanceOperationTime(BsonTimestamp operationTime)
Advance the operation time.long
advanceTransactionNumber()
Advance the transaction number.BsonDocument
getClusterTime()
Gets the current cluster time for this session context.BsonTimestamp
getOperationTime()
Gets the current operation time for this session contextReadConcern
getReadConcern()
Gets the read concern to apply to operations on this binding.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 transactionboolean
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.
-
-
-
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
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
BsonTimestamp getOperationTime()
Gets the current operation time for this session context- Returns:
- the current operation time, which may be null
-
advanceOperationTime
void advanceOperationTime(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
BsonDocument getClusterTime()
Gets the current cluster time for this session context.- Returns:
- the cluster time, which may be null
-
advanceClusterTime
void advanceClusterTime(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
-
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
-
-