Search in sources :

Example 11 with StreamingRetryAlgorithm

use of com.google.api.gax.retrying.StreamingRetryAlgorithm in project java-bigquerystorage by googleapis.

the class EnhancedBigQueryReadStub method readRowsCallable.

public ServerStreamingCallable<ReadRowsRequest, ReadRowsResponse> readRowsCallable() {
    ServerStreamingCallable<ReadRowsRequest, ReadRowsResponse> innerCallable = GrpcRawCallableFactory.createServerStreamingCallable(GrpcCallSettings.<ReadRowsRequest, ReadRowsResponse>newBuilder().setMethodDescriptor(BigQueryReadGrpc.getReadRowsMethod()).setParamsExtractor(new RequestParamsExtractor<ReadRowsRequest>() {

        @Override
        public Map<String, String> extract(ReadRowsRequest request) {
            return ImmutableMap.of("read_stream", String.valueOf(request.getReadStream()));
        }
    }).build(), stubSettings.readRowsSettings().getRetryableCodes());
    ServerStreamingCallSettings<ReadRowsRequest, ReadRowsResponse> callSettings = stubSettings.readRowsSettings();
    StreamingRetryAlgorithm<Void> retryAlgorithm = new StreamingRetryAlgorithm<>(new ApiResultRetryAlgorithm<Void>(readRowsRetryAttemptListener), new ExponentialRetryAlgorithm(callSettings.getRetrySettings(), context.getClock()));
    ScheduledRetryingExecutor<Void> retryingExecutor = new ScheduledRetryingExecutor<>(retryAlgorithm, context.getExecutor());
    if (context.getStreamWatchdog() != null) {
        innerCallable = Callables.watched(innerCallable, callSettings, context);
    }
    ReadRowsRetryingCallable outerCallable = new ReadRowsRetryingCallable(context.getDefaultCallContext(), innerCallable, retryingExecutor, callSettings.getResumptionStrategy());
    ServerStreamingCallable<ReadRowsRequest, ReadRowsResponse> traced = new TracedServerStreamingCallable<>(outerCallable, context.getTracerFactory(), SpanName.of(TRACING_OUTER_CLIENT_NAME, "ReadRows"));
    return traced.withDefaultCallContext(context.getDefaultCallContext());
}
Also used : TracedServerStreamingCallable(com.google.api.gax.tracing.TracedServerStreamingCallable) ReadRowsRetryingCallable(com.google.cloud.bigquery.storage.v1.stub.readrows.ReadRowsRetryingCallable) ReadRowsRequest(com.google.cloud.bigquery.storage.v1.ReadRowsRequest) ExponentialRetryAlgorithm(com.google.api.gax.retrying.ExponentialRetryAlgorithm) ScheduledRetryingExecutor(com.google.api.gax.retrying.ScheduledRetryingExecutor) StreamingRetryAlgorithm(com.google.api.gax.retrying.StreamingRetryAlgorithm) ReadRowsResponse(com.google.cloud.bigquery.storage.v1.ReadRowsResponse) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap)

Aggregations

ExponentialRetryAlgorithm (com.google.api.gax.retrying.ExponentialRetryAlgorithm)11 StreamingRetryAlgorithm (com.google.api.gax.retrying.StreamingRetryAlgorithm)11 RetryingContext (com.google.api.gax.retrying.RetryingContext)7 TimedAttemptSettings (com.google.api.gax.retrying.TimedAttemptSettings)7 Test (org.junit.Test)7 ApiClock (com.google.api.core.ApiClock)6 BasicResultRetryAlgorithm (com.google.api.gax.retrying.BasicResultRetryAlgorithm)5 ScheduledRetryingExecutor (com.google.api.gax.retrying.ScheduledRetryingExecutor)4 ServerStreamingAttemptException (com.google.api.gax.retrying.ServerStreamingAttemptException)3 TracedServerStreamingCallable (com.google.api.gax.tracing.TracedServerStreamingCallable)3 ImmutableMap (com.google.common.collect.ImmutableMap)3 Map (java.util.Map)3 ReadRowsRequest (com.google.cloud.bigquery.storage.v1.ReadRowsRequest)1 ReadRowsResponse (com.google.cloud.bigquery.storage.v1.ReadRowsResponse)1 ReadRowsRetryingCallable (com.google.cloud.bigquery.storage.v1.stub.readrows.ReadRowsRetryingCallable)1 ReadRowsRequest (com.google.cloud.bigquery.storage.v1beta1.Storage.ReadRowsRequest)1 ReadRowsResponse (com.google.cloud.bigquery.storage.v1beta1.Storage.ReadRowsResponse)1 ReadRowsRetryingCallable (com.google.cloud.bigquery.storage.v1beta1.stub.readrows.ReadRowsRetryingCallable)1 ReadRowsRequest (com.google.cloud.bigquery.storage.v1beta2.ReadRowsRequest)1 ReadRowsResponse (com.google.cloud.bigquery.storage.v1beta2.ReadRowsResponse)1