use of com.google.bigtable.admin.v2.CheckConsistencyResponse in project java-bigtable by googleapis.
the class AwaitReplicationCallable method create.
static AwaitReplicationCallable create(UnaryCallable<GenerateConsistencyTokenRequest, GenerateConsistencyTokenResponse> generateCallable, UnaryCallable<CheckConsistencyRequest, CheckConsistencyResponse> checkCallable, ClientContext clientContext, RetrySettings pollingSettings) {
RetryAlgorithm<CheckConsistencyResponse> retryAlgorithm = new RetryAlgorithm<>(new PollResultAlgorithm(), new ExponentialPollAlgorithm(pollingSettings, clientContext.getClock()));
RetryingExecutor<CheckConsistencyResponse> retryingExecutor = new ScheduledRetryingExecutor<>(retryAlgorithm, clientContext.getExecutor());
return new AwaitReplicationCallable(generateCallable, checkCallable, retryingExecutor);
}
use of com.google.bigtable.admin.v2.CheckConsistencyResponse in project java-bigtable by googleapis.
the class AwaitReplicationCallableTest method testImmediatelyConsistent.
@Test
public void testImmediatelyConsistent() throws Exception {
GenerateConsistencyTokenRequest expectedRequest = GenerateConsistencyTokenRequest.newBuilder().setName(TABLE_NAME.toString()).build();
GenerateConsistencyTokenResponse expectedResponse = GenerateConsistencyTokenResponse.newBuilder().setConsistencyToken("fake-token").build();
Mockito.when(mockGenerateConsistencyTokenCallable.futureCall(expectedRequest, CALL_CONTEXT)).thenReturn(ApiFutures.immediateFuture(expectedResponse));
CheckConsistencyRequest expectedRequest2 = CheckConsistencyRequest.newBuilder().setName(TABLE_NAME.toString()).setConsistencyToken("fake-token").build();
CheckConsistencyResponse expectedResponse2 = CheckConsistencyResponse.newBuilder().setConsistent(true).build();
Mockito.when(mockCheckConsistencyCallable.futureCall(expectedRequest2, CALL_CONTEXT)).thenReturn(ApiFutures.immediateFuture(expectedResponse2));
ApiFuture<Void> consistentFuture = callable.futureCall(TABLE_NAME, CALL_CONTEXT);
consistentFuture.get(1, TimeUnit.MILLISECONDS);
}
Aggregations