Search in sources :

Example 1 with BulkMutationWrapper

use of com.google.cloud.bigtable.hbase.wrappers.BulkMutationWrapper in project java-bigtable-hbase by googleapis.

the class TestBulkMutationVeneerApi method testWhenBatcherIsClosed.

@Test
public void testWhenBatcherIsClosed() throws IOException {
    BatchingSettings batchingSettings = mock(BatchingSettings.class);
    FlowControlSettings flowControlSettings = FlowControlSettings.newBuilder().setLimitExceededBehavior(LimitExceededBehavior.Ignore).build();
    when(batchingSettings.getFlowControlSettings()).thenReturn(flowControlSettings);
    @SuppressWarnings("unchecked") Batcher<RowMutationEntry, Void> actualBatcher = new BatcherImpl(mock(BatchingDescriptor.class), mock(UnaryCallable.class), new Object(), batchingSettings, mock(ScheduledExecutorService.class));
    BulkMutationWrapper underTest = new BulkMutationVeneerApi(actualBatcher);
    underTest.close();
    Exception actualEx = null;
    try {
        underTest.add(rowMutation);
        fail("batcher should throw exception");
    } catch (Exception e) {
        actualEx = e;
    }
    assertTrue(actualEx instanceof IllegalStateException);
}
Also used : ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) BatchingDescriptor(com.google.api.gax.batching.BatchingDescriptor) RowMutationEntry(com.google.cloud.bigtable.data.v2.models.RowMutationEntry) UnaryCallable(com.google.api.gax.rpc.UnaryCallable) BatcherImpl(com.google.api.gax.batching.BatcherImpl) IOException(java.io.IOException) FlowControlSettings(com.google.api.gax.batching.FlowControlSettings) BatchingSettings(com.google.api.gax.batching.BatchingSettings) BulkMutationWrapper(com.google.cloud.bigtable.hbase.wrappers.BulkMutationWrapper) Test(org.junit.Test)

Example 2 with BulkMutationWrapper

use of com.google.cloud.bigtable.hbase.wrappers.BulkMutationWrapper in project java-bigtable-hbase by googleapis.

the class TestDataClientVeneerApi method testCreateBulkMutation.

@Test
public void testCreateBulkMutation() throws Exception {
    RowMutationEntry entry = RowMutationEntry.create(ROW_KEY);
    when(mockDataClient.newBulkMutationBatcher(TABLE_ID)).thenReturn(mockMutationBatcher);
    when(mockMutationBatcher.add(entry)).thenReturn(ApiFutures.<Void>immediateFuture(null));
    BulkMutationWrapper mutationWrapper = dataClientWrapper.createBulkMutation(TABLE_ID);
    mutationWrapper.add(entry).get();
    verify(mockDataClient).newBulkMutationBatcher(TABLE_ID);
    verify(mockMutationBatcher).add(entry);
}
Also used : RowMutationEntry(com.google.cloud.bigtable.data.v2.models.RowMutationEntry) BulkMutationWrapper(com.google.cloud.bigtable.hbase.wrappers.BulkMutationWrapper) Test(org.junit.Test)

Aggregations

RowMutationEntry (com.google.cloud.bigtable.data.v2.models.RowMutationEntry)2 BulkMutationWrapper (com.google.cloud.bigtable.hbase.wrappers.BulkMutationWrapper)2 Test (org.junit.Test)2 BatcherImpl (com.google.api.gax.batching.BatcherImpl)1 BatchingDescriptor (com.google.api.gax.batching.BatchingDescriptor)1 BatchingSettings (com.google.api.gax.batching.BatchingSettings)1 FlowControlSettings (com.google.api.gax.batching.FlowControlSettings)1 UnaryCallable (com.google.api.gax.rpc.UnaryCallable)1 IOException (java.io.IOException)1 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)1