Search in sources :

Example 6 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