当前位置: 首页>>代码示例>>Java>>正文


Java ProtobufUtil.newServiceStub方法代码示例

本文整理汇总了Java中org.apache.hadoop.hbase.protobuf.ProtobufUtil.newServiceStub方法的典型用法代码示例。如果您正苦于以下问题:Java ProtobufUtil.newServiceStub方法的具体用法?Java ProtobufUtil.newServiceStub怎么用?Java ProtobufUtil.newServiceStub使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.hadoop.hbase.protobuf.ProtobufUtil的用法示例。


在下文中一共展示了ProtobufUtil.newServiceStub方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testEndpoint

import org.apache.hadoop.hbase.protobuf.ProtobufUtil; //导入方法依赖的package包/类
@Test
public void testEndpoint() throws Exception {
  final ServerName serverName = TEST_UTIL.getHBaseCluster().getRegionServer(0).getServerName();
  final ServerRpcController controller = new ServerRpcController();
  final BlockingRpcCallback<DummyRegionServerEndpointProtos.DummyResponse> rpcCallback =
      new BlockingRpcCallback<DummyRegionServerEndpointProtos.DummyResponse>();
  DummyRegionServerEndpointProtos.DummyService service =
      ProtobufUtil.newServiceStub(DummyRegionServerEndpointProtos.DummyService.class,
          TEST_UTIL.getHBaseAdmin().coprocessorService(serverName));
  service.dummyCall(controller,
      DummyRegionServerEndpointProtos.DummyRequest.getDefaultInstance(), rpcCallback);
  assertEquals(DUMMY_VALUE, rpcCallback.get().getValue());
  if (controller.failedOnException()) {
    throw controller.getFailedOn();
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:17,代码来源:TestRegionServerCoprocessorEndpoint.java

示例2: testEndpointExceptions

import org.apache.hadoop.hbase.protobuf.ProtobufUtil; //导入方法依赖的package包/类
@Test
public void testEndpointExceptions() throws Exception {
  final ServerName serverName = TEST_UTIL.getHBaseCluster().getRegionServer(0).getServerName();
  final ServerRpcController controller = new ServerRpcController();
  final BlockingRpcCallback<DummyRegionServerEndpointProtos.DummyResponse> rpcCallback =
      new BlockingRpcCallback<DummyRegionServerEndpointProtos.DummyResponse>();
  DummyRegionServerEndpointProtos.DummyService service =
      ProtobufUtil.newServiceStub(DummyRegionServerEndpointProtos.DummyService.class,
          TEST_UTIL.getHBaseAdmin().coprocessorService(serverName));
  service.dummyThrow(controller,
      DummyRegionServerEndpointProtos.DummyRequest.getDefaultInstance(), rpcCallback);
  assertEquals(null, rpcCallback.get());
  assertTrue(controller.failedOnException());
  assertEquals(WHAT_TO_THROW.getClass().getName().trim(),
      ((RemoteWithExtrasException) controller.getFailedOn().getCause()).getClassName().trim());
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:17,代码来源:TestRegionServerCoprocessorEndpoint.java

示例3: cleanupBulkLoad

import org.apache.hadoop.hbase.protobuf.ProtobufUtil; //导入方法依赖的package包/类
public void cleanupBulkLoad(final String bulkToken) throws IOException {
  try {
    CoprocessorRpcChannel channel = table.coprocessorService(HConstants.EMPTY_START_ROW);
    SecureBulkLoadProtos.SecureBulkLoadService instance =
        ProtobufUtil.newServiceStub(SecureBulkLoadProtos.SecureBulkLoadService.class, channel);

    ServerRpcController controller = new ServerRpcController();

    BlockingRpcCallback<SecureBulkLoadProtos.CleanupBulkLoadResponse> rpcCallback =
        new BlockingRpcCallback<SecureBulkLoadProtos.CleanupBulkLoadResponse>();

    SecureBulkLoadProtos.CleanupBulkLoadRequest request =
        SecureBulkLoadProtos.CleanupBulkLoadRequest.newBuilder()
            .setBulkToken(bulkToken).build();

    instance.cleanupBulkLoad(controller,
        request,
        rpcCallback);

    if (controller.failedOnException()) {
      throw controller.getFailedOn();
    }
  } catch (Throwable throwable) {
    throw new IOException(throwable);
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:27,代码来源:SecureBulkLoadClient.java

示例4: prepareBulkLoad

import org.apache.hadoop.hbase.protobuf.ProtobufUtil; //导入方法依赖的package包/类
public String prepareBulkLoad(final TableName tableName) throws IOException {
  try {
    CoprocessorRpcChannel channel = table.coprocessorService(HConstants.EMPTY_START_ROW);
    SecureBulkLoadProtos.SecureBulkLoadService instance =
        ProtobufUtil.newServiceStub(SecureBulkLoadProtos.SecureBulkLoadService.class, channel);

    ServerRpcController controller = new ServerRpcController();

    BlockingRpcCallback<SecureBulkLoadProtos.PrepareBulkLoadResponse> rpcCallback =
        new BlockingRpcCallback<SecureBulkLoadProtos.PrepareBulkLoadResponse>();

    SecureBulkLoadProtos.PrepareBulkLoadRequest request =
        SecureBulkLoadProtos.PrepareBulkLoadRequest.newBuilder()
        .setTableName(ProtobufUtil.toProtoTableName(tableName)).build();

    instance.prepareBulkLoad(controller,
        request,
        rpcCallback);

    SecureBulkLoadProtos.PrepareBulkLoadResponse response = rpcCallback.get();
    if (controller.failedOnException()) {
      throw controller.getFailedOn();
    }

    return response.getBulkToken();
  } catch (Throwable throwable) {
    throw new IOException(throwable);
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:30,代码来源:SecureBulkLoadClient.java

示例5: bulkLoadHFiles

import org.apache.hadoop.hbase.protobuf.ProtobufUtil; //导入方法依赖的package包/类
public boolean bulkLoadHFiles(final List<Pair<byte[], String>> familyPaths,
                       final Token<?> userToken,
                       final String bulkToken,
                       final byte[] startRow) throws IOException {
  // we never want to send a batch of HFiles to all regions, thus cannot call
  // HTable#coprocessorService methods that take start and end rowkeys; see HBASE-9639
  try {
    CoprocessorRpcChannel channel = table.coprocessorService(startRow);
    SecureBulkLoadProtos.SecureBulkLoadService instance =
        ProtobufUtil.newServiceStub(SecureBulkLoadProtos.SecureBulkLoadService.class, channel);

    SecureBulkLoadProtos.DelegationToken protoDT =
        SecureBulkLoadProtos.DelegationToken.newBuilder().build();
    if(userToken != null) {
      protoDT =
          SecureBulkLoadProtos.DelegationToken.newBuilder()
            .setIdentifier(ByteStringer.wrap(userToken.getIdentifier()))
            .setPassword(ByteStringer.wrap(userToken.getPassword()))
            .setKind(userToken.getKind().toString())
            .setService(userToken.getService().toString()).build();
    }

    List<ClientProtos.BulkLoadHFileRequest.FamilyPath> protoFamilyPaths =
        new ArrayList<ClientProtos.BulkLoadHFileRequest.FamilyPath>();
    for(Pair<byte[], String> el: familyPaths) {
      protoFamilyPaths.add(ClientProtos.BulkLoadHFileRequest.FamilyPath.newBuilder()
        .setFamily(ByteStringer.wrap(el.getFirst()))
        .setPath(el.getSecond()).build());
    }

    SecureBulkLoadProtos.SecureBulkLoadHFilesRequest request =
        SecureBulkLoadProtos.SecureBulkLoadHFilesRequest.newBuilder()
          .setFsToken(protoDT)
          .addAllFamilyPath(protoFamilyPaths)
          .setBulkToken(bulkToken).build();

    ServerRpcController controller = new ServerRpcController();
    BlockingRpcCallback<SecureBulkLoadProtos.SecureBulkLoadHFilesResponse> rpcCallback =
        new BlockingRpcCallback<SecureBulkLoadProtos.SecureBulkLoadHFilesResponse>();
    instance.secureBulkLoadHFiles(controller,
      request,
      rpcCallback);

    SecureBulkLoadProtos.SecureBulkLoadHFilesResponse response = rpcCallback.get();
    if (controller.failedOnException()) {
      throw controller.getFailedOn();
    }
    return response.getLoaded();
  } catch (Throwable throwable) {
    throw new IOException(throwable);
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:53,代码来源:SecureBulkLoadClient.java


注:本文中的org.apache.hadoop.hbase.protobuf.ProtobufUtil.newServiceStub方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。