use of com.google.cloud.bigtable.data.v2.stub.metrics.TracedBatcherUnaryCallable in project java-bigtable by googleapis.
the class EnhancedBigtableStub method createBulkMutateRowsCallable.
/**
* Creates a callable chain to handle MutatesRows RPCs. This is meant to be used for manual
* batching. The chain will:
*
* <ul>
* <li>Convert a {@link BulkMutation} into a {@link MutateRowsRequest}.
* <li>Process the response and schedule retries. At the end of each attempt, entries that have
* been applied, are filtered from the next attempt. Also, any entries that failed with a
* nontransient error, are filtered from the next attempt. This will continue until there
* are no more entries or there are no more retry attempts left.
* <li>Wrap batch failures in a {@link
* com.google.cloud.bigtable.data.v2.models.MutateRowsException}.
* <li>Add tracing & metrics.
* </ul>
*/
private UnaryCallable<BulkMutation, Void> createBulkMutateRowsCallable() {
UnaryCallable<MutateRowsRequest, Void> baseCallable = createMutateRowsBaseCallable();
UnaryCallable<MutateRowsRequest, Void> flowControlCallable = null;
if (settings.bulkMutateRowsSettings().isLatencyBasedThrottlingEnabled()) {
flowControlCallable = new DynamicFlowControlCallable(baseCallable, bulkMutationFlowController, bulkMutationDynamicFlowControlStats, settings.bulkMutateRowsSettings().getTargetRpcLatencyMs(), FLOW_CONTROL_ADJUSTING_INTERVAL_MS);
}
UnaryCallable<BulkMutation, Void> userFacing = new BulkMutateRowsUserFacingCallable(flowControlCallable != null ? flowControlCallable : baseCallable, requestContext);
SpanName spanName = getSpanName("MutateRows");
UnaryCallable<BulkMutation, Void> tracedBatcher = new TracedBatcherUnaryCallable<>(userFacing);
UnaryCallable<BulkMutation, Void> withHeaderTracer = new HeaderTracerUnaryCallable<>(tracedBatcher);
UnaryCallable<BulkMutation, Void> traced = new TracedUnaryCallable<>(withHeaderTracer, clientContext.getTracerFactory(), spanName);
return traced.withDefaultCallContext(clientContext.getDefaultCallContext());
}
use of com.google.cloud.bigtable.data.v2.stub.metrics.TracedBatcherUnaryCallable in project java-bigtable by googleapis.
the class EnhancedBigtableStub method createBulkReadRowsCallable.
/**
* Creates a callable chain to handle bulk ReadRows RPCs. This is meant to be used in ReadRows
* batcher. The chain will:
*
* <ul>
* <li>Convert a {@link Query} into a {@link com.google.bigtable.v2.ReadRowsRequest}.
* <li>Upon receiving the response stream, it will merge the {@link
* com.google.bigtable.v2.ReadRowsResponse.CellChunk}s in logical rows. The actual row
* implementation can be configured in by the {@code rowAdapter} parameter.
* <li>Retry/resume on failure.
* <li>Filter out marker rows.
* <li>Construct a {@link UnaryCallable} that will buffer the entire stream into memory before
* completing. If the stream is empty, then the list will be empty.
* <li>Add tracing & metrics.
* </ul>
*/
private <RowT> UnaryCallable<Query, List<RowT>> createBulkReadRowsCallable(RowAdapter<RowT> rowAdapter) {
ServerStreamingCallable<ReadRowsRequest, RowT> readRowsCallable = createReadRowsBaseCallable(settings.readRowsSettings(), rowAdapter);
ServerStreamingCallable<Query, RowT> readRowsUserCallable = new ReadRowsUserCallable<>(readRowsCallable, requestContext);
SpanName span = getSpanName("ReadRows");
// The TracedBatcherUnaryCallable has to be wrapped by the TracedUnaryCallable, so that
// TracedUnaryCallable can inject a tracer for the TracedBatcherUnaryCallable to interact with
UnaryCallable<Query, List<RowT>> tracedBatcher = new TracedBatcherUnaryCallable<>(readRowsUserCallable.all());
UnaryCallable<Query, List<RowT>> withHeaderTracer = new HeaderTracerUnaryCallable(tracedBatcher);
UnaryCallable<Query, List<RowT>> traced = new TracedUnaryCallable<>(withHeaderTracer, clientContext.getTracerFactory(), span);
return traced.withDefaultCallContext(clientContext.getDefaultCallContext());
}
Aggregations