use of com.google.cloud.bigtable.data.v2.models.RowMutation 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);
}
use of com.google.cloud.bigtable.data.v2.models.RowMutation in project java-bigtable by googleapis.
the class NativeImageBigtableSample method insertData.
public static void insertData(BigtableDataClient client, String tableId, long timestamp, ImmutableMap<String, Long> dataWithLong, ImmutableMap<String, String> dataWithStrings) {
String rowKey = String.format("phone#%d", timestamp);
RowMutation rowMutation = RowMutation.create(tableId, rowKey);
for (Entry<String, Long> longEntry : dataWithLong.entrySet()) {
rowMutation.setCell(COLUMN_FAMILY_NAME, ByteString.copyFrom(longEntry.getKey().getBytes()), timestamp, longEntry.getValue());
}
for (Entry<String, String> stringEntry : dataWithStrings.entrySet()) {
rowMutation.setCell(COLUMN_FAMILY_NAME, stringEntry.getKey(), timestamp, stringEntry.getValue());
}
client.mutateRow(rowMutation);
System.out.println("Successfully wrote row: " + rowKey);
}
use of com.google.cloud.bigtable.data.v2.models.RowMutation in project java-bigtable by googleapis.
the class BigtableDataClientTest method mutateRowTest.
@Test
public void mutateRowTest() {
Mockito.when(mockStub.mutateRowCallable()).thenReturn(mockMutateRowCallable);
Mockito.when(mockMutateRowCallable.futureCall(ArgumentMatchers.any(RowMutation.class))).thenAnswer((Answer) invocationOnMock -> ApiFutures.immediateFuture(Empty.getDefaultInstance()));
RowMutation request = RowMutation.create("fake-table", "some-key").setCell("some-family", "fake-qualifier", "fake-value");
bigtableDataClient.mutateRow(request);
Mockito.verify(mockMutateRowCallable).futureCall(request);
}
Aggregations