Search in sources :

Example 1 with AsyncCallableWithConnection

use of com.mongodb.operation.OperationHelper.AsyncCallableWithConnection in project mongo-java-driver by mongodb.

the class MixedBulkWriteOperation method executeAsync.

@Override
public void executeAsync(final AsyncWriteBinding binding, final SingleResultCallback<BulkWriteResult> callback) {
    withConnection(binding, new AsyncCallableWithConnection() {

        @Override
        public void call(final AsyncConnection connection, final Throwable t) {
            final SingleResultCallback<BulkWriteResult> errHandlingCallback = errorHandlingCallback(callback, LOGGER);
            if (t != null) {
                errHandlingCallback.onResult(null, t);
            } else {
                validateWriteRequests(connection, bypassDocumentValidation, writeRequests, writeConcern, new AsyncCallableWithConnection() {

                    @Override
                    public void call(final AsyncConnection connection, final Throwable t) {
                        if (t != null) {
                            releasingCallback(errHandlingCallback, connection).onResult(null, t);
                        } else {
                            Iterator<Run> runs = getRunGenerator(connection.getDescription()).iterator();
                            executeRunsAsync(runs, connection, new BulkWriteBatchCombiner(connection.getDescription().getServerAddress(), ordered, writeConcern), errHandlingCallback);
                        }
                    }
                });
            }
        }
    });
}
Also used : AsyncConnection(com.mongodb.connection.AsyncConnection) SingleResultCallback(com.mongodb.async.SingleResultCallback) AsyncCallableWithConnection(com.mongodb.operation.OperationHelper.AsyncCallableWithConnection) BulkWriteBatchCombiner(com.mongodb.connection.BulkWriteBatchCombiner)

Aggregations

SingleResultCallback (com.mongodb.async.SingleResultCallback)1 AsyncConnection (com.mongodb.connection.AsyncConnection)1 BulkWriteBatchCombiner (com.mongodb.connection.BulkWriteBatchCombiner)1 AsyncCallableWithConnection (com.mongodb.operation.OperationHelper.AsyncCallableWithConnection)1