/** * <p>Constructor for BigtableBufferedMutator.</p> * * @param adapter Converts HBase objects to Bigtable protos * @param configuration For Additional configuration. TODO: move this to options * @param session a {@link com.google.cloud.bigtable.grpc.BigtableSession} to get {@link com.google.cloud.bigtable.config.BigtableOptions}, {@link com.google.cloud.bigtable.grpc.async.AsyncExecutor} * and {@link com.google.cloud.bigtable.grpc.async.BulkMutation} objects from * starting the async operations on the BigtableDataClient. */ public BigtableAsyncBufferedMutator( HBaseRequestAdapter adapter, Configuration configuration, BigtableSession session) { helper = new BigtableBufferedMutatorHelper(adapter, configuration, session); }
/** {@inheritDoc} */ @Override public Configuration getConfiguration() { return helper.getConfiguration(); }
/** {@inheritDoc} */ @Override public TableName getName() { return helper.getName(); }
/** {@inheritDoc} */ @Override public List<CompletableFuture<Void>> mutate(List<? extends Mutation> mutations) { Stream<CompletableFuture<Void>> stream = helper.mutate(mutations).stream() .map(lfuture -> FutureUtils.toCompletableFuture(lfuture).thenApply(r-> null)); return stream.collect(Collectors.toList()); }
/** * <p>hasInflightRequests.</p> * * @return a boolean. */ public boolean hasInflightRequests() { return helper.hasInflightRequests(); } }
/** {@inheritDoc} */ @Override public long getWriteBufferSize() { return helper.getWriteBufferSize(); }
/** {@inheritDoc} */ @Override public void flush() throws IOException { helper.flush(); handleExceptions(); }
public List<ListenableFuture<?>> mutate(List<? extends Mutation> mutations) { closedReadLock.lock(); try { List<ListenableFuture<?>> futures = new ArrayList<>(mutations.size()); for (Mutation mutation : mutations) { futures.add(offer(mutation)); } return futures; } finally { closedReadLock.unlock(); } }
/** {@inheritDoc} */ @Override public void flush() { helper.sendUnsent(); }
/** {@inheritDoc} */ @Override public void close() throws IOException { helper.close(); handleExceptions(); }
/** * {@inheritDoc} * * Being a Mutation. This method will block if either of the following are true: * 1) There are more than {@code maxInflightRpcs} RPCs in flight * 2) There are more than {@link #getWriteBufferSize()} bytes pending */ @Override public CompletableFuture<Void> mutate(final Mutation mutation) { return FutureUtils.toCompletableFuture(helper.mutate(mutation)).thenApply(r -> null); }
/** * <p>hasInflightRequests.</p> * * @return a boolean. */ public boolean hasInflightRequests() { return helper.hasInflightRequests(); }
/** {@inheritDoc} */ @Override public long getWriteBufferSize() { return helper.getWriteBufferSize(); }
public void close() throws IOException { closedWriteLock.lock(); try { flush(); asyncExecutor.flush(); closed = true; } finally { closedWriteLock.unlock(); } }
public List<ListenableFuture<?>> mutate(List<? extends Mutation> mutations) { closedReadLock.lock(); try { List<ListenableFuture<?>> futures = new ArrayList<>(mutations.size()); for (Mutation mutation : mutations) { futures.add(offer(mutation)); } return futures; } finally { closedReadLock.unlock(); } }
/** {@inheritDoc} */ @Override public void flush() { helper.sendUnsent(); }
/** {@inheritDoc} */ @Override public void close() throws IOException { helper.close(); handleExceptions(); }
/** {@inheritDoc} */ @Override public List<CompletableFuture<Void>> mutate(List<? extends Mutation> mutations) { Stream<CompletableFuture<Void>> stream = helper.mutate(mutations).stream() .map(lfuture -> FutureUtils.toCompletableFuture(lfuture).thenApply(r-> null)); return stream.collect(Collectors.toList()); }
/** {@inheritDoc} */ @Override public TableName getName() { return helper.getName(); }
/** {@inheritDoc} */ @Override public Configuration getConfiguration() { return helper.getConfiguration(); }