@Override public ReadConcern getReadConcern() { return wrapped.getReadConcern(); } }
@Override public ReadConcern getReadConcern() { if (clientSession.hasActiveTransaction()) { return clientSession.getTransactionOptions().getReadConcern(); } else { return wrapped.getSessionContext().getReadConcern(); } } }
@Override public BatchCursor<T> call(final ConnectionSource source, final Connection connection) { validateReadConcernAndCollation(connection, binding.getSessionContext().getReadConcern(), collation); return executeWrappedCommandProtocol(binding, namespace.getDatabaseName(), getCommand(binding.getSessionContext()), createCommandDecoder(), connection, transformer(source, connection)); } });
@Override public Long call(final Connection connection) { validateReadConcernAndCollation(connection, binding.getSessionContext().getReadConcern(), collation); return executeWrappedCommandProtocol(binding, namespace.getDatabaseName(), getCommand(binding.getSessionContext()), DECODER, connection, transformer()); } });
@Override public MapReduceBatchCursor<T> call(final ConnectionSource source, final Connection connection) { validateReadConcernAndCollation(connection, binding.getSessionContext().getReadConcern(), collation); return executeWrappedCommandProtocol(binding, namespace.getDatabaseName(), getCommand(binding.getSessionContext()), CommandResultDocumentCodec.create(decoder, "results"), connection, transformer(source, connection)); } });
@Override public List<BatchCursor<T>> call(final ConnectionSource source, final Connection connection) { validateReadConcern(connection, binding.getSessionContext().getReadConcern()); return executeWrappedCommandProtocol(binding, namespace.getDatabaseName(), getCommand(binding.getSessionContext()), CommandResultDocumentCodec.create(decoder, "firstBatch"), connection, transformer(source)); } });
@Override public void call(final AsyncConnection connection, final Throwable t) { SingleResultCallback<Long> errHandlingCallback = errorHandlingCallback(callback, LOGGER); if (t != null) { errHandlingCallback.onResult(null, t); } else { final SingleResultCallback<Long> wrappedCallback = releasingCallback(errHandlingCallback, connection); validateReadConcernAndCollation(connection, binding.getSessionContext().getReadConcern(), collation, new AsyncCallableWithConnection() { @Override public void call(final AsyncConnection connection, final Throwable t) { if (t != null) { wrappedCallback.onResult(null, t); } else { executeWrappedCommandProtocolAsync(binding, namespace.getDatabaseName(), getCommand(binding.getSessionContext()), DECODER, connection, transformer(), wrappedCallback); } } }); } } });
@Override public BatchCursor<T> call(final ConnectionSource source, final Connection connection) { validateReadConcernAndCollation(connection, binding.getSessionContext().getReadConcern(), collation); return executeWrappedCommandProtocol(binding, namespace.getDatabaseName(), getCommand(connection.getDescription(), binding.getSessionContext()), CommandResultDocumentCodec.create(decoder, FIELD_NAMES_WITH_RESULT), connection, transformer(source, connection)); } });
@Override public void call(final AsyncConnectionSource source, final AsyncConnection connection, final Throwable t) { SingleResultCallback<AsyncBatchCursor<T>> errHandlingCallback = errorHandlingCallback(callback, LOGGER); if (t != null) { errHandlingCallback.onResult(null, t); } else { final SingleResultCallback<AsyncBatchCursor<T>> wrappedCallback = releasingCallback( errHandlingCallback, source, connection); validateReadConcernAndCollation(source, connection, binding.getSessionContext().getReadConcern(), collation, new AsyncCallableWithConnectionAndSource() { @Override public void call(final AsyncConnectionSource source, final AsyncConnection connection, final Throwable t) { if (t != null) { wrappedCallback.onResult(null, t); } else { executeWrappedCommandProtocolAsync(binding, namespace.getDatabaseName(), getCommand(binding.getSessionContext()), createCommandDecoder(), connection, asyncTransformer(connection.getDescription()), wrappedCallback); } } }); } } });
@Override public void call(final AsyncConnection connection, final Throwable t) { SingleResultCallback<MapReduceAsyncBatchCursor<T>> errHandlingCallback = errorHandlingCallback(callback, LOGGER); if (t != null) { errHandlingCallback.onResult(null, t); } else { final SingleResultCallback<MapReduceAsyncBatchCursor<T>> wrappedCallback = releasingCallback( errHandlingCallback, connection); validateReadConcernAndCollation(connection, binding.getSessionContext().getReadConcern(), collation, new AsyncCallableWithConnection() { @Override public void call(final AsyncConnection connection, final Throwable t) { if (t != null) { wrappedCallback.onResult(null, t); } else { executeWrappedCommandProtocolAsync(binding, namespace.getDatabaseName(), getCommand(binding.getSessionContext()), CommandResultDocumentCodec.create(decoder, "results"), connection, asyncTransformer(connection), wrappedCallback); } } }); } } });
@Override public void call(final AsyncConnectionSource source, final AsyncConnection connection, final Throwable t) { SingleResultCallback<AsyncBatchCursor<T>> errHandlingCallback = errorHandlingCallback(callback, LOGGER); if (t != null) { errHandlingCallback.onResult(null, t); } else { final SingleResultCallback<AsyncBatchCursor<T>> wrappedCallback = releasingCallback(errHandlingCallback, source, connection); validateReadConcernAndCollation(source, connection, binding.getSessionContext().getReadConcern(), collation, new AsyncCallableWithConnectionAndSource() { @Override public void call(final AsyncConnectionSource source, final AsyncConnection connection, final Throwable t) { if (t != null) { wrappedCallback.onResult(null, t); } else { executeWrappedCommandProtocolAsync(binding, namespace.getDatabaseName(), getCommand(connection.getDescription(), binding.getSessionContext()), CommandResultDocumentCodec.create(decoder, FIELD_NAMES_WITH_RESULT), connection, asyncTransformer(source, connection), wrappedCallback); } } }); } } });
@Override public void call(final AsyncConnectionSource source, final AsyncConnection connection, final Throwable t) { SingleResultCallback<List<AsyncBatchCursor<T>>> errHandlingCallback = errorHandlingCallback(callback, LOGGER); if (t != null) { errHandlingCallback.onResult(null, t); } else { final SingleResultCallback<List<AsyncBatchCursor<T>>> wrappedCallback = releasingCallback( errHandlingCallback, source, connection); validateReadConcern(source, connection, binding.getSessionContext().getReadConcern(), new AsyncCallableWithConnectionAndSource() { @Override public void call(final AsyncConnectionSource source, final AsyncConnection connection, final Throwable t) { if (t != null) { wrappedCallback.onResult(null, t); } else { executeWrappedCommandProtocolAsync(binding, namespace.getDatabaseName(), getCommand(binding.getSessionContext()), CommandResultDocumentCodec.create(decoder, "firstBatch"), connection, asyncTransformer(source, connection), wrappedCallback); } } }); } } });
public static BsonDocument getReadConcernDocument(final SessionContext sessionContext) { notNull("sessionContext", sessionContext); BsonDocument readConcernDocument = new BsonDocument(); ReadConcernLevel level = sessionContext.getReadConcern().getLevel(); if (level != null) { readConcernDocument.append("level", new BsonString(level.getValue())); } if (shouldAddAfterClusterTime(sessionContext)) { readConcernDocument.append("afterClusterTime", sessionContext.getOperationTime()); } return readConcernDocument; }
final SingleResultCallback<AsyncBatchCursor<T>> wrappedCallback = releasingCallback(exceptionTransformingCallback(errHandlingCallback), source, connection); validateReadConcernAndCollation(source, connection, binding.getSessionContext().getReadConcern(), collation, new AsyncCallableWithConnectionAndSource() { @Override final SingleResultCallback<AsyncBatchCursor<T>> wrappedCallback = releasingCallback(errHandlingCallback, source, connection); validateReadConcernAndCollation(source, connection, binding.getSessionContext().getReadConcern(), collation, new AsyncCallableWithConnectionAndSource() { @Override
if (serverIsAtLeastVersionThreeDotTwo(connection.getDescription())) { try { validateReadConcernAndCollation(connection, binding.getSessionContext().getReadConcern(), collation); return executeWrappedCommandProtocol(binding, namespace.getDatabaseName(), wrapInExplainIfNecessary(getCommand(binding.getSessionContext())), validateReadConcernAndCollation(connection, binding.getSessionContext().getReadConcern(), collation); QueryResult<T> queryResult = connection.query(namespace, asDocument(connection.getDescription(), binding.getReadPreference()),
@Override public ReadConcern getReadConcern() { return wrapped.getReadConcern(); } }
@Override public ReadConcern getReadConcern() { if (clientSession.hasActiveTransaction()) { return clientSession.getTransactionOptions().getReadConcern(); } else { return wrapped.getSessionContext().getReadConcern(); } } }
@Override public MapReduceBatchCursor<T> call(final ConnectionSource source, final Connection connection) { validateReadConcernAndCollation(connection, binding.getSessionContext().getReadConcern(), collation); return executeWrappedCommandProtocol(binding, namespace.getDatabaseName(), getCommand(binding.getSessionContext()), CommandResultDocumentCodec.create(decoder, "results"), connection, transformer(source, connection)); } });
@Override public BatchCursor<T> call(final ConnectionSource source, final Connection connection) { validateReadConcernAndCollation(connection, binding.getSessionContext().getReadConcern(), collation); return executeWrappedCommandProtocol(binding, namespace.getDatabaseName(), getCommand(connection.getDescription(), binding.getSessionContext()), CommandResultDocumentCodec.create(decoder, FIELD_NAMES_WITH_RESULT), connection, transformer(source, connection)); } });
public static BsonDocument getReadConcernDocument(final SessionContext sessionContext) { notNull("sessionContext", sessionContext); BsonDocument readConcernDocument = new BsonDocument(); ReadConcernLevel level = sessionContext.getReadConcern().getLevel(); if (level != null) { readConcernDocument.append("level", new BsonString(level.getValue())); } if (shouldAddAfterClusterTime(sessionContext)) { readConcernDocument.append("afterClusterTime", sessionContext.getOperationTime()); } return readConcernDocument; }