use of com.google.cloud.bigtable.data.v2.models.RowMutationEntry in project java-bigtable-hbase by googleapis.
the class HBaseRequestAdapter method adaptEntry.
/**
* adapt.
*
* @param delete a {@link Delete} object.
* @return a {@link RowMutationEntry} object.
*/
public RowMutationEntry adaptEntry(Delete delete) {
RowMutationEntry rowMutation = buildRowMutationEntry(delete.getRow());
adapt(delete, rowMutation);
return rowMutation;
}
use of com.google.cloud.bigtable.data.v2.models.RowMutationEntry in project java-bigtable-hbase by googleapis.
the class HBaseRequestAdapter method adaptEntry.
/**
* adaptEntry.
*
* @param mutations a {@link org.apache.hadoop.hbase.client.RowMutations} object.
* @return a {@link RowMutationEntry} object.
*/
public RowMutationEntry adaptEntry(RowMutations mutations) {
RowMutationEntry rowMutation = buildRowMutationEntry(mutations.getRow());
adapt(mutations, rowMutation);
return rowMutation;
}
use of com.google.cloud.bigtable.data.v2.models.RowMutationEntry in project java-bigtable-hbase by googleapis.
the class TestBigtableAsyncBufferedMutator method testMutate.
@Test
public void testMutate() throws ExecutionException, InterruptedException {
Put put = new Put(Bytes.toBytes("rowKey"));
RowMutationEntry entry = RowMutationEntry.create("rowKey");
when(mockRequestAdapter.adaptEntry(put)).thenReturn(entry);
when(mockBulkMutation.add(entry)).thenReturn(ApiFutures.immediateFuture(null));
asyncBufferedMutator.mutate(put).get();
verify(mockRequestAdapter).adaptEntry(put);
verify(mockBulkMutation).add(entry);
}
use of com.google.cloud.bigtable.data.v2.models.RowMutationEntry in project java-bigtable by googleapis.
the class MutateRowsBatchingDescriptorTest method countBytesTest.
@Test
public void countBytesTest() {
RowMutationEntry request = RowMutationEntry.create(ROW_KEY).setCell(FAMILY, QUALIFIER, VALUE);
long bytes = request.toProto().getSerializedSize();
MutateRowsBatchingDescriptor underTest = new MutateRowsBatchingDescriptor();
assertThat(underTest.countBytes(request)).isEqualTo(bytes);
}
use of com.google.cloud.bigtable.data.v2.models.RowMutationEntry in project java-bigtable by googleapis.
the class MutateRowsBatchingDescriptorTest method splitExceptionWithFailedMutationsTest.
@Test
public void splitExceptionWithFailedMutationsTest() {
MutateRowsBatchingDescriptor underTest = new MutateRowsBatchingDescriptor();
Throwable actualThrowable = null;
BatchEntry<RowMutationEntry, Void> batchEntry1 = BatchEntry.create(RowMutationEntry.create("key1").deleteRow(), SettableApiFuture.<Void>create());
BatchEntry<RowMutationEntry, Void> batchEntry2 = BatchEntry.create(RowMutationEntry.create("key2").deleteRow(), SettableApiFuture.<Void>create());
BatchEntry<RowMutationEntry, Void> batchEntry3 = BatchEntry.create(RowMutationEntry.create("key3").deleteRow(), SettableApiFuture.<Void>create());
// Threw an exception at 1st and 3rd entry
MutateRowsException serverError = new MutateRowsException(null, ImmutableList.of(MutateRowsException.FailedMutation.create(0, new UnavailableException(null, GrpcStatusCode.of(Status.Code.UNAVAILABLE), true)), MutateRowsException.FailedMutation.create(2, new DeadlineExceededException(null, GrpcStatusCode.of(Status.Code.DEADLINE_EXCEEDED), true))), true);
underTest.splitException(serverError, ImmutableList.of(batchEntry1, batchEntry2, batchEntry3));
try {
batchEntry1.getResultFuture().get();
} catch (ExecutionException | InterruptedException e) {
actualThrowable = e;
}
assertThat(actualThrowable).hasCauseThat().isEqualTo(serverError.getFailedMutations().get(0).getError());
// As there is no exception for 2nd entry so it should not throw any exception
actualThrowable = null;
try {
batchEntry2.getResultFuture().get();
} catch (ExecutionException | InterruptedException e) {
actualThrowable = e;
}
assertThat(actualThrowable).isNull();
actualThrowable = null;
try {
batchEntry3.getResultFuture().get();
} catch (ExecutionException | InterruptedException e) {
actualThrowable = e;
}
// The third response should has the last found failed mutation error.
assertThat(actualThrowable).hasCauseThat().isEqualTo(serverError.getFailedMutations().get(1).getError());
}
Aggregations