Search in sources :

Example 1 with ReadRowsRetryingCallable

use of com.google.cloud.bigquery.storage.v1beta2.stub.readrows.ReadRowsRetryingCallable 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.v1beta2.stub.readrows.ReadRowsRetryingCallable) ReadRowsRequest(com.google.cloud.bigquery.storage.v1beta2.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.v1beta2.ReadRowsResponse) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap)

Example 2 with ReadRowsRetryingCallable

use of com.google.cloud.bigquery.storage.v1beta2.stub.readrows.ReadRowsRetryingCallable in project java-bigquerystorage by googleapis.

the class EnhancedBigQueryStorageStub method readRowsCallable.

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

        @Override
        public Map<String, String> extract(ReadRowsRequest request) {
            return ImmutableMap.of("read_position.stream.name", String.valueOf(request.getReadPosition().getStream().getName()));
        }
    }).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.v1beta1.stub.readrows.ReadRowsRetryingCallable) ReadRowsRequest(com.google.cloud.bigquery.storage.v1beta1.Storage.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.v1beta1.Storage.ReadRowsResponse) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap)

Example 3 with ReadRowsRetryingCallable

use of com.google.cloud.bigquery.storage.v1beta2.stub.readrows.ReadRowsRetryingCallable 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)3 ScheduledRetryingExecutor (com.google.api.gax.retrying.ScheduledRetryingExecutor)3 StreamingRetryAlgorithm (com.google.api.gax.retrying.StreamingRetryAlgorithm)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 ReadRowsRetryingCallable (com.google.cloud.bigquery.storage.v1beta2.stub.readrows.ReadRowsRetryingCallable)1