org.apache.hadoop.hbase.client.Admin.coprocessorService()方法的使用及代码示例

x33g5p2x  于2022-01-15 转载在 其他  
字(13.0k)|赞(0)|评价(0)|浏览(148)

本文整理了Java中org.apache.hadoop.hbase.client.Admin.coprocessorService()方法的一些代码示例,展示了Admin.coprocessorService()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Admin.coprocessorService()方法的具体详情如下:
包路径:org.apache.hadoop.hbase.client.Admin
类名称:Admin
方法名:coprocessorService

Admin.coprocessorService介绍

[英]Creates and returns a com.facebook.presto.hbase.$internal.com.google.protobuf.RpcChannel instance connected to the active master.

The obtained com.facebook.presto.hbase.$internal.com.google.protobuf.RpcChannel instance can be used to access a published coprocessor com.facebook.presto.hbase.$internal.com.google.protobuf.Service using standard protobuf service invocations:

CoprocessorRpcChannel channel = myAdmin.coprocessorService(); 
MyService.BlockingInterface service = MyService.newBlockingStub(channel); 
MyCallRequest request = MyCallRequest.newBuilder() 
... 
.build(); 
MyCallResponse response = service.myCall(null, request);

[中]创建并返回一个com。脸谱网。急板地。hbase$内部的通用域名格式。谷歌。protobuf。已连接到活动主机的RPC通道实例。
获得的com。脸谱网。急板地。hbase$内部的通用域名格式。谷歌。protobuf。RpcChannel实例可用于访问已发布的协处理器com。脸谱网。急板地。hbase$内部的通用域名格式。谷歌。protobuf。使用标准protobuf服务调用的服务:

CoprocessorRpcChannel channel = myAdmin.coprocessorService(); 
MyService.BlockingInterface service = MyService.newBlockingStub(channel); 
MyCallRequest request = MyCallRequest.newBuilder() 
... 
.build(); 
MyCallResponse response = service.myCall(null, request);

代码示例

代码示例来源:origin: apache/hbase

public RSGroupAdminClient(Connection conn) throws IOException {
 admin = conn.getAdmin();
 stub = RSGroupAdminService.newBlockingStub(admin.coprocessorService());
}

代码示例来源:origin: apache/hbase

@Test
public void testMasterCoprocessorError() throws Throwable {
 Admin admin = util.getAdmin();
 TestRpcServiceProtos.TestProtobufRpcProto.BlockingInterface service =
   TestRpcServiceProtos.TestProtobufRpcProto.newBlockingStub(admin.coprocessorService());
 try {
  service.error(null, TestProtos.EmptyRequestProto.getDefaultInstance());
  fail("Should have thrown an exception");
 } catch (ServiceException e) {
 }
}

代码示例来源:origin: apache/hbase

@Test
public void testEndpointExceptions() throws Exception {
 final ServerName serverName = TEST_UTIL.getHBaseCluster().getRegionServer(0).getServerName();
 final ServerRpcController controller = new ServerRpcController();
 final CoprocessorRpcUtils.BlockingRpcCallback<DummyRegionServerEndpointProtos.DummyResponse>
   rpcCallback = new CoprocessorRpcUtils.BlockingRpcCallback<>();
 DummyRegionServerEndpointProtos.DummyService service =
   ProtobufUtil.newServiceStub(DummyRegionServerEndpointProtos.DummyService.class,
     TEST_UTIL.getAdmin().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());
}

代码示例来源:origin: apache/hbase

@Test
public void testExecService() throws Exception {
 Action action = (admin) -> {
  TestRpcServiceProtos.TestProtobufRpcProto.BlockingInterface service =
    TestRpcServiceProtos.TestProtobufRpcProto.newBlockingStub(admin.coprocessorService());
  service.ping(null, TestProtos.EmptyRequestProto.getDefaultInstance());
 };
 verifyAllowed(USER_ADMIN, action);
 verifyAllowed(USER_GROUP_ADMIN, action);
 // This is same as above verifyAccessDenied
 verifiedDeniedServiceException(USER_NON_ADMIN, action);
}

代码示例来源:origin: apache/hbase

@Test
public void testMasterCoprocessorService() throws Throwable {
 Admin admin = util.getAdmin();
 final TestProtos.EchoRequestProto request =
   TestProtos.EchoRequestProto.newBuilder().setMessage("hello").build();
 TestRpcServiceProtos.TestProtobufRpcProto.BlockingInterface service =
   TestRpcServiceProtos.TestProtobufRpcProto.newBlockingStub(admin.coprocessorService());
 assertEquals("hello", service.echo(null, request).getMessage());
}

代码示例来源:origin: apache/hbase

@Test
public void testExecRegionServerService() throws Exception {
 Action action = (admin) -> {
  ServerName serverName = TEST_UTIL.getHBaseCluster().getRegionServer(0).getServerName();
  TestRpcServiceProtos.TestProtobufRpcProto.BlockingInterface service =
    TestRpcServiceProtos.TestProtobufRpcProto.newBlockingStub(
      admin.coprocessorService(serverName));
  service.ping(null, TestProtos.EmptyRequestProto.getDefaultInstance());
 };
 verifyAllowed(USER_ADMIN, action);
 verifyAllowed(USER_GROUP_ADMIN, action);
 verifiedDeniedServiceException(USER_NON_ADMIN, action);
}

代码示例来源:origin: apache/hbase

@Test
 public void testCoprocessorServiceLoadedByMaster() throws Throwable {
  TEST_UTIL.getAdmin().coprocessorService().callBlockingMethod(
      DummyCoprocessorService.getDescriptor().findMethodByName("dummyCall"), null,
      DummyRequest.newBuilder().setValue(MASTER).build(), DummyResponse.getDefaultInstance());
  assertEquals(MASTER, DummyCoprocessorService.numMaster);

  TEST_UTIL.getAdmin().coprocessorService(
    TEST_UTIL.getHBaseCluster().getRegionServer(0).getServerName()).callBlockingMethod(
      DummyCoprocessorService.getDescriptor().findMethodByName("dummyCall"), null,
      DummyRequest.newBuilder().setValue(REGIONSERVER).build(),
      DummyResponse.getDefaultInstance());
  assertEquals(REGIONSERVER, DummyCoprocessorService.numRegionServer);

  TEST_UTIL.getConnection().getTable(TableName.valueOf("hbase:meta")).batchCoprocessorService(
    DummyCoprocessorService.getDescriptor().findMethodByName("dummyCall"),
    DummyRequest.newBuilder().setValue(REGION).build(), Bytes.toBytes(""), Bytes.toBytes(""),
    DummyResponse.getDefaultInstance());
  assertEquals(REGION, DummyCoprocessorService.numRegion);
 }
}

代码示例来源:origin: apache/hbase

@Test
public void testEndpoint() throws Exception {
 final ServerName serverName = TEST_UTIL.getHBaseCluster().getRegionServer(0).getServerName();
 final ServerRpcController controller = new ServerRpcController();
 final CoprocessorRpcUtils.BlockingRpcCallback<DummyRegionServerEndpointProtos.DummyResponse>
   rpcCallback = new CoprocessorRpcUtils.BlockingRpcCallback<>();
 DummyRegionServerEndpointProtos.DummyService service =
   ProtobufUtil.newServiceStub(DummyRegionServerEndpointProtos.DummyService.class,
    TEST_UTIL.getAdmin().coprocessorService(serverName));
 service.dummyCall(controller,
   DummyRegionServerEndpointProtos.DummyRequest.getDefaultInstance(), rpcCallback);
 assertEquals(DUMMY_VALUE, rpcCallback.get().getValue());
 if (controller.failedOnException()) {
  throw controller.getFailedOn();
 }
}

代码示例来源:origin: org.apache.hbase/hbase-rsgroup

public RSGroupAdminClient(Connection conn) throws IOException {
 stub = RSGroupAdminService.newBlockingStub(conn.getAdmin().coprocessorService());
}

代码示例来源:origin: com.aliyun.hbase/alihbase-rsgroup

public RSGroupAdminClient(Connection conn) throws IOException {
 stub = RSGroupAdminService.newBlockingStub(conn.getAdmin().coprocessorService());
}

代码示例来源:origin: org.apache.hbase/hbase-endpoint

@Test
public void testMasterCoprocessorError() throws Throwable {
 Admin admin = util.getAdmin();
 TestRpcServiceProtos.TestProtobufRpcProto.BlockingInterface service =
   TestRpcServiceProtos.TestProtobufRpcProto.newBlockingStub(admin.coprocessorService());
 try {
  service.error(null, TestProtos.EmptyRequestProto.getDefaultInstance());
  fail("Should have thrown an exception");
 } catch (ServiceException e) {
 }
}

代码示例来源:origin: com.aliyun.hbase/alihbase-endpoint

@Test
public void testMasterCoprocessorError() throws Throwable {
 Admin admin = util.getAdmin();
 TestRpcServiceProtos.TestProtobufRpcProto.BlockingInterface service =
   TestRpcServiceProtos.TestProtobufRpcProto.newBlockingStub(admin.coprocessorService());
 try {
  service.error(null, TestProtos.EmptyRequestProto.getDefaultInstance());
  fail("Should have thrown an exception");
 } catch (ServiceException e) {
 }
}

代码示例来源:origin: org.apache.hbase/hbase-endpoint

@Test
public void testEndpointExceptions() throws Exception {
 final ServerName serverName = TEST_UTIL.getHBaseCluster().getRegionServer(0).getServerName();
 final ServerRpcController controller = new ServerRpcController();
 final CoprocessorRpcUtils.BlockingRpcCallback<DummyRegionServerEndpointProtos.DummyResponse>
   rpcCallback = new CoprocessorRpcUtils.BlockingRpcCallback<>();
 DummyRegionServerEndpointProtos.DummyService service =
   ProtobufUtil.newServiceStub(DummyRegionServerEndpointProtos.DummyService.class,
     TEST_UTIL.getAdmin().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());
}

代码示例来源:origin: com.aliyun.hbase/alihbase-endpoint

@Test
public void testEndpointExceptions() throws Exception {
 final ServerName serverName = TEST_UTIL.getHBaseCluster().getRegionServer(0).getServerName();
 final ServerRpcController controller = new ServerRpcController();
 final CoprocessorRpcUtils.BlockingRpcCallback<DummyRegionServerEndpointProtos.DummyResponse>
   rpcCallback = new CoprocessorRpcUtils.BlockingRpcCallback<>();
 DummyRegionServerEndpointProtos.DummyService service =
   ProtobufUtil.newServiceStub(DummyRegionServerEndpointProtos.DummyService.class,
     TEST_UTIL.getAdmin().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());
}

代码示例来源:origin: org.apache.hbase/hbase-server

@Test
public void testExecService() throws Exception {
 Action action = (admin) -> {
  TestRpcServiceProtos.TestProtobufRpcProto.BlockingInterface service =
    TestRpcServiceProtos.TestProtobufRpcProto.newBlockingStub(admin.coprocessorService());
  service.ping(null, TestProtos.EmptyRequestProto.getDefaultInstance());
 };
 verifyAllowed(USER_ADMIN, action);
 verifyAllowed(USER_GROUP_ADMIN, action);
 // This is same as above verifyAccessDenied
 verifiedDeniedServiceException(USER_NON_ADMIN, action);
}

代码示例来源:origin: org.apache.hbase/hbase-endpoint

@Test
public void testMasterCoprocessorService() throws Throwable {
 Admin admin = util.getAdmin();
 final TestProtos.EchoRequestProto request =
   TestProtos.EchoRequestProto.newBuilder().setMessage("hello").build();
 TestRpcServiceProtos.TestProtobufRpcProto.BlockingInterface service =
   TestRpcServiceProtos.TestProtobufRpcProto.newBlockingStub(admin.coprocessorService());
 assertEquals("hello", service.echo(null, request).getMessage());
}

代码示例来源:origin: com.aliyun.hbase/alihbase-endpoint

@Test
public void testMasterCoprocessorService() throws Throwable {
 Admin admin = util.getAdmin();
 final TestProtos.EchoRequestProto request =
   TestProtos.EchoRequestProto.newBuilder().setMessage("hello").build();
 TestRpcServiceProtos.TestProtobufRpcProto.BlockingInterface service =
   TestRpcServiceProtos.TestProtobufRpcProto.newBlockingStub(admin.coprocessorService());
 assertEquals("hello", service.echo(null, request).getMessage());
}

代码示例来源:origin: org.apache.hbase/hbase-server

@Test
public void testExecRegionServerService() throws Exception {
 Action action = (admin) -> {
  ServerName serverName = TEST_UTIL.getHBaseCluster().getRegionServer(0).getServerName();
  TestRpcServiceProtos.TestProtobufRpcProto.BlockingInterface service =
    TestRpcServiceProtos.TestProtobufRpcProto.newBlockingStub(
      admin.coprocessorService(serverName));
  service.ping(null, TestProtos.EmptyRequestProto.getDefaultInstance());
 };
 verifyAllowed(USER_ADMIN, action);
 verifyAllowed(USER_GROUP_ADMIN, action);
 verifiedDeniedServiceException(USER_NON_ADMIN, action);
}

代码示例来源:origin: org.apache.hbase/hbase-endpoint

@Test
public void testEndpoint() throws Exception {
 final ServerName serverName = TEST_UTIL.getHBaseCluster().getRegionServer(0).getServerName();
 final ServerRpcController controller = new ServerRpcController();
 final CoprocessorRpcUtils.BlockingRpcCallback<DummyRegionServerEndpointProtos.DummyResponse>
   rpcCallback = new CoprocessorRpcUtils.BlockingRpcCallback<>();
 DummyRegionServerEndpointProtos.DummyService service =
   ProtobufUtil.newServiceStub(DummyRegionServerEndpointProtos.DummyService.class,
    TEST_UTIL.getAdmin().coprocessorService(serverName));
 service.dummyCall(controller,
   DummyRegionServerEndpointProtos.DummyRequest.getDefaultInstance(), rpcCallback);
 assertEquals(DUMMY_VALUE, rpcCallback.get().getValue());
 if (controller.failedOnException()) {
  throw controller.getFailedOn();
 }
}

代码示例来源:origin: com.aliyun.hbase/alihbase-endpoint

@Test
public void testEndpoint() throws Exception {
 final ServerName serverName = TEST_UTIL.getHBaseCluster().getRegionServer(0).getServerName();
 final ServerRpcController controller = new ServerRpcController();
 final CoprocessorRpcUtils.BlockingRpcCallback<DummyRegionServerEndpointProtos.DummyResponse>
   rpcCallback = new CoprocessorRpcUtils.BlockingRpcCallback<>();
 DummyRegionServerEndpointProtos.DummyService service =
   ProtobufUtil.newServiceStub(DummyRegionServerEndpointProtos.DummyService.class,
    TEST_UTIL.getAdmin().coprocessorService(serverName));
 service.dummyCall(controller,
   DummyRegionServerEndpointProtos.DummyRequest.getDefaultInstance(), rpcCallback);
 assertEquals(DUMMY_VALUE, rpcCallback.get().getValue());
 if (controller.failedOnException()) {
  throw controller.getFailedOn();
 }
}

相关文章

Admin类方法