Search in sources :

Example 1 with SpanName

use of com.google.api.gax.tracing.SpanName 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)

Example 2 with SpanName

use of com.google.api.gax.tracing.SpanName in project java-bigtable by googleapis.

the class EnhancedBigtableStub method createReadRowsCallable.

/**
 * Creates a callable chain to handle streaming ReadRows RPCs. The chain will:
 *
 * <ul>
 *   <li>Convert a {@link Query} into a {@link com.google.bigtable.v2.ReadRowsRequest} and
 *       dispatch the RPC.
 *   <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>Add tracing & metrics.
 * </ul>
 */
public <RowT> ServerStreamingCallable<Query, RowT> createReadRowsCallable(RowAdapter<RowT> rowAdapter) {
    ServerStreamingCallable<ReadRowsRequest, RowT> readRowsCallable = createReadRowsBaseCallable(settings.readRowsSettings(), rowAdapter);
    ServerStreamingCallable<Query, RowT> readRowsUserCallable = new ReadRowsUserCallable<>(readRowsCallable, requestContext);
    SpanName span = getSpanName("ReadRows");
    ServerStreamingCallable<Query, RowT> traced = new TracedServerStreamingCallable<>(readRowsUserCallable, clientContext.getTracerFactory(), span);
    return traced.withDefaultCallContext(clientContext.getDefaultCallContext());
}
Also used : ReadRowsUserCallable(com.google.cloud.bigtable.data.v2.stub.readrows.ReadRowsUserCallable) SpanName(com.google.api.gax.tracing.SpanName) TracedServerStreamingCallable(com.google.api.gax.tracing.TracedServerStreamingCallable) Query(com.google.cloud.bigtable.data.v2.models.Query) ReadRowsRequest(com.google.bigtable.v2.ReadRowsRequest)

Example 3 with SpanName

use of com.google.api.gax.tracing.SpanName 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());
}
Also used : ReadRowsUserCallable(com.google.cloud.bigtable.data.v2.stub.readrows.ReadRowsUserCallable) SpanName(com.google.api.gax.tracing.SpanName) TracedUnaryCallable(com.google.api.gax.tracing.TracedUnaryCallable) HeaderTracerUnaryCallable(com.google.cloud.bigtable.data.v2.stub.metrics.HeaderTracerUnaryCallable) Query(com.google.cloud.bigtable.data.v2.models.Query) ReadRowsRequest(com.google.bigtable.v2.ReadRowsRequest) List(java.util.List) ImmutableList(com.google.common.collect.ImmutableList) TracedBatcherUnaryCallable(com.google.cloud.bigtable.data.v2.stub.metrics.TracedBatcherUnaryCallable)

Aggregations

SpanName (com.google.api.gax.tracing.SpanName)3 TracedUnaryCallable (com.google.api.gax.tracing.TracedUnaryCallable)2 ReadRowsRequest (com.google.bigtable.v2.ReadRowsRequest)2 Query (com.google.cloud.bigtable.data.v2.models.Query)2 HeaderTracerUnaryCallable (com.google.cloud.bigtable.data.v2.stub.metrics.HeaderTracerUnaryCallable)2 TracedBatcherUnaryCallable (com.google.cloud.bigtable.data.v2.stub.metrics.TracedBatcherUnaryCallable)2 ReadRowsUserCallable (com.google.cloud.bigtable.data.v2.stub.readrows.ReadRowsUserCallable)2 TracedServerStreamingCallable (com.google.api.gax.tracing.TracedServerStreamingCallable)1 MutateRowsRequest (com.google.bigtable.v2.MutateRowsRequest)1 BulkMutation (com.google.cloud.bigtable.data.v2.models.BulkMutation)1 BulkMutateRowsUserFacingCallable (com.google.cloud.bigtable.data.v2.stub.mutaterows.BulkMutateRowsUserFacingCallable)1 ImmutableList (com.google.common.collect.ImmutableList)1 List (java.util.List)1