/** * <p>createAsyncExecutor.</p> * * @return a {@link com.google.cloud.bigtable.grpc.async.AsyncExecutor} object. */ public AsyncExecutor createAsyncExecutor() { return new AsyncExecutor(throttlingDataClient); }
/** * Performs a {@link com.google.cloud.bigtable.grpc.BigtableDataClient#mutateRowAsync(MutateRowRequest)} on the * {@link com.google.bigtable.v2.MutateRowRequest}. This method may block if * {@link OperationAccountant#registerOperation(ListenableFuture)} blocks. * * @param request The {@link com.google.bigtable.v2.MutateRowRequest} to send. * @return a {@link com.google.common.util.concurrent.ListenableFuture} which can be listened to for completion events. * @throws java.lang.InterruptedException if any. */ public ListenableFuture<MutateRowResponse> mutateRowAsync(MutateRowRequest request) throws InterruptedException { return call(MUTATE_ROW_ASYNC, request); }
public void flush() throws IOException { // If there is a bulk mutation in progress, then send it. if (bulkMutation != null) { try { bulkMutation.flush(); } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new IOException("flush() was interrupted", e); } } asyncExecutor.flush(); }
private ListenableFuture<?> issueAsyncRequest(BulkOperation bulkOperation, Row row) { try { if (row instanceof Get) { return bulkOperation.bulkRead.add(requestAdapter.adapt((Get) row)); } else if (row instanceof Put) { return bulkOperation.bulkMutation.add(requestAdapter.adaptEntry((Put) row)); } else if (row instanceof Delete) { return bulkOperation.bulkMutation.add(requestAdapter.adaptEntry((Delete) row)); } else if (row instanceof Append) { return asyncExecutor.readModifyWriteRowAsync(requestAdapter.adapt((Append) row)); } else if (row instanceof Increment) { return asyncExecutor.readModifyWriteRowAsync(requestAdapter.adapt((Increment) row)); } else if (row instanceof RowMutations) { return bulkOperation.bulkMutation.add(requestAdapter.adaptEntry((RowMutations) row)); } } catch (InterruptedException e) { Thread.currentThread().interrupt(); return Futures.immediateFailedFuture(new IOException("Could not process the batch due to interrupt", e)); } catch (Throwable e) { return Futures.immediateFailedFuture(new IOException("Could not process the batch", e)); } LOG.error("Encountered unknown action type %s", row.getClass()); return Futures.immediateFailedFuture( new IllegalArgumentException("Encountered unknown action type: " + row.getClass())); }
/** * <p>hasInflightRequests.</p> * * @return a boolean. */ public boolean hasInflightRequests() { return this.asyncExecutor.hasInflightRequests() || (bulkMutation != null && !bulkMutation.isFlushed()); } }
public void flush() throws IOException { // If there is a bulk mutation in progress, then send it. if (bulkMutation != null) { try { bulkMutation.flush(); } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new IOException("flush() was interrupted", e); } } asyncExecutor.flush(); }
future = bulkMutation.add(adapter.adaptEntry((Delete) mutation)); } else if (mutation instanceof Increment) { future = asyncExecutor.readModifyWriteRowAsync(adapter.adapt((Increment) mutation)); } else if (mutation instanceof Append) { future = asyncExecutor.readModifyWriteRowAsync(adapter.adapt((Append) mutation)); } else { future = Futures.immediateFailedFuture(new IllegalArgumentException(
/** * <p>hasInflightRequests.</p> * * @return a boolean. */ public boolean hasInflightRequests() { return this.asyncExecutor.hasInflightRequests() || (bulkMutation != null && !bulkMutation.isFlushed()); } }
/** * Performs a {@link com.google.cloud.bigtable.grpc.BigtableDataClient#checkAndMutateRowAsync(CheckAndMutateRowRequest)} on the * {@link com.google.bigtable.v2.CheckAndMutateRowRequest}. This method may block if * {@link OperationAccountant#registerOperation(ListenableFuture)} blocks. * * @param request The {@link com.google.bigtable.v2.CheckAndMutateRowRequest} to send. * @return a {@link com.google.common.util.concurrent.ListenableFuture} which can be listened to for completion events. * @throws java.lang.InterruptedException if any. */ public ListenableFuture<CheckAndMutateRowResponse> checkAndMutateRowAsync( CheckAndMutateRowRequest request) throws InterruptedException { return call(CHECK_AND_MUTATE_ASYNC, request); }
public void close() throws IOException { closedWriteLock.lock(); try { flush(); asyncExecutor.flush(); closed = true; } finally { closedWriteLock.unlock(); } }
private ListenableFuture<?> issueAsyncRequest(BulkOperation bulkOperation, Row row) { try { if (row instanceof Get) { return bulkOperation.bulkRead.add(requestAdapter.adapt((Get) row)); } else if (row instanceof Put) { return bulkOperation.bulkMutation.add(requestAdapter.adaptEntry((Put) row)); } else if (row instanceof Delete) { return bulkOperation.bulkMutation.add(requestAdapter.adaptEntry((Delete) row)); } else if (row instanceof Append) { return asyncExecutor.readModifyWriteRowAsync(requestAdapter.adapt((Append) row)); } else if (row instanceof Increment) { return asyncExecutor.readModifyWriteRowAsync(requestAdapter.adapt((Increment) row)); } else if (row instanceof RowMutations) { return bulkOperation.bulkMutation.add(requestAdapter.adaptEntry((RowMutations) row)); } } catch (InterruptedException e) { Thread.currentThread().interrupt(); return Futures.immediateFailedFuture(new IOException("Could not process the batch due to interrupt", e)); } catch (Throwable e) { return Futures.immediateFailedFuture(new IOException("Could not process the batch", e)); } LOG.error("Encountered unknown action type %s", row.getClass()); return Futures.immediateFailedFuture( new IllegalArgumentException("Encountered unknown action type: " + row.getClass())); }
/** * Performs a {@link com.google.cloud.bigtable.grpc.BigtableDataClient#mutateRowsAsync(MutateRowsRequest)} on the * {@link com.google.bigtable.v2.MutateRowsRequest}. This method may block if * {@link OperationAccountant#registerOperation(ListenableFuture)} blocks. * * @param request The {@link com.google.bigtable.v2.MutateRowRequest} to send. * @return a {@link com.google.common.util.concurrent.ListenableFuture} which can be listened to for completion events. * @throws java.lang.InterruptedException if any. */ public ListenableFuture<List<MutateRowsResponse>> mutateRowsAsync(MutateRowsRequest request) throws InterruptedException { return call(MUTATE_ROWS_ASYNC, request); }
public void close() throws IOException { closedWriteLock.lock(); try { flush(); asyncExecutor.flush(); closed = true; } finally { closedWriteLock.unlock(); } }
future = bulkMutation.add(adapter.adaptEntry((Delete) mutation)); } else if (mutation instanceof Increment) { future = asyncExecutor.readModifyWriteRowAsync(adapter.adapt((Increment) mutation)); } else if (mutation instanceof Append) { future = asyncExecutor.readModifyWriteRowAsync(adapter.adapt((Append) mutation)); } else { future = Futures.immediateFailedFuture(new IllegalArgumentException(
/** * Performs a {@link com.google.cloud.bigtable.grpc.BigtableDataClient#readModifyWriteRow(ReadModifyWriteRowRequest)} on the * {@link com.google.bigtable.v2.ReadModifyWriteRowRequest}. This method may block if * {@link OperationAccountant#registerOperation(ListenableFuture)} blocks. * * @param request The {@link com.google.bigtable.v2.ReadModifyWriteRowRequest} to send. * @return a {@link com.google.common.util.concurrent.ListenableFuture} which can be listened to for completion events. * @throws java.lang.InterruptedException if any. */ public ListenableFuture<ReadModifyWriteRowResponse> readModifyWriteRowAsync(ReadModifyWriteRowRequest request) throws InterruptedException { return call(READ_MODIFY_WRITE_ASYNC, request); }
/** * Performs a {@link com.google.cloud.bigtable.grpc.BigtableDataClient#readRowsAsync(ReadRowsRequest)} on the * {@link com.google.bigtable.v2.ReadRowsRequest}. This method may block if * {@link OperationAccountant#registerOperation(ListenableFuture)} blocks. * * @param request The {@link com.google.bigtable.v2.ReadRowsRequest} to send. * @return a {@link com.google.common.util.concurrent.ListenableFuture} which can be listened to for completion events. * @throws java.lang.InterruptedException if any. */ public ListenableFuture<List<Row>> readRowsAsync(ReadRowsRequest request) throws InterruptedException { return call(READ_ROWS_ASYNC, request); }
/** * Performs a {@link com.google.cloud.bigtable.grpc.BigtableDataClient#readRowsAsync(ReadRowsRequest)} on the * {@link com.google.bigtable.v2.ReadRowsRequest}. This method may block if * {@link OperationAccountant#registerOperation(ListenableFuture)} blocks. * * @param request The {@link com.google.bigtable.v2.ReadRowsRequest} to send. * @return a {@link com.google.common.util.concurrent.ListenableFuture} which can be listened to for completion events. * @throws java.lang.InterruptedException if any. */ public ListenableFuture<List<FlatRow>> readFlatRowsAsync(ReadRowsRequest request) throws InterruptedException { return call(READ_FLAT_ROWS_ASYNC, request); }