use of com.google.cloud.bigtable.data.v2.models.KeyOffset in project java-bigtable-hbase by googleapis.
the class TestAbstractBigtableConnection method testRegionLocator.
@Test
public void testRegionLocator() throws IOException {
assertEquals(1, connection.getAllRegionInfos(TABLE_NAME).size());
assertEquals(regionInfo, connection.getAllRegionInfos(TABLE_NAME).get(0));
List<HRegionLocation> expectedRegionLocations = ImmutableList.of(new HRegionLocation(regionInfo, ServerName.valueOf(HOST_NAME, server.getPort(), 0)));
when(mockSampledAdapter.adaptResponse(Mockito.<List<KeyOffset>>any())).thenReturn(expectedRegionLocations);
RegionLocator regionLocator = connection.getRegionLocator(TABLE_NAME);
assertEquals(expectedRegionLocations, regionLocator.getAllRegionLocations());
}
use of com.google.cloud.bigtable.data.v2.models.KeyOffset 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