Search in sources :

Example 1 with StatsHeadersServerStreamingCallable

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

the class EnhancedBigtableStub method createMutateRowsBaseCallable.

/**
 * Internal helper to create the base MutateRows callable chain. The chain is responsible for
 * retrying individual entry in case of error.
 *
 * <p>NOTE: the caller is responsible for adding tracing & metrics.
 *
 * @see MutateRowsRetryingCallable for more details
 */
private UnaryCallable<MutateRowsRequest, Void> createMutateRowsBaseCallable() {
    ServerStreamingCallable<MutateRowsRequest, MutateRowsResponse> base = GrpcRawCallableFactory.createServerStreamingCallable(GrpcCallSettings.<MutateRowsRequest, MutateRowsResponse>newBuilder().setMethodDescriptor(BigtableGrpc.getMutateRowsMethod()).setParamsExtractor(new RequestParamsExtractor<MutateRowsRequest>() {

        @Override
        public Map<String, String> extract(MutateRowsRequest mutateRowsRequest) {
            return ImmutableMap.of("table_name", mutateRowsRequest.getTableName(), "app_profile_id", mutateRowsRequest.getAppProfileId());
        }
    }).build(), settings.bulkMutateRowsSettings().getRetryableCodes());
    ServerStreamingCallable<MutateRowsRequest, MutateRowsResponse> withStatsHeaders = new StatsHeadersServerStreamingCallable<>(base);
    RetryAlgorithm<Void> retryAlgorithm = new RetryAlgorithm<>(new ApiResultRetryAlgorithm<Void>(), new ExponentialRetryAlgorithm(settings.bulkMutateRowsSettings().getRetrySettings(), clientContext.getClock()));
    RetryingExecutorWithContext<Void> retryingExecutor = new ScheduledRetryingExecutor<>(retryAlgorithm, clientContext.getExecutor());
    return new MutateRowsRetryingCallable(clientContext.getDefaultCallContext(), withStatsHeaders, retryingExecutor, settings.bulkMutateRowsSettings().getRetryableCodes());
}
Also used : RetryAlgorithm(com.google.api.gax.retrying.RetryAlgorithm) ExponentialRetryAlgorithm(com.google.api.gax.retrying.ExponentialRetryAlgorithm) ApiResultRetryAlgorithm(com.google.cloud.bigtable.gaxx.retrying.ApiResultRetryAlgorithm) ExponentialRetryAlgorithm(com.google.api.gax.retrying.ExponentialRetryAlgorithm) StatsHeadersServerStreamingCallable(com.google.cloud.bigtable.data.v2.stub.metrics.StatsHeadersServerStreamingCallable) ScheduledRetryingExecutor(com.google.api.gax.retrying.ScheduledRetryingExecutor) MutateRowsResponse(com.google.bigtable.v2.MutateRowsResponse) MutateRowsRequest(com.google.bigtable.v2.MutateRowsRequest) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap) MutateRowsRetryingCallable(com.google.cloud.bigtable.data.v2.stub.mutaterows.MutateRowsRetryingCallable)

Aggregations

ExponentialRetryAlgorithm (com.google.api.gax.retrying.ExponentialRetryAlgorithm)1 RetryAlgorithm (com.google.api.gax.retrying.RetryAlgorithm)1 ScheduledRetryingExecutor (com.google.api.gax.retrying.ScheduledRetryingExecutor)1 MutateRowsRequest (com.google.bigtable.v2.MutateRowsRequest)1 MutateRowsResponse (com.google.bigtable.v2.MutateRowsResponse)1 StatsHeadersServerStreamingCallable (com.google.cloud.bigtable.data.v2.stub.metrics.StatsHeadersServerStreamingCallable)1 MutateRowsRetryingCallable (com.google.cloud.bigtable.data.v2.stub.mutaterows.MutateRowsRetryingCallable)1 ApiResultRetryAlgorithm (com.google.cloud.bigtable.gaxx.retrying.ApiResultRetryAlgorithm)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 Map (java.util.Map)1