Search in sources :

Example 1 with BulkMutateRowsUserFacingCallable

use of com.google.cloud.bigtable.data.v2.stub.mutaterows.BulkMutateRowsUserFacingCallable 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());
}
Also used : BulkMutation(com.google.cloud.bigtable.data.v2.models.BulkMutation) BulkMutateRowsUserFacingCallable(com.google.cloud.bigtable.data.v2.stub.mutaterows.BulkMutateRowsUserFacingCallable) SpanName(com.google.api.gax.tracing.SpanName) TracedUnaryCallable(com.google.api.gax.tracing.TracedUnaryCallable) HeaderTracerUnaryCallable(com.google.cloud.bigtable.data.v2.stub.metrics.HeaderTracerUnaryCallable) MutateRowsRequest(com.google.bigtable.v2.MutateRowsRequest) TracedBatcherUnaryCallable(com.google.cloud.bigtable.data.v2.stub.metrics.TracedBatcherUnaryCallable)

Aggregations

SpanName (com.google.api.gax.tracing.SpanName)1 TracedUnaryCallable (com.google.api.gax.tracing.TracedUnaryCallable)1 MutateRowsRequest (com.google.bigtable.v2.MutateRowsRequest)1 BulkMutation (com.google.cloud.bigtable.data.v2.models.BulkMutation)1 HeaderTracerUnaryCallable (com.google.cloud.bigtable.data.v2.stub.metrics.HeaderTracerUnaryCallable)1 TracedBatcherUnaryCallable (com.google.cloud.bigtable.data.v2.stub.metrics.TracedBatcherUnaryCallable)1 BulkMutateRowsUserFacingCallable (com.google.cloud.bigtable.data.v2.stub.mutaterows.BulkMutateRowsUserFacingCallable)1