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);
}
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));
}
Aggregations