@Override public ServerDescription getServerDescription() { return wrapped.getServerDescription(); }
@Override public List<BatchCursor<T>> apply(final BsonDocument result, final ServerAddress serverAddress) { List<BatchCursor<T>> cursors = new ArrayList<BatchCursor<T>>(); for (BsonValue cursorValue : getCursorDocuments(result)) { cursors.add(new QueryBatchCursor<T>(createQueryResult(getCursorDocument(cursorValue.asDocument()), source.getServerDescription().getAddress()), 0, getBatchSize(), decoder, source)); } return cursors; } };
static <T> BatchCursor<T> cursorDocumentToBatchCursor(final BsonDocument cursorDocument, final Decoder<T> decoder, final ConnectionSource source, final int batchSize) { return new QueryBatchCursor<T>(OperationHelper.<T>cursorDocumentToQueryResult(cursorDocument, source.getServerDescription().getAddress()), 0, batchSize, decoder, source); }
private void initFromCommandResult(final BsonDocument getMoreCommandResultDocument) { QueryResult<T> queryResult = getMoreCursorDocumentToQueryResult(getMoreCommandResultDocument.getDocument("cursor"), connectionSource.getServerDescription().getAddress()); initFromQueryResult(queryResult); }
static <D, T> T executeWrappedCommandProtocol(final WriteBinding binding, final String database, final BsonDocument command, final FieldNameValidator fieldNameValidator, final Decoder<D> decoder, final CommandTransformer<D, T> transformer) { ConnectionSource source = binding.getWriteConnectionSource(); try { return transformer.apply(executeWrappedCommandProtocol(database, command, fieldNameValidator, decoder, source, primary()), source.getServerDescription().getAddress()); } finally { source.release(); } }
static <D, T> T executeWrappedCommandProtocol(final ReadBinding binding, final String database, final BsonDocument command, final Decoder<D> decoder, final CommandTransformer<D, T> transformer) { ConnectionSource source = binding.getReadConnectionSource(); try { return transformer.apply(executeWrappedCommandProtocol(database, command, decoder, source, binding.getReadPreference()), source.getServerDescription().getAddress()); } finally { source.release(); } }
@Override public BulkWriteResult call(final ConnectionSource connectionSource, final Connection connection) { validateWriteRequestsAndReleaseConnectionIfError(connection); if (getWriteConcern().isAcknowledged() || serverIsAtLeastVersionThreeDotSix(connection.getDescription())) { BulkWriteBatch bulkWriteBatch = BulkWriteBatch.createBulkWriteBatch(namespace, connectionSource.getServerDescription(), connection.getDescription(), ordered, writeConcern, bypassDocumentValidation, retryWrites, writeRequests, binding.getSessionContext()); return executeBulkWriteBatch(binding, connection, bulkWriteBatch); } else { return executeLegacyBatches(connection); } } });
@Override public BulkWriteResult call(final ConnectionSource source, final Connection connection) { if (!isRetryableWrite(retryWrites, writeConcern, source.getServerDescription(), connection.getDescription(), binding.getSessionContext())) { return checkMongoWriteConcernWithResponseException(connection); } else { try { retryBatch.addResult(executeCommand(connection, retryBatch, binding)); } catch (Throwable t) { return checkMongoWriteConcernWithResponseException(connection); } return executeBulkWriteBatch(binding, connection, retryBatch.getNextBatch()); } }
MongoException exception; try { command = commandCreator.create(source.getServerDescription(), connection.getDescription()); return transformer.apply(connection.command(database, command, fieldNameValidator, readPreference, commandResultDecoder, binding.getSessionContext()), connection.getDescription().getServerAddress());
@Override public BatchCursor<T> call(final ConnectionSource source, final Connection connection) { if (serverIsAtLeastVersionThreeDotZero(connection.getDescription())) { try { return executeWrappedCommandProtocol(binding, databaseName, getCommand(), createCommandDecoder(), connection, commandTransformer(source)); } catch (MongoCommandException e) { return rethrowIfNotNamespaceError(e, createEmptyBatchCursor(createNamespace(), decoder, source.getServerDescription().getAddress(), batchSize)); } } else { return new ProjectingBatchCursor(new QueryBatchCursor<BsonDocument>(connection.query(getNamespace(), asQueryDocument(connection.getDescription(), binding.getReadPreference()), null, 0, 0, batchSize, binding.getReadPreference().isSlaveOk(), false, false, false, false, false, new BsonDocumentCodec()), 0, batchSize, new BsonDocumentCodec(), source)); } } });
@Override public ServerDescription getServerDescription() { return wrapped.getServerDescription(); }
@Override public ServerDescription getServerDescription() { return wrapped.getServerDescription(); }
@Override public List<BatchCursor<T>> apply(final BsonDocument result, final ServerAddress serverAddress) { List<BatchCursor<T>> cursors = new ArrayList<BatchCursor<T>>(); for (BsonValue cursorValue : getCursorDocuments(result)) { cursors.add(new QueryBatchCursor<T>(createQueryResult(getCursorDocument(cursorValue.asDocument()), source.getServerDescription().getAddress()), 0, getBatchSize(), decoder, source)); } return cursors; } };
static <T> BatchCursor<T> cursorDocumentToBatchCursor(final BsonDocument cursorDocument, final Decoder<T> decoder, final ConnectionSource source, final int batchSize) { return new QueryBatchCursor<T>(OperationHelper.<T>cursorDocumentToQueryResult(cursorDocument, source.getServerDescription().getAddress()), 0, batchSize, decoder, source); }
private void initFromCommandResult(final BsonDocument getMoreCommandResultDocument) { QueryResult<T> queryResult = getMoreCursorDocumentToQueryResult(getMoreCommandResultDocument.getDocument("cursor"), connectionSource.getServerDescription().getAddress()); initFromQueryResult(queryResult); }
static <D, T> T executeWrappedCommandProtocol(final WriteBinding binding, final String database, final BsonDocument command, final FieldNameValidator fieldNameValidator, final Decoder<D> decoder, final CommandTransformer<D, T> transformer) { ConnectionSource source = binding.getWriteConnectionSource(); try { return transformer.apply(executeWrappedCommandProtocol(database, command, fieldNameValidator, decoder, source, primary()), source.getServerDescription().getAddress()); } finally { source.release(); } }
static <D, T> T executeWrappedCommandProtocol(final ReadBinding binding, final String database, final BsonDocument command, final Decoder<D> decoder, final CommandTransformer<D, T> transformer) { ConnectionSource source = binding.getReadConnectionSource(); try { return transformer.apply(executeWrappedCommandProtocol(database, command, decoder, source, binding.getReadPreference()), source.getServerDescription().getAddress()); } finally { source.release(); } }
@Override public BulkWriteResult call(final ConnectionSource connectionSource, final Connection connection) { validateWriteRequestsAndReleaseConnectionIfError(connection); if (getWriteConcern().isAcknowledged() || serverIsAtLeastVersionThreeDotSix(connection.getDescription())) { BulkWriteBatch bulkWriteBatch = BulkWriteBatch.createBulkWriteBatch(namespace, connectionSource.getServerDescription(), connection.getDescription(), ordered, writeConcern, bypassDocumentValidation, retryWrites, writeRequests, binding.getSessionContext()); return executeBulkWriteBatch(binding, connection, bulkWriteBatch); } else { return executeLegacyBatches(connection); } } });
@Override public BulkWriteResult call(final ConnectionSource source, final Connection connection) { if (!isRetryableWrite(retryWrites, writeConcern, source.getServerDescription(), connection.getDescription(), binding.getSessionContext())) { return checkMongoWriteConcernWithResponseException(connection); } else { try { retryBatch.addResult(executeCommand(connection, retryBatch, binding)); } catch (Throwable t) { return checkMongoWriteConcernWithResponseException(connection); } return executeBulkWriteBatch(binding, connection, retryBatch.getNextBatch()); } }
@Override public BatchCursor<T> call(final ConnectionSource source, final Connection connection) { if (serverIsAtLeastVersionThreeDotZero(connection.getDescription())) { try { return executeWrappedCommandProtocol(binding, databaseName, getCommand(), createCommandDecoder(), connection, commandTransformer(source)); } catch (MongoCommandException e) { return rethrowIfNotNamespaceError(e, createEmptyBatchCursor(createNamespace(), decoder, source.getServerDescription().getAddress(), batchSize)); } } else { return new ProjectingBatchCursor(new QueryBatchCursor<BsonDocument>(connection.query(getNamespace(), asQueryDocument(connection.getDescription(), binding.getReadPreference()), null, 0, 0, batchSize, binding.getReadPreference().isSlaveOk(), false, false, false, false, false, new BsonDocumentCodec()), 0, batchSize, new BsonDocumentCodec(), source)); } } });