use of com.mongodb.internal.binding.ConnectionSource in project mongo-java-driver by mongodb.
the class ClientSessionBinding method getPinnedConnectionSource.
private ConnectionSource getPinnedConnectionSource(final boolean isRead) {
TransactionContext<Connection> transactionContext = TransactionContext.get(session);
ConnectionSource source;
if (transactionContext == null) {
source = isRead ? wrapped.getReadConnectionSource() : wrapped.getWriteConnectionSource();
transactionContext = new TransactionContext<>(wrapped.getCluster().getDescription().getType());
session.setTransactionContext(source.getServerDescription().getAddress(), transactionContext);
// The session is responsible for retaining a reference to the context
transactionContext.release();
} else {
source = wrapped.getConnectionSource(session.getPinnedServerAddress());
}
return source;
}
Aggregations