Package com.mongodb.session
Interface SessionContext
-
public interface SessionContextThe session context.- Since:
- 3.6
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidadvanceClusterTime(org.bson.BsonDocument clusterTime)Advance the cluster time.voidadvanceOperationTime(org.bson.BsonTimestamp operationTime)Advance the operation time.longadvanceTransactionNumber()Advance the transaction number.org.bson.BsonDocumentgetClusterTime()Gets the current cluster time for this session context.org.bson.BsonTimestampgetOperationTime()Gets the current operation time for this session contextReadConcerngetReadConcern()Gets the read concern to apply to operations on this binding.org.bson.BsonDocumentgetSessionId()Gets the session identifier if this context has a session backing it.longgetTransactionNumber()Gets the current transaction number.booleanhasActiveTransaction()Gets whether the session has an active transactionbooleanhasSession()Returns true if there is a true server session associated with this context.booleanisCausallyConsistent()Gets whether this context is associated with a causally consistent session.booleanisImplicitSession()Returns true if the session is implicit, and false if the application started the session explicity.booleannotifyMessageSent()Notify the session context that a message has been sent.voidsetRecoveryToken(org.bson.BsonDocument recoveryToken)Sets the recovery token in the session.voidunpinServerAddress()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
-
-