Search in sources :

Example 11 with ReadModifyWriteRowRequest

use of com.google.bigtable.v2.ReadModifyWriteRowRequest in project java-bigtable by googleapis.

the class ReadModifyWriteRowTest method fromProtoTest.

@Test
public void fromProtoTest() {
    ReadModifyWriteRow expected = ReadModifyWriteRow.create(TABLE_ID, "row-key").increment("fake-family", ByteString.copyFromUtf8("fake-qualifier"), 1).append("fake-family", "fake-qualifier", "fake-value");
    ReadModifyWriteRowRequest protoRequest = expected.toProto(REQUEST_CONTEXT);
    ReadModifyWriteRow actualRequest = ReadModifyWriteRow.fromProto(protoRequest);
    assertThat(actualRequest.toProto(REQUEST_CONTEXT)).isEqualTo(protoRequest);
    String projectId = "fresh-project";
    String instanceId = "fresh-instance";
    String appProfile = "fresh-app-profile";
    ReadModifyWriteRowRequest overriddenRequest = actualRequest.toProto(RequestContext.create(projectId, instanceId, appProfile));
    assertThat(overriddenRequest).isNotEqualTo(protoRequest);
    assertThat(overriddenRequest.getTableName()).matches(NameUtil.formatTableName(projectId, instanceId, TABLE_ID));
    assertThat(overriddenRequest.getAppProfileId()).matches(appProfile);
}
Also used : ReadModifyWriteRowRequest(com.google.bigtable.v2.ReadModifyWriteRowRequest) ByteString(com.google.protobuf.ByteString) Test(org.junit.Test)

Example 12 with ReadModifyWriteRowRequest

use of com.google.bigtable.v2.ReadModifyWriteRowRequest in project java-bigtable by googleapis.

the class EnhancedBigtableStub method createReadModifyWriteRowCallable.

/**
 * Creates a callable chain to handle ReadModifyWriteRow RPCs. The chain will:
 *
 * <ul>
 *   <li>Convert {@link ReadModifyWriteRow}s into {@link
 *       com.google.bigtable.v2.ReadModifyWriteRowRequest}s.
 *   <li>Convert the responses into {@link Row}.
 *   <li>Add tracing & metrics.
 * </ul>
 */
private UnaryCallable<ReadModifyWriteRow, Row> createReadModifyWriteRowCallable() {
    UnaryCallable<ReadModifyWriteRowRequest, ReadModifyWriteRowResponse> base = GrpcRawCallableFactory.createUnaryCallable(GrpcCallSettings.<ReadModifyWriteRowRequest, ReadModifyWriteRowResponse>newBuilder().setMethodDescriptor(BigtableGrpc.getReadModifyWriteRowMethod()).setParamsExtractor(new RequestParamsExtractor<ReadModifyWriteRowRequest>() {

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

Aggregations

ReadModifyWriteRowRequest (com.google.bigtable.v2.ReadModifyWriteRowRequest)12 Test (org.junit.Test)11 ReadModifyWriteRow (com.google.cloud.bigtable.data.v2.models.ReadModifyWriteRow)8 ReadModifyWriteRule (com.google.bigtable.v2.ReadModifyWriteRule)6 ByteString (com.google.protobuf.ByteString)4 Append (org.apache.hadoop.hbase.client.Append)4 Increment (org.apache.hadoop.hbase.client.Increment)4 ReadModifyWriteRowResponse (com.google.bigtable.v2.ReadModifyWriteRowResponse)1 HeaderTracerUnaryCallable (com.google.cloud.bigtable.data.v2.stub.metrics.HeaderTracerUnaryCallable)1 StatsHeadersUnaryCallable (com.google.cloud.bigtable.data.v2.stub.metrics.StatsHeadersUnaryCallable)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 Map (java.util.Map)1