use of com.google.bigtable.v2.SampleRowKeysRequest in project java-bigtable-hbase by googleapis.
the class TestBigtableConnection method testAllRegions.
@Test
public void testAllRegions() throws IOException, InterruptedException {
List<HRegionInfo> regionInfoList = connection.getAllRegionInfos(TABLE_NAME);
SampleRowKeysRequest request = fakeDataService.popLastRequest();
assertEquals(FULL_TABLE_NAME, request.getTableName());
assertEquals("", Bytes.toString(regionInfoList.get(0).getStartKey()));
assertEquals("rowKey", Bytes.toString(regionInfoList.get(0).getEndKey()));
}
use of com.google.bigtable.v2.SampleRowKeysRequest in project java-bigtable by googleapis.
the class SampleRowKeysCallable method futureCall.
@Override
public ApiFuture<List<KeyOffset>> futureCall(String tableId, ApiCallContext context) {
String tableName = NameUtil.formatTableName(requestContext.getProjectId(), requestContext.getInstanceId(), tableId);
SampleRowKeysRequest request = SampleRowKeysRequest.newBuilder().setTableName(tableName).setAppProfileId(requestContext.getAppProfileId()).build();
ApiFuture<List<SampleRowKeysResponse>> rawResponse = inner.futureCall(request, context);
return ApiFutures.transform(rawResponse, new ApiFunction<List<SampleRowKeysResponse>, List<KeyOffset>>() {
@Override
public List<KeyOffset> apply(List<SampleRowKeysResponse> rawResponse) {
return convert(rawResponse);
}
}, MoreExecutors.directExecutor());
}
use of com.google.bigtable.v2.SampleRowKeysRequest in project java-bigtable by googleapis.
the class EnhancedBigtableStub method createSampleRowKeysCallable.
/**
* Creates a callable chain to handle SampleRowKeys RPcs. The chain will:
*
* <ul>
* <li>Convert a table id to a {@link com.google.bigtable.v2.SampleRowKeysRequest}.
* <li>Dispatch the request to the GAPIC's {@link BigtableStub#sampleRowKeysCallable()}.
* <li>Spool responses into a list.
* <li>Retry on failure.
* <li>Convert the responses into {@link KeyOffset}s.
* <li>Add tracing & metrics.
* </ul>
*/
private UnaryCallable<String, List<KeyOffset>> createSampleRowKeysCallable() {
String methodName = "SampleRowKeys";
ServerStreamingCallable<SampleRowKeysRequest, SampleRowKeysResponse> base = GrpcRawCallableFactory.createServerStreamingCallable(GrpcCallSettings.<SampleRowKeysRequest, SampleRowKeysResponse>newBuilder().setMethodDescriptor(BigtableGrpc.getSampleRowKeysMethod()).setParamsExtractor(new RequestParamsExtractor<SampleRowKeysRequest>() {
@Override
public Map<String, String> extract(SampleRowKeysRequest sampleRowKeysRequest) {
return ImmutableMap.of("table_name", sampleRowKeysRequest.getTableName(), "app_profile_id", sampleRowKeysRequest.getAppProfileId());
}
}).build(), settings.sampleRowKeysSettings().getRetryableCodes());
UnaryCallable<SampleRowKeysRequest, List<SampleRowKeysResponse>> spoolable = base.all();
UnaryCallable<SampleRowKeysRequest, List<SampleRowKeysResponse>> withStatsHeaders = new StatsHeadersUnaryCallable<>(spoolable);
UnaryCallable<SampleRowKeysRequest, List<SampleRowKeysResponse>> withHeaderTracer = new HeaderTracerUnaryCallable<>(withStatsHeaders);
UnaryCallable<SampleRowKeysRequest, List<SampleRowKeysResponse>> retryable = Callables.retrying(withHeaderTracer, settings.sampleRowKeysSettings(), clientContext);
return createUserFacingUnaryCallable(methodName, new SampleRowKeysCallable(retryable, requestContext));
}
Aggregations