Search in sources :

Example 1 with RowMutationEntry

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;
}
Also used : RowMutationEntry(com.google.cloud.bigtable.data.v2.models.RowMutationEntry)

Example 2 with RowMutationEntry

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;
}
Also used : RowMutationEntry(com.google.cloud.bigtable.data.v2.models.RowMutationEntry)

Example 3 with RowMutationEntry

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);
}
Also used : RowMutationEntry(com.google.cloud.bigtable.data.v2.models.RowMutationEntry) Put(org.apache.hadoop.hbase.client.Put) Test(org.junit.Test)

Example 4 with RowMutationEntry

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);
}
Also used : RowMutationEntry(com.google.cloud.bigtable.data.v2.models.RowMutationEntry) Test(org.junit.Test)

Example 5 with RowMutationEntry

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());
}
Also used : MutateRowsException(com.google.cloud.bigtable.data.v2.models.MutateRowsException) RowMutationEntry(com.google.cloud.bigtable.data.v2.models.RowMutationEntry) UnavailableException(com.google.api.gax.rpc.UnavailableException) DeadlineExceededException(com.google.api.gax.rpc.DeadlineExceededException) ExecutionException(java.util.concurrent.ExecutionException) Test(org.junit.Test)

Aggregations

RowMutationEntry (com.google.cloud.bigtable.data.v2.models.RowMutationEntry)16 Test (org.junit.Test)11 ByteString (com.google.protobuf.ByteString)3 BatcherImpl (com.google.api.gax.batching.BatcherImpl)2 BigtableDataClient (com.google.cloud.bigtable.data.v2.BigtableDataClient)2 BulkMutation (com.google.cloud.bigtable.data.v2.models.BulkMutation)2 MutateRowsException (com.google.cloud.bigtable.data.v2.models.MutateRowsException)2 Row (com.google.cloud.bigtable.data.v2.models.Row)2 BulkMutationWrapper (com.google.cloud.bigtable.hbase.wrappers.BulkMutationWrapper)2 ExecutionException (java.util.concurrent.ExecutionException)2 Put (org.apache.hadoop.hbase.client.Put)2 BatchingDescriptor (com.google.api.gax.batching.BatchingDescriptor)1 BatchingSettings (com.google.api.gax.batching.BatchingSettings)1 FlowControlEventStats (com.google.api.gax.batching.FlowControlEventStats)1 FlowControlSettings (com.google.api.gax.batching.FlowControlSettings)1 GrpcCallContext (com.google.api.gax.grpc.GrpcCallContext)1 DeadlineExceededException (com.google.api.gax.rpc.DeadlineExceededException)1 UnaryCallable (com.google.api.gax.rpc.UnaryCallable)1 UnavailableException (com.google.api.gax.rpc.UnavailableException)1 Table (com.google.cloud.bigtable.admin.v2.models.Table)1