/** * Issue a single RPC recording the result into {@code results[index]} and if not-null, invoking * the supplied callback. * @param bulkOperation An object that encapsulates a set of Mutations and Reads that happen via a * bulk API. * @param row The action to perform * @param callback The callback to invoke when the RPC completes and we have results * @param results An array of results, into which we should store the result of the operation * @param index The into into the array of results where we should store our result * @param <R> The action type * @param <T> The type of the callback. * @return A ListenableFuture that will have the result when the RPC completes. */ private <R extends Row, T> ListenableFuture<Result> issueAsyncRowRequest( BulkOperation bulkOperation, Row row, Batch.Callback<T> callback, Object[] results, int index) { LOG.trace("issueRowRequest(BulkOperation, Row, Batch.Callback, Object[], index"); SettableFuture<Result> resultFuture = SettableFuture.create(); RpcResultFutureCallback<T> futureCallback = new RpcResultFutureCallback<T>(row, callback, index, results, resultFuture); results[index] = null; Futures.addCallback(issueAsyncRequest(bulkOperation, row), futureCallback, MoreExecutors.directExecutor()); return resultFuture; }
/** * Issue a single RPC recording the result into {@code results[index]} and if not-null, invoking * the supplied callback. * @param bulkOperation An object that encapsulates a set of Mutations and Reads that happen via a * bulk API. * @param row The action to perform * @param callback The callback to invoke when the RPC completes and we have results * @param results An array of results, into which we should store the result of the operation * @param index The into into the array of results where we should store our result * @param <R> The action type * @param <T> The type of the callback. * @return A ListenableFuture that will have the result when the RPC completes. */ private <R extends Row, T> ListenableFuture<Result> issueAsyncRowRequest( BulkOperation bulkOperation, Row row, Batch.Callback<T> callback, Object[] results, int index) { LOG.trace("issueRowRequest(BulkOperation, Row, Batch.Callback, Object[], index"); SettableFuture<Result> resultFuture = SettableFuture.create(); RpcResultFutureCallback<T> futureCallback = new RpcResultFutureCallback<T>(row, callback, index, results, resultFuture); results[index] = null; Futures.addCallback(issueAsyncRequest(bulkOperation, row), futureCallback, MoreExecutors.directExecutor()); return resultFuture; }