Search in sources :

Example 1 with HeaderTracerUnaryCallable

use of com.google.cloud.bigtable.data.v2.stub.metrics.HeaderTracerUnaryCallable in project java-bigtable by googleapis.

the class EnhancedBigtableStub method createMutateRowCallable.

/**
 * Creates a callable chain to handle MutateRow RPCs. The chain will:
 *
 * <ul>
 *   <li>Convert a {@link RowMutation} into a {@link com.google.bigtable.v2.MutateRowRequest}.
 *   <li>Add tracing & metrics.
 * </ul>
 */
private UnaryCallable<RowMutation, Void> createMutateRowCallable() {
    String methodName = "MutateRow";
    UnaryCallable<MutateRowRequest, MutateRowResponse> base = GrpcRawCallableFactory.createUnaryCallable(GrpcCallSettings.<MutateRowRequest, MutateRowResponse>newBuilder().setMethodDescriptor(BigtableGrpc.getMutateRowMethod()).setParamsExtractor(new RequestParamsExtractor<MutateRowRequest>() {

        @Override
        public Map<String, String> extract(MutateRowRequest mutateRowRequest) {
            return ImmutableMap.of("table_name", mutateRowRequest.getTableName(), "app_profile_id", mutateRowRequest.getAppProfileId());
        }
    }).build(), settings.mutateRowSettings().getRetryableCodes());
    UnaryCallable<MutateRowRequest, MutateRowResponse> withStatsHeaders = new StatsHeadersUnaryCallable<>(base);
    UnaryCallable<MutateRowRequest, MutateRowResponse> withHeaderTracer = new HeaderTracerUnaryCallable<>(withStatsHeaders);
    UnaryCallable<MutateRowRequest, MutateRowResponse> retrying = Callables.retrying(withHeaderTracer, settings.mutateRowSettings(), clientContext);
    return createUserFacingUnaryCallable(methodName, new MutateRowCallable(retrying, requestContext));
}
Also used : MutateRowRequest(com.google.bigtable.v2.MutateRowRequest) CheckAndMutateRowRequest(com.google.bigtable.v2.CheckAndMutateRowRequest) CheckAndMutateRowResponse(com.google.bigtable.v2.CheckAndMutateRowResponse) MutateRowResponse(com.google.bigtable.v2.MutateRowResponse) HeaderTracerUnaryCallable(com.google.cloud.bigtable.data.v2.stub.metrics.HeaderTracerUnaryCallable) StatsHeadersUnaryCallable(com.google.cloud.bigtable.data.v2.stub.metrics.StatsHeadersUnaryCallable) ByteString(com.google.protobuf.ByteString) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap)

Example 2 with HeaderTracerUnaryCallable

use of com.google.cloud.bigtable.data.v2.stub.metrics.HeaderTracerUnaryCallable 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 3 with HeaderTracerUnaryCallable

use of com.google.cloud.bigtable.data.v2.stub.metrics.HeaderTracerUnaryCallable in project java-bigtable by googleapis.

the class EnhancedBigtableStub method createReadModifyWriteRowCallable.

/**
 * Creates a callable chain to handle ReadModifyWriteRow RPCs. The chain will:
 *
 * <ul>
 *   <li>Convert {@link ReadModifyWriteRow}s into {@link
 *       com.google.bigtable.v2.ReadModifyWriteRowRequest}s.
 *   <li>Convert the responses into {@link Row}.
 *   <li>Add tracing & metrics.
 * </ul>
 */
private UnaryCallable<ReadModifyWriteRow, Row> createReadModifyWriteRowCallable() {
    UnaryCallable<ReadModifyWriteRowRequest, ReadModifyWriteRowResponse> base = GrpcRawCallableFactory.createUnaryCallable(GrpcCallSettings.<ReadModifyWriteRowRequest, ReadModifyWriteRowResponse>newBuilder().setMethodDescriptor(BigtableGrpc.getReadModifyWriteRowMethod()).setParamsExtractor(new RequestParamsExtractor<ReadModifyWriteRowRequest>() {

        @Override
        public Map<String, String> extract(ReadModifyWriteRowRequest request) {
            return ImmutableMap.of("table_name", request.getTableName(), "app_profile_id", request.getAppProfileId());
        }
    }).build(), settings.readModifyWriteRowSettings().getRetryableCodes());
    UnaryCallable<ReadModifyWriteRowRequest, ReadModifyWriteRowResponse> withStatsHeaders = new StatsHeadersUnaryCallable<>(base);
    String methodName = "ReadModifyWriteRow";
    UnaryCallable<ReadModifyWriteRowRequest, ReadModifyWriteRowResponse> withHeaderTracer = new HeaderTracerUnaryCallable<>(withStatsHeaders);
    UnaryCallable<ReadModifyWriteRowRequest, ReadModifyWriteRowResponse> retrying = Callables.retrying(withHeaderTracer, settings.readModifyWriteRowSettings(), clientContext);
    return createUserFacingUnaryCallable(methodName, new ReadModifyWriteRowCallable(retrying, requestContext));
}
Also used : HeaderTracerUnaryCallable(com.google.cloud.bigtable.data.v2.stub.metrics.HeaderTracerUnaryCallable) ReadModifyWriteRowRequest(com.google.bigtable.v2.ReadModifyWriteRowRequest) StatsHeadersUnaryCallable(com.google.cloud.bigtable.data.v2.stub.metrics.StatsHeadersUnaryCallable) ByteString(com.google.protobuf.ByteString) ReadModifyWriteRowResponse(com.google.bigtable.v2.ReadModifyWriteRowResponse) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap)

Example 4 with HeaderTracerUnaryCallable

use of com.google.cloud.bigtable.data.v2.stub.metrics.HeaderTracerUnaryCallable in project java-bigtable by googleapis.

the class EnhancedBigtableStub method createCheckAndMutateRowCallable.

/**
 * Creates a callable chain to handle CheckAndMutateRow RPCs. THe chain will:
 *
 * <ul>
 *   <li>Convert {@link ConditionalRowMutation}s into {@link
 *       com.google.bigtable.v2.CheckAndMutateRowRequest}s.
 *   <li>Add tracing & metrics.
 * </ul>
 */
private UnaryCallable<ConditionalRowMutation, Boolean> createCheckAndMutateRowCallable() {
    String methodName = "CheckAndMutateRow";
    UnaryCallable<CheckAndMutateRowRequest, CheckAndMutateRowResponse> base = GrpcRawCallableFactory.createUnaryCallable(GrpcCallSettings.<CheckAndMutateRowRequest, CheckAndMutateRowResponse>newBuilder().setMethodDescriptor(BigtableGrpc.getCheckAndMutateRowMethod()).setParamsExtractor(new RequestParamsExtractor<CheckAndMutateRowRequest>() {

        @Override
        public Map<String, String> extract(CheckAndMutateRowRequest checkAndMutateRowRequest) {
            return ImmutableMap.of("table_name", checkAndMutateRowRequest.getTableName(), "app_profile_id", checkAndMutateRowRequest.getAppProfileId());
        }
    }).build(), settings.checkAndMutateRowSettings().getRetryableCodes());
    UnaryCallable<CheckAndMutateRowRequest, CheckAndMutateRowResponse> withStatsHeaders = new StatsHeadersUnaryCallable<>(base);
    UnaryCallable<CheckAndMutateRowRequest, CheckAndMutateRowResponse> withHeaderTracer = new HeaderTracerUnaryCallable<>(withStatsHeaders);
    UnaryCallable<CheckAndMutateRowRequest, CheckAndMutateRowResponse> retrying = Callables.retrying(withHeaderTracer, settings.checkAndMutateRowSettings(), clientContext);
    return createUserFacingUnaryCallable(methodName, new CheckAndMutateRowCallable(retrying, requestContext));
}
Also used : HeaderTracerUnaryCallable(com.google.cloud.bigtable.data.v2.stub.metrics.HeaderTracerUnaryCallable) CheckAndMutateRowResponse(com.google.bigtable.v2.CheckAndMutateRowResponse) StatsHeadersUnaryCallable(com.google.cloud.bigtable.data.v2.stub.metrics.StatsHeadersUnaryCallable) ByteString(com.google.protobuf.ByteString) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap) CheckAndMutateRowRequest(com.google.bigtable.v2.CheckAndMutateRowRequest)

Example 5 with HeaderTracerUnaryCallable

use of com.google.cloud.bigtable.data.v2.stub.metrics.HeaderTracerUnaryCallable in project java-bigtable by googleapis.

the class EnhancedBigtableStub method createSampleRowKeysCallable.

/**
 * Creates a callable chain to handle SampleRowKeys RPcs. The chain will:
 *
 * <ul>
 *   <li>Convert a table id to a {@link com.google.bigtable.v2.SampleRowKeysRequest}.
 *   <li>Dispatch the request to the GAPIC's {@link BigtableStub#sampleRowKeysCallable()}.
 *   <li>Spool responses into a list.
 *   <li>Retry on failure.
 *   <li>Convert the responses into {@link KeyOffset}s.
 *   <li>Add tracing & metrics.
 * </ul>
 */
private UnaryCallable<String, List<KeyOffset>> createSampleRowKeysCallable() {
    String methodName = "SampleRowKeys";
    ServerStreamingCallable<SampleRowKeysRequest, SampleRowKeysResponse> base = GrpcRawCallableFactory.createServerStreamingCallable(GrpcCallSettings.<SampleRowKeysRequest, SampleRowKeysResponse>newBuilder().setMethodDescriptor(BigtableGrpc.getSampleRowKeysMethod()).setParamsExtractor(new RequestParamsExtractor<SampleRowKeysRequest>() {

        @Override
        public Map<String, String> extract(SampleRowKeysRequest sampleRowKeysRequest) {
            return ImmutableMap.of("table_name", sampleRowKeysRequest.getTableName(), "app_profile_id", sampleRowKeysRequest.getAppProfileId());
        }
    }).build(), settings.sampleRowKeysSettings().getRetryableCodes());
    UnaryCallable<SampleRowKeysRequest, List<SampleRowKeysResponse>> spoolable = base.all();
    UnaryCallable<SampleRowKeysRequest, List<SampleRowKeysResponse>> withStatsHeaders = new StatsHeadersUnaryCallable<>(spoolable);
    UnaryCallable<SampleRowKeysRequest, List<SampleRowKeysResponse>> withHeaderTracer = new HeaderTracerUnaryCallable<>(withStatsHeaders);
    UnaryCallable<SampleRowKeysRequest, List<SampleRowKeysResponse>> retryable = Callables.retrying(withHeaderTracer, settings.sampleRowKeysSettings(), clientContext);
    return createUserFacingUnaryCallable(methodName, new SampleRowKeysCallable(retryable, requestContext));
}
Also used : SampleRowKeysResponse(com.google.bigtable.v2.SampleRowKeysResponse) HeaderTracerUnaryCallable(com.google.cloud.bigtable.data.v2.stub.metrics.HeaderTracerUnaryCallable) SampleRowKeysRequest(com.google.bigtable.v2.SampleRowKeysRequest) List(java.util.List) ImmutableList(com.google.common.collect.ImmutableList) StatsHeadersUnaryCallable(com.google.cloud.bigtable.data.v2.stub.metrics.StatsHeadersUnaryCallable) ByteString(com.google.protobuf.ByteString) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap)

Aggregations

HeaderTracerUnaryCallable (com.google.cloud.bigtable.data.v2.stub.metrics.HeaderTracerUnaryCallable)6 StatsHeadersUnaryCallable (com.google.cloud.bigtable.data.v2.stub.metrics.StatsHeadersUnaryCallable)4 ImmutableMap (com.google.common.collect.ImmutableMap)4 ByteString (com.google.protobuf.ByteString)4 Map (java.util.Map)4 SpanName (com.google.api.gax.tracing.SpanName)2 TracedUnaryCallable (com.google.api.gax.tracing.TracedUnaryCallable)2 CheckAndMutateRowRequest (com.google.bigtable.v2.CheckAndMutateRowRequest)2 CheckAndMutateRowResponse (com.google.bigtable.v2.CheckAndMutateRowResponse)2 TracedBatcherUnaryCallable (com.google.cloud.bigtable.data.v2.stub.metrics.TracedBatcherUnaryCallable)2 ImmutableList (com.google.common.collect.ImmutableList)2 List (java.util.List)2 MutateRowRequest (com.google.bigtable.v2.MutateRowRequest)1 MutateRowResponse (com.google.bigtable.v2.MutateRowResponse)1 MutateRowsRequest (com.google.bigtable.v2.MutateRowsRequest)1 ReadModifyWriteRowRequest (com.google.bigtable.v2.ReadModifyWriteRowRequest)1 ReadModifyWriteRowResponse (com.google.bigtable.v2.ReadModifyWriteRowResponse)1 ReadRowsRequest (com.google.bigtable.v2.ReadRowsRequest)1 SampleRowKeysRequest (com.google.bigtable.v2.SampleRowKeysRequest)1 SampleRowKeysResponse (com.google.bigtable.v2.SampleRowKeysResponse)1