Search in sources :

Example 1 with SampleRowKeysRequest

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()));
}
Also used : HRegionInfo(org.apache.hadoop.hbase.HRegionInfo) SampleRowKeysRequest(com.google.bigtable.v2.SampleRowKeysRequest) Test(org.junit.Test)

Example 2 with SampleRowKeysRequest

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());
}
Also used : SampleRowKeysResponse(com.google.bigtable.v2.SampleRowKeysResponse) SampleRowKeysRequest(com.google.bigtable.v2.SampleRowKeysRequest) List(java.util.List) ImmutableList(com.google.common.collect.ImmutableList)

Example 3 with SampleRowKeysRequest

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));
}
Also used : SampleRowKeysResponse(com.google.bigtable.v2.SampleRowKeysResponse) HeaderTracerUnaryCallable(com.google.cloud.bigtable.data.v2.stub.metrics.HeaderTracerUnaryCallable) SampleRowKeysRequest(com.google.bigtable.v2.SampleRowKeysRequest) List(java.util.List) ImmutableList(com.google.common.collect.ImmutableList) 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)

Aggregations

SampleRowKeysRequest (com.google.bigtable.v2.SampleRowKeysRequest)3 SampleRowKeysResponse (com.google.bigtable.v2.SampleRowKeysResponse)2 ImmutableList (com.google.common.collect.ImmutableList)2 List (java.util.List)2 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 ByteString (com.google.protobuf.ByteString)1 Map (java.util.Map)1 HRegionInfo (org.apache.hadoop.hbase.HRegionInfo)1 Test (org.junit.Test)1