use of com.google.api.gax.grpc.GrpcCallContext in project java-bigtable-hbase by googleapis.
the class DataClientVeneerApi method createScanCallContext.
// Support 2 bigtable-hbase features not directly available in veneer:
// - per attempt deadlines - vener doesn't implement deadlines for attempts. To workaround this,
// the timeouts are set per call in the ApiCallContext. However this creates a separate issue of
// over running the operation deadline, so gRPC deadline is also set.
private GrpcCallContext createScanCallContext() {
GrpcCallContext ctx = GrpcCallContext.createDefault();
OperationTimeouts callSettings = clientOperationTimeouts.getScanTimeouts();
if (callSettings.getOperationTimeout().isPresent()) {
ctx = ctx.withCallOptions(CallOptions.DEFAULT.withDeadline(Deadline.after(callSettings.getOperationTimeout().get().toMillis(), TimeUnit.MILLISECONDS)));
}
if (callSettings.getAttemptTimeout().isPresent()) {
ctx = ctx.withTimeout(callSettings.getAttemptTimeout().get());
}
return ctx;
}
use of com.google.api.gax.grpc.GrpcCallContext in project java-bigtable-hbase by googleapis.
the class DataClientVeneerApi method createReadRowCallContext.
// Point reads are implemented using a streaming ReadRows RPC. So timeouts need to be managed
// similar to scans below.
private ApiCallContext createReadRowCallContext() {
GrpcCallContext ctx = GrpcCallContext.createDefault();
OperationTimeouts callSettings = clientOperationTimeouts.getUnaryTimeouts();
if (callSettings.getAttemptTimeout().isPresent()) {
ctx = ctx.withTimeout(callSettings.getAttemptTimeout().get());
}
// Fix it by settings the underlying grpc deadline
if (callSettings.getOperationTimeout().isPresent()) {
ctx = ctx.withCallOptions(CallOptions.DEFAULT.withDeadline(Deadline.after(callSettings.getOperationTimeout().get().toMillis(), TimeUnit.MILLISECONDS)));
}
return ctx;
}
use of com.google.api.gax.grpc.GrpcCallContext in project java-bigtable by googleapis.
the class EnhancedBigtableStubTest method testCallContextPropagatedInMutationBatcher.
@Test
public void testCallContextPropagatedInMutationBatcher() throws IOException, InterruptedException, ExecutionException {
EnhancedBigtableStubSettings settings = defaultSettings.toBuilder().setRefreshingChannel(true).setPrimedTableIds("table1", "table2").build();
try (EnhancedBigtableStub stub = EnhancedBigtableStub.create(settings)) {
// clear the previous contexts
contextInterceptor.contexts.clear();
// Override the timeout
GrpcCallContext clientCtx = GrpcCallContext.createDefault().withTimeout(Duration.ofMinutes(10));
// Send a batch
try (Batcher<RowMutationEntry, Void> batcher = stub.newMutateRowsBatcher("table1", clientCtx)) {
batcher.add(RowMutationEntry.create("key").deleteRow()).get();
}
// Ensure that the server got the overriden deadline
Context serverCtx = contextInterceptor.contexts.poll();
assertThat(serverCtx).isNotNull();
assertThat(serverCtx.getDeadline()).isAtLeast(Deadline.after(8, TimeUnit.MINUTES));
}
}
use of com.google.api.gax.grpc.GrpcCallContext in project java-bigtable by googleapis.
the class EnhancedBigtableStubTest method testCallContextPropagatedInReadBatcher.
@Test
public void testCallContextPropagatedInReadBatcher() throws IOException, InterruptedException, ExecutionException {
EnhancedBigtableStubSettings settings = defaultSettings.toBuilder().setRefreshingChannel(true).setPrimedTableIds("table1", "table2").build();
try (EnhancedBigtableStub stub = EnhancedBigtableStub.create(settings)) {
// clear the previous contexts
contextInterceptor.contexts.clear();
// Override the timeout
GrpcCallContext clientCtx = GrpcCallContext.createDefault().withTimeout(Duration.ofMinutes(10));
// Send a batch
try (Batcher<ByteString, Row> batcher = stub.newBulkReadRowsBatcher(Query.create("table1"), clientCtx)) {
batcher.add(ByteString.copyFromUtf8("key")).get();
}
// Ensure that the server got the overriden deadline
Context serverCtx = contextInterceptor.contexts.poll();
assertThat(serverCtx).isNotNull();
assertThat(serverCtx.getDeadline()).isAtLeast(Deadline.after(8, TimeUnit.MINUTES));
}
}
Aggregations