Search in sources :

Example 6 with GenerateConsistencyTokenResponse

use of com.google.bigtable.admin.v2.GenerateConsistencyTokenResponse in project java-bigtable by googleapis.

the class BaseBigtableTableAdminClientTest method generateConsistencyTokenTest.

@Test
public void generateConsistencyTokenTest() throws Exception {
    GenerateConsistencyTokenResponse expectedResponse = GenerateConsistencyTokenResponse.newBuilder().setConsistencyToken("consistencyToken-1985152319").build();
    mockBigtableTableAdmin.addResponse(expectedResponse);
    TableName name = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]");
    GenerateConsistencyTokenResponse actualResponse = client.generateConsistencyToken(name);
    Assert.assertEquals(expectedResponse, actualResponse);
    List<AbstractMessage> actualRequests = mockBigtableTableAdmin.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    GenerateConsistencyTokenRequest actualRequest = ((GenerateConsistencyTokenRequest) actualRequests.get(0));
    Assert.assertEquals(name.toString(), actualRequest.getName());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : TableName(com.google.bigtable.admin.v2.TableName) AbstractMessage(com.google.protobuf.AbstractMessage) GenerateConsistencyTokenRequest(com.google.bigtable.admin.v2.GenerateConsistencyTokenRequest) GenerateConsistencyTokenResponse(com.google.bigtable.admin.v2.GenerateConsistencyTokenResponse) Test(org.junit.Test)

Example 7 with GenerateConsistencyTokenResponse

use of com.google.bigtable.admin.v2.GenerateConsistencyTokenResponse 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);
}
Also used : GenerateConsistencyTokenRequest(com.google.bigtable.admin.v2.GenerateConsistencyTokenRequest) CheckConsistencyResponse(com.google.bigtable.admin.v2.CheckConsistencyResponse) GenerateConsistencyTokenResponse(com.google.bigtable.admin.v2.GenerateConsistencyTokenResponse) CheckConsistencyRequest(com.google.bigtable.admin.v2.CheckConsistencyRequest) Test(org.junit.Test)

Example 8 with GenerateConsistencyTokenResponse

use of com.google.bigtable.admin.v2.GenerateConsistencyTokenResponse 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);
}
Also used : ScheduledRetryingExecutor(com.google.api.gax.retrying.ScheduledRetryingExecutor) CheckConsistencyResponse(com.google.bigtable.admin.v2.CheckConsistencyResponse) RetryAlgorithm(com.google.api.gax.retrying.RetryAlgorithm) ResultRetryAlgorithm(com.google.api.gax.retrying.ResultRetryAlgorithm) ExponentialPollAlgorithm(com.google.api.gax.retrying.ExponentialPollAlgorithm)

Aggregations

GenerateConsistencyTokenRequest (com.google.bigtable.admin.v2.GenerateConsistencyTokenRequest)7 Test (org.junit.Test)7 GenerateConsistencyTokenResponse (com.google.bigtable.admin.v2.GenerateConsistencyTokenResponse)6 CheckConsistencyRequest (com.google.bigtable.admin.v2.CheckConsistencyRequest)4 CheckConsistencyResponse (com.google.bigtable.admin.v2.CheckConsistencyResponse)4 ExecutionException (java.util.concurrent.ExecutionException)3 FakeApiException (com.google.api.gax.rpc.testing.FakeApiException)2 AbstractMessage (com.google.protobuf.AbstractMessage)2 ExponentialPollAlgorithm (com.google.api.gax.retrying.ExponentialPollAlgorithm)1 ResultRetryAlgorithm (com.google.api.gax.retrying.ResultRetryAlgorithm)1 RetryAlgorithm (com.google.api.gax.retrying.RetryAlgorithm)1 ScheduledRetryingExecutor (com.google.api.gax.retrying.ScheduledRetryingExecutor)1 TableName (com.google.bigtable.admin.v2.TableName)1 ByteString (com.google.protobuf.ByteString)1