Search in sources :

Example 11 with RowMutation

use of com.google.cloud.bigtable.data.v2.models.RowMutation in project java-bigtable-hbase by googleapis.

the class TestDeleteAdapter method adapt.

private MutateRowRequest adapt(Delete delete) {
    RowMutation rowMutation = RowMutation.create(TABLE_ID, ByteString.copyFrom(delete.getRow()));
    deleteAdapter.adapt(delete, rowMutation);
    return rowMutation.toProto(REQUEST_CONTEXT);
}
Also used : RowMutation(com.google.cloud.bigtable.data.v2.models.RowMutation)

Example 12 with RowMutation

use of com.google.cloud.bigtable.data.v2.models.RowMutation in project java-bigtable-hbase by googleapis.

the class TestDataClientVeneerApi method testMutateRowAsync.

@Test
public void testMutateRowAsync() throws Exception {
    RowMutation rowMutation = RowMutation.create(TABLE_ID, ROW_KEY);
    when(mockDataClient.mutateRowAsync(rowMutation)).thenReturn(ApiFutures.<Void>immediateFuture(null));
    dataClientWrapper.mutateRowAsync(rowMutation).get();
    verify(mockDataClient).mutateRowAsync(rowMutation);
}
Also used : RowMutation(com.google.cloud.bigtable.data.v2.models.RowMutation) ConditionalRowMutation(com.google.cloud.bigtable.data.v2.models.ConditionalRowMutation) Test(org.junit.Test)

Example 13 with RowMutation

use of com.google.cloud.bigtable.data.v2.models.RowMutation in project java-bigtable by googleapis.

the class EnhancedBigtableStub method createMutateRowCallable.

/**
 * Creates a callable chain to handle MutateRow RPCs. The chain will:
 *
 * <ul>
 *   <li>Convert a {@link RowMutation} into a {@link com.google.bigtable.v2.MutateRowRequest}.
 *   <li>Add tracing & metrics.
 * </ul>
 */
private UnaryCallable<RowMutation, Void> createMutateRowCallable() {
    String methodName = "MutateRow";
    UnaryCallable<MutateRowRequest, MutateRowResponse> base = GrpcRawCallableFactory.createUnaryCallable(GrpcCallSettings.<MutateRowRequest, MutateRowResponse>newBuilder().setMethodDescriptor(BigtableGrpc.getMutateRowMethod()).setParamsExtractor(new RequestParamsExtractor<MutateRowRequest>() {

        @Override
        public Map<String, String> extract(MutateRowRequest mutateRowRequest) {
            return ImmutableMap.of("table_name", mutateRowRequest.getTableName(), "app_profile_id", mutateRowRequest.getAppProfileId());
        }
    }).build(), settings.mutateRowSettings().getRetryableCodes());
    UnaryCallable<MutateRowRequest, MutateRowResponse> withStatsHeaders = new StatsHeadersUnaryCallable<>(base);
    UnaryCallable<MutateRowRequest, MutateRowResponse> withHeaderTracer = new HeaderTracerUnaryCallable<>(withStatsHeaders);
    UnaryCallable<MutateRowRequest, MutateRowResponse> retrying = Callables.retrying(withHeaderTracer, settings.mutateRowSettings(), clientContext);
    return createUserFacingUnaryCallable(methodName, new MutateRowCallable(retrying, requestContext));
}
Also used : MutateRowRequest(com.google.bigtable.v2.MutateRowRequest) CheckAndMutateRowRequest(com.google.bigtable.v2.CheckAndMutateRowRequest) CheckAndMutateRowResponse(com.google.bigtable.v2.CheckAndMutateRowResponse) MutateRowResponse(com.google.bigtable.v2.MutateRowResponse) HeaderTracerUnaryCallable(com.google.cloud.bigtable.data.v2.stub.metrics.HeaderTracerUnaryCallable) StatsHeadersUnaryCallable(com.google.cloud.bigtable.data.v2.stub.metrics.StatsHeadersUnaryCallable) ByteString(com.google.protobuf.ByteString) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap)

Example 14 with RowMutation

use of com.google.cloud.bigtable.data.v2.models.RowMutation in project java-bigtable by googleapis.

the class BigtableDataClientTest method proxyMutateRowTest.

@Test
public void proxyMutateRowTest() {
    Mockito.when(mockStub.mutateRowCallable()).thenReturn(mockMutateRowCallable);
    RowMutation request = RowMutation.create("fake-table", "some-key").setCell("some-family", "fake-qualifier", "fake-value");
    bigtableDataClient.mutateRowAsync(request);
    Mockito.verify(mockMutateRowCallable).futureCall(request);
}
Also used : RowMutation(com.google.cloud.bigtable.data.v2.models.RowMutation) ConditionalRowMutation(com.google.cloud.bigtable.data.v2.models.ConditionalRowMutation) Test(org.junit.Test)

Example 15 with RowMutation

use of com.google.cloud.bigtable.data.v2.models.RowMutation in project java-bigtable by googleapis.

the class MutateRowCallableTest method testRequestConversion.

@Test
public void testRequestConversion() {
    MutateRowCallable callable = new MutateRowCallable(innerCallable, REQUEST_CONTEXT);
    RowMutation outerRequest = RowMutation.create("fake-table", "fake-key").setCell("fake-family", "fake-qualifier", 1_000, "fake-value");
    innerResult.set(MutateRowResponse.getDefaultInstance());
    callable.call(outerRequest);
    Truth.assertThat(innerMutation.getValue()).isEqualTo(outerRequest.toProto(REQUEST_CONTEXT));
}
Also used : RowMutation(com.google.cloud.bigtable.data.v2.models.RowMutation) Test(org.junit.Test)

Aggregations

RowMutation (com.google.cloud.bigtable.data.v2.models.RowMutation)23 ByteString (com.google.protobuf.ByteString)8 Test (org.junit.Test)7 ConditionalRowMutation (com.google.cloud.bigtable.data.v2.models.ConditionalRowMutation)5 RowMutationEntry (com.google.cloud.bigtable.data.v2.models.RowMutationEntry)5 MutateRowRequest (com.google.bigtable.v2.MutateRowRequest)3 ApiFuture (com.google.api.core.ApiFuture)2 UnaryCallable (com.google.api.gax.rpc.UnaryCallable)2 BigtableDataClient (com.google.cloud.bigtable.data.v2.BigtableDataClient)2 ApiFutures (com.google.api.core.ApiFutures)1 Batcher (com.google.api.gax.batching.Batcher)1 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 NotFoundException (com.google.api.gax.rpc.NotFoundException)1 ResponseObserver (com.google.api.gax.rpc.ResponseObserver)1 ServerStreamingCallable (com.google.api.gax.rpc.ServerStreamingCallable)1 CheckAndMutateRowRequest (com.google.bigtable.v2.CheckAndMutateRowRequest)1 CheckAndMutateRowResponse (com.google.bigtable.v2.CheckAndMutateRowResponse)1