use of com.google.bigtable.repackaged.com.google.bigtable.v2.ReadRowsRequest 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());
}
use of com.google.bigtable.repackaged.com.google.bigtable.v2.ReadRowsRequest in project java-bigquerystorage by googleapis.
the class ReadRowsAttemptCallable method call.
/**
* Sends the actual RPC. The request being sent will first be transformed by the {@link
* StreamResumptionStrategy}.
*
* <p>This method expects to be called by one thread at a time. Furthermore, it expects that the
* current RPC finished before the next time it's called.
*/
@Override
public Void call() {
Preconditions.checkState(isStarted, "Must be started first");
ReadRowsRequest request = (++numAttempts == 1) ? initialRequest : resumptionStrategy.getResumeRequest(initialRequest);
// Should never happen. onAttemptError will check if ResumptionStrategy can create a resume
// request,
// which the RetryingFuture/StreamResumptionStrategy should respect.
Preconditions.checkState(request != null, "ResumptionStrategy returned a null request.");
innerAttemptFuture = SettableApiFuture.create();
seenSuccessSinceLastError = false;
ApiCallContext attemptContext = context;
if (!outerRetryingFuture.getAttemptSettings().getRpcTimeout().isZero()) {
attemptContext = attemptContext.withStreamWaitTimeout(outerRetryingFuture.getAttemptSettings().getRpcTimeout());
}
attemptContext.getTracer().attemptStarted(outerRetryingFuture.getAttemptSettings().getOverallAttemptCount());
innerCallable.call(request, new StateCheckingResponseObserver<ReadRowsResponse>() {
@Override
public void onStartImpl(StreamController controller) {
onAttemptStart(controller);
}
@Override
public void onResponseImpl(ReadRowsResponse response) {
onAttemptResponse(response);
}
@Override
public void onErrorImpl(Throwable t) {
onAttemptError(t);
}
@Override
public void onCompleteImpl() {
onAttemptComplete();
}
}, attemptContext);
outerRetryingFuture.setAttemptFuture(innerAttemptFuture);
return null;
}
use of com.google.bigtable.repackaged.com.google.bigtable.v2.ReadRowsRequest in project java-bigquerystorage by googleapis.
the class EnhancedBigQueryReadStubSettingsTest method testReadRowsSettings.
@Test
public void testReadRowsSettings() {
ServerStreamingCallSettings.Builder<ReadRowsRequest, ReadRowsResponse> builder = EnhancedBigQueryReadStubSettings.newBuilder().readRowsSettings();
assertThat(builder.getRetryableCodes()).contains(Code.UNAVAILABLE);
RetrySettings retrySettings = builder.getRetrySettings();
assertThat(retrySettings.getInitialRetryDelay()).isEqualTo(Duration.ofMillis(100L));
assertThat(retrySettings.getRetryDelayMultiplier()).isWithin(1e-6).of(1.3);
assertThat(retrySettings.getMaxRetryDelay()).isEqualTo(Duration.ofMinutes(1L));
assertThat(retrySettings.getInitialRpcTimeout()).isEqualTo(Duration.ofDays(1L));
assertThat(retrySettings.getRpcTimeoutMultiplier()).isWithin(1e-6).of(1.0);
assertThat(retrySettings.getMaxRpcTimeout()).isEqualTo(Duration.ofDays(1L));
assertThat(retrySettings.getTotalTimeout()).isEqualTo(Duration.ofDays(1L));
assertThat(builder.getIdleTimeout()).isEqualTo(Duration.ZERO);
}
use of com.google.bigtable.repackaged.com.google.bigtable.v2.ReadRowsRequest in project java-bigquerystorage by googleapis.
the class ResourceHeaderTest method readRowsTest.
@Test
public void readRowsTest() {
try {
ReadRowsRequest request = ReadRowsRequest.newBuilder().setReadStream(TEST_STREAM_NAME).setOffset(125).build();
client.readRowsCallable().call(request);
} catch (UnimplementedException e) {
// Ignore the error: none of the methods are actually implemented.
}
verifyHeaderSent(READ_STREAM_PATTERN);
}
use of com.google.bigtable.repackaged.com.google.bigtable.v2.ReadRowsRequest in project java-bigquerystorage by googleapis.
the class ReadRowsRetryTest method errorAtTheVeryEndTest.
@Test
public void errorAtTheVeryEndTest() {
ReadRowsRequest request = RpcExpectation.createRequest("fake-stream", 0);
service.expectations.add(RpcExpectation.create().expectRequest("fake-stream", 0).respondWithNumberOfRows(10).respondWithNumberOfRows(7).respondWithStatus(Code.UNAVAILABLE));
service.expectations.add(RpcExpectation.create().expectRequest("fake-stream", 17).respondWithNumberOfRows(0));
Assert.assertEquals(17, getRowCount(request));
}
Aggregations