Java 类org.apache.hadoop.hbase.ipc.protobuf.generated.TestRpcServiceProtos 实例源码

项目:ditb    文件:TestCoprocessorEndpoint.java   
@Test
public void testCoprocessorError() throws Exception {
  Configuration configuration = new Configuration(util.getConfiguration());
  // Make it not retry forever
  configuration.setInt(HConstants.HBASE_CLIENT_RETRIES_NUMBER, 1);
  Table table = new HTable(configuration, TEST_TABLE);

  try {
    CoprocessorRpcChannel protocol = table.coprocessorService(ROWS[0]);

    TestRpcServiceProtos.TestProtobufRpcProto.BlockingInterface service =
        TestRpcServiceProtos.TestProtobufRpcProto.newBlockingStub(protocol);

    service.error(null, TestProtos.EmptyRequestProto.getDefaultInstance());
    fail("Should have thrown an exception");
  } catch (ServiceException e) {
  } finally {
    table.close();
  }
}
项目:ditb    文件:TestProtoBufRpc.java   
@Before
public  void setUp() throws IOException { // Setup server for both protocols
  this.conf = HBaseConfiguration.create();
  Logger log = Logger.getLogger("org.apache.hadoop.ipc.HBaseServer");
  log.setLevel(Level.DEBUG);
  log = Logger.getLogger("org.apache.hadoop.ipc.HBaseServer.trace");
  log.setLevel(Level.TRACE);
  // Create server side implementation
  PBServerImpl serverImpl = new PBServerImpl();
  BlockingService service =
    TestRpcServiceProtos.TestProtobufRpcProto.newReflectiveBlockingService(serverImpl);
  // Get RPC server for server side implementation
  this.server = new RpcServer(null, "testrpc",
      Lists.newArrayList(new RpcServer.BlockingServiceAndInterface(service, null)),
      new InetSocketAddress(ADDRESS, PORT), conf,
      new FifoRpcScheduler(conf, 10));
  InetSocketAddress address = server.getListenerAddress();
  if (address == null) {
    throw new IOException("Listener channel is closed");
  }
  this.isa = address;
  this.server.start();
}
项目:pbase    文件:TestCoprocessorEndpoint.java   
@Test
public void testCoprocessorError() throws Exception {
  Configuration configuration = new Configuration(util.getConfiguration());
  // Make it not retry forever
  configuration.setInt(HConstants.HBASE_CLIENT_RETRIES_NUMBER, 1);
  Table table = new HTable(configuration, TEST_TABLE);

  try {
    CoprocessorRpcChannel protocol = table.coprocessorService(ROWS[0]);

    TestRpcServiceProtos.TestProtobufRpcProto.BlockingInterface service =
        TestRpcServiceProtos.TestProtobufRpcProto.newBlockingStub(protocol);

    service.error(null, TestProtos.EmptyRequestProto.getDefaultInstance());
    fail("Should have thrown an exception");
  } catch (ServiceException e) {
  } finally {
    table.close();
  }
}
项目:pbase    文件:TestProtoBufRpc.java   
@Before
public  void setUp() throws IOException { // Setup server for both protocols
  this.conf = HBaseConfiguration.create();
  Logger log = Logger.getLogger("org.apache.hadoop.ipc.HBaseServer");
  log.setLevel(Level.DEBUG);
  log = Logger.getLogger("org.apache.hadoop.ipc.HBaseServer.trace");
  log.setLevel(Level.TRACE);
  // Create server side implementation
  PBServerImpl serverImpl = new PBServerImpl();
  BlockingService service =
    TestRpcServiceProtos.TestProtobufRpcProto.newReflectiveBlockingService(serverImpl);
  // Get RPC server for server side implementation
  this.server = new RpcServer(null, "testrpc",
      Lists.newArrayList(new RpcServer.BlockingServiceAndInterface(service, null)),
      new InetSocketAddress(ADDRESS, PORT), conf,
      new FifoRpcScheduler(conf, 10));
  this.isa = server.getListenerAddress();
  this.server.start();
}
项目:HIndex    文件:TestCoprocessorEndpoint.java   
@Test
public void testCoprocessorError() throws Exception {
  Configuration configuration = new Configuration(util.getConfiguration());
  // Make it not retry forever
  configuration.setInt(HConstants.HBASE_CLIENT_RETRIES_NUMBER, 1);
  HTable table = new HTable(configuration, TEST_TABLE);

  try {
    CoprocessorRpcChannel protocol = table.coprocessorService(ROWS[0]);

    TestRpcServiceProtos.TestProtobufRpcProto.BlockingInterface service =
        TestRpcServiceProtos.TestProtobufRpcProto.newBlockingStub(protocol);

    service.error(null, TestProtos.EmptyRequestProto.getDefaultInstance());
    fail("Should have thrown an exception");
  } catch (ServiceException e) {
  } finally {
    table.close();
  }
}
项目:HIndex    文件:TestProtoBufRpc.java   
@Before
public  void setUp() throws IOException { // Setup server for both protocols
  this.conf = HBaseConfiguration.create();
  Logger log = Logger.getLogger("org.apache.hadoop.ipc.HBaseServer");
  log.setLevel(Level.DEBUG);
  log = Logger.getLogger("org.apache.hadoop.ipc.HBaseServer.trace");
  log.setLevel(Level.TRACE);
  // Create server side implementation
  PBServerImpl serverImpl = new PBServerImpl();
  BlockingService service =
    TestRpcServiceProtos.TestProtobufRpcProto.newReflectiveBlockingService(serverImpl);
  // Get RPC server for server side implementation
  this.server = new RpcServer(null, "testrpc",
      Lists.newArrayList(new RpcServer.BlockingServiceAndInterface(service, null)),
      new InetSocketAddress(ADDRESS, PORT), conf,
      new FifoRpcScheduler(conf, 10));
  this.isa = server.getListenerAddress();
  this.server.start();
}
项目:hbase    文件:TestCoprocessorEndpoint.java   
@Test
public void testCoprocessorError() throws Exception {
  Configuration configuration = new Configuration(util.getConfiguration());
  // Make it not retry forever
  configuration.setInt(HConstants.HBASE_CLIENT_RETRIES_NUMBER, 1);
  Table table = util.getConnection().getTable(TEST_TABLE);

  try {
    CoprocessorRpcChannel protocol = table.coprocessorService(ROWS[0]);

    TestRpcServiceProtos.TestProtobufRpcProto.BlockingInterface service =
        TestRpcServiceProtos.TestProtobufRpcProto.newBlockingStub(protocol);

    service.error(null, TestProtos.EmptyRequestProto.getDefaultInstance());
    fail("Should have thrown an exception");
  } catch (ServiceException e) {
  } finally {
    table.close();
  }
}
项目:PyroDB    文件:TestCoprocessorEndpoint.java   
@Test
public void testCoprocessorError() throws Exception {
  Configuration configuration = new Configuration(util.getConfiguration());
  // Make it not retry forever
  configuration.setInt(HConstants.HBASE_CLIENT_RETRIES_NUMBER, 1);
  HTable table = new HTable(configuration, TEST_TABLE);

  try {
    CoprocessorRpcChannel protocol = table.coprocessorService(ROWS[0]);

    TestRpcServiceProtos.TestProtobufRpcProto.BlockingInterface service =
        TestRpcServiceProtos.TestProtobufRpcProto.newBlockingStub(protocol);

    service.error(null, TestProtos.EmptyRequestProto.getDefaultInstance());
    fail("Should have thrown an exception");
  } catch (ServiceException e) {
  } finally {
    table.close();
  }
}
项目:PyroDB    文件:TestProtoBufRpc.java   
@Before
public  void setUp() throws IOException { // Setup server for both protocols
  this.conf = HBaseConfiguration.create();
  Logger log = Logger.getLogger("org.apache.hadoop.ipc.HBaseServer");
  log.setLevel(Level.DEBUG);
  log = Logger.getLogger("org.apache.hadoop.ipc.HBaseServer.trace");
  log.setLevel(Level.TRACE);
  // Create server side implementation
  PBServerImpl serverImpl = new PBServerImpl();
  BlockingService service =
    TestRpcServiceProtos.TestProtobufRpcProto.newReflectiveBlockingService(serverImpl);
  // Get RPC server for server side implementation
  this.server = new RpcServer(null, "testrpc",
      Lists.newArrayList(new RpcServer.BlockingServiceAndInterface(service, null)),
      new InetSocketAddress(ADDRESS, PORT), conf,
      new FifoRpcScheduler(conf, 10));
  this.isa = server.getListenerAddress();
  this.server.start();
}
项目:c5    文件:TestCoprocessorEndpoint.java   
@Test
public void testCoprocessorError() throws Exception {
  Configuration configuration = new Configuration(util.getConfiguration());
  // Make it not retry forever
  configuration.setInt(HConstants.HBASE_CLIENT_RETRIES_NUMBER, 1);
  HTable table = new HTable(configuration, TEST_TABLE);

  try {
    CoprocessorRpcChannel protocol = table.coprocessorService(ROWS[0]);

    TestRpcServiceProtos.TestProtobufRpcProto.BlockingInterface service =
        TestRpcServiceProtos.TestProtobufRpcProto.newBlockingStub(protocol);

    service.error(null, TestProtos.EmptyRequestProto.getDefaultInstance());
    fail("Should have thrown an exception");
  } catch (ServiceException e) {
  } finally {
    table.close();
  }
}
项目:c5    文件:TestProtoBufRpc.java   
@Before
public  void setUp() throws IOException { // Setup server for both protocols
  this.conf = HBaseConfiguration.create();
  Logger log = Logger.getLogger("org.apache.hadoop.ipc.HBaseServer");
  log.setLevel(Level.DEBUG);
  log = Logger.getLogger("org.apache.hadoop.ipc.HBaseServer.trace");
  log.setLevel(Level.TRACE);
  // Create server side implementation
  PBServerImpl serverImpl = new PBServerImpl();
  BlockingService service =
    TestRpcServiceProtos.TestProtobufRpcProto.newReflectiveBlockingService(serverImpl);
  // Get RPC server for server side implementation
  this.server = new RpcServer(null, "testrpc",
      Lists.newArrayList(new RpcServer.BlockingServiceAndInterface(service, null)),
      new InetSocketAddress(ADDRESS, PORT), 10, 10, conf, 0);
  this.isa = server.getListenerAddress();
  this.server.start();
}
项目:ditb    文件:TestCoprocessorEndpoint.java   
@Test
public void testMasterCoprocessorService() throws Throwable {
  Admin admin = util.getHBaseAdmin();
  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());
}
项目:ditb    文件:TestCoprocessorEndpoint.java   
@Test
public void testMasterCoprocessorError() throws Throwable {
  Admin admin = util.getHBaseAdmin();
  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) {
  }
}
项目:ditb    文件:TestProtoBufRpc.java   
@Test
public void testProtoBufRpc() throws Exception {
  RpcClient rpcClient = RpcClientFactory.createClient(conf, HConstants.CLUSTER_ID_DEFAULT);
  try {
    BlockingRpcChannel channel = rpcClient.createBlockingRpcChannel(
        ServerName.valueOf(this.isa.getHostName(), this.isa.getPort(), System.currentTimeMillis()),
      User.getCurrent(), 0);
    TestRpcServiceProtos.TestProtobufRpcProto.BlockingInterface stub =
      TestRpcServiceProtos.TestProtobufRpcProto.newBlockingStub(channel);
    // Test ping method
    TestProtos.EmptyRequestProto emptyRequest =
      TestProtos.EmptyRequestProto.newBuilder().build();
    stub.ping(null, emptyRequest);

    // Test echo method
    EchoRequestProto echoRequest = EchoRequestProto.newBuilder().setMessage("hello").build();
    EchoResponseProto echoResponse = stub.echo(null, echoRequest);
    Assert.assertEquals(echoResponse.getMessage(), "hello");

    // Test error method - error should be thrown as RemoteException
    try {
      stub.error(null, emptyRequest);
      Assert.fail("Expected exception is not thrown");
    } catch (ServiceException e) {
    }
  } finally {
    rpcClient.close();
  }
}
项目:ditb    文件:AbstractTestIPC.java   
/**
 * Tests that the RpcServer creates & dispatches CallRunner object to scheduler with non-null
 * remoteAddress set to its Call Object
 * @throws ServiceException
 */
@Test
public void testRpcServerForNotNullRemoteAddressInCallObject() throws IOException,
    ServiceException {
  final RpcScheduler scheduler = new FifoRpcScheduler(CONF, 1);
  final TestRpcServer1 rpcServer = new TestRpcServer1(scheduler);
  final InetSocketAddress localAddr = new InetSocketAddress("localhost", 0);
  final AbstractRpcClient client =
      new RpcClientImpl(CONF, HConstants.CLUSTER_ID_DEFAULT, localAddr, null);
  try {
    rpcServer.start();
    final InetSocketAddress isa = rpcServer.getListenerAddress();
    if (isa == null) {
      throw new IOException("Listener channel is closed");
    }
    final BlockingRpcChannel channel =
        client.createBlockingRpcChannel(
          ServerName.valueOf(isa.getHostName(), isa.getPort(), System.currentTimeMillis()),
          User.getCurrent(), 0);
    TestRpcServiceProtos.TestProtobufRpcProto.BlockingInterface stub =
        TestRpcServiceProtos.TestProtobufRpcProto.newBlockingStub(channel);
    final EchoRequestProto echoRequest =
        EchoRequestProto.newBuilder().setMessage("GetRemoteAddress").build();
    final EchoResponseProto echoResponse = stub.echo(null, echoRequest);
    Assert.assertEquals(localAddr.getAddress().getHostAddress(), echoResponse.getMessage());
  } finally {
    client.close();
    rpcServer.stop();
  }
}
项目:pbase    文件:TestCoprocessorEndpoint.java   
@Test
public void testMasterCoprocessorService() throws Throwable {
  Admin admin = util.getHBaseAdmin();
  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());
}
项目:pbase    文件:TestCoprocessorEndpoint.java   
@Test
public void testMasterCoprocessorError() throws Throwable {
  Admin admin = util.getHBaseAdmin();
  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) {
  }
}
项目:pbase    文件:TestProtoBufRpc.java   
@Test
public void testProtoBufRpc() throws Exception {
  RpcClient rpcClient = RpcClientFactory.createClient(conf, HConstants.CLUSTER_ID_DEFAULT);
  try {
    BlockingRpcChannel channel = rpcClient.createBlockingRpcChannel(
        ServerName.valueOf(this.isa.getHostName(), this.isa.getPort(), System.currentTimeMillis()),
      User.getCurrent(), 0);
    TestRpcServiceProtos.TestProtobufRpcProto.BlockingInterface stub =
      TestRpcServiceProtos.TestProtobufRpcProto.newBlockingStub(channel);
    // Test ping method
    TestProtos.EmptyRequestProto emptyRequest =
      TestProtos.EmptyRequestProto.newBuilder().build();
    stub.ping(null, emptyRequest);

    // Test echo method
    EchoRequestProto echoRequest = EchoRequestProto.newBuilder().setMessage("hello").build();
    EchoResponseProto echoResponse = stub.echo(null, echoRequest);
    Assert.assertEquals(echoResponse.getMessage(), "hello");

    // Test error method - error should be thrown as RemoteException
    try {
      stub.error(null, emptyRequest);
      Assert.fail("Expected exception is not thrown");
    } catch (ServiceException e) {
    }
  } finally {
    rpcClient.close();
  }
}
项目:HIndex    文件:TestCoprocessorEndpoint.java   
@Test
public void testMasterCoprocessorService() throws Throwable {
  HBaseAdmin admin = util.getHBaseAdmin();
  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());
}
项目:HIndex    文件:TestCoprocessorEndpoint.java   
@Test
public void testMasterCoprocessorError() throws Throwable {
  HBaseAdmin admin = util.getHBaseAdmin();
  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) {
  }
}
项目:HIndex    文件:TestProtoBufRpc.java   
@Test
public void testProtoBufRpc() throws Exception {
  RpcClient rpcClient = new RpcClient(conf, HConstants.CLUSTER_ID_DEFAULT);
  try {
    BlockingRpcChannel channel = rpcClient.createBlockingRpcChannel(
        ServerName.valueOf(this.isa.getHostName(), this.isa.getPort(), System.currentTimeMillis()),
      User.getCurrent(), 0);
    TestRpcServiceProtos.TestProtobufRpcProto.BlockingInterface stub =
      TestRpcServiceProtos.TestProtobufRpcProto.newBlockingStub(channel);
    // Test ping method
    TestProtos.EmptyRequestProto emptyRequest =
      TestProtos.EmptyRequestProto.newBuilder().build();
    stub.ping(null, emptyRequest);

    // Test echo method
    EchoRequestProto echoRequest = EchoRequestProto.newBuilder().setMessage("hello").build();
    EchoResponseProto echoResponse = stub.echo(null, echoRequest);
    Assert.assertEquals(echoResponse.getMessage(), "hello");

    // Test error method - error should be thrown as RemoteException
    try {
      stub.error(null, emptyRequest);
      Assert.fail("Expected exception is not thrown");
    } catch (ServiceException e) {
    }
  } finally {
    rpcClient.stop();
  }
}
项目:hbase    文件:TestCoprocessorEndpoint.java   
@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());
}
项目:hbase    文件:TestCoprocessorEndpoint.java   
@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) {
  }
}
项目:hbase    文件:TestAsyncCoprocessorEndpoint.java   
@Test
public void testMasterCoprocessorService() throws Exception {
  TestProtos.EchoRequestProto request =
      TestProtos.EchoRequestProto.newBuilder().setMessage("hello").build();
  TestProtos.EchoResponseProto response =
      admin
          .<TestRpcServiceProtos.TestProtobufRpcProto.Stub, TestProtos.EchoResponseProto> coprocessorService(
            TestRpcServiceProtos.TestProtobufRpcProto::newStub,
            (s, c, done) -> s.echo(c, request, done)).get();
  assertEquals("hello", response.getMessage());
}
项目:hbase    文件:TestAsyncCoprocessorEndpoint.java   
@Test
public void testMasterCoprocessorError() throws Exception {
  TestProtos.EmptyRequestProto emptyRequest = TestProtos.EmptyRequestProto.getDefaultInstance();
  try {
    admin
        .<TestRpcServiceProtos.TestProtobufRpcProto.Stub, TestProtos.EmptyResponseProto> coprocessorService(
          TestRpcServiceProtos.TestProtobufRpcProto::newStub,
          (s, c, done) -> s.error(c, emptyRequest, done)).get();
    fail("Should have thrown an exception");
  } catch (Exception e) {
  }
}
项目:PyroDB    文件:TestCoprocessorEndpoint.java   
@Test
public void testMasterCoprocessorService() throws Throwable {
  HBaseAdmin admin = util.getHBaseAdmin();
  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());
}
项目:PyroDB    文件:TestCoprocessorEndpoint.java   
@Test
public void testMasterCoprocessorError() throws Throwable {
  HBaseAdmin admin = util.getHBaseAdmin();
  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) {
  }
}
项目:PyroDB    文件:TestProtoBufRpc.java   
@Test
public void testProtoBufRpc() throws Exception {
  RpcClient rpcClient = new RpcClient(conf, HConstants.CLUSTER_ID_DEFAULT);
  try {
    BlockingRpcChannel channel = rpcClient.createBlockingRpcChannel(
        ServerName.valueOf(this.isa.getHostName(), this.isa.getPort(), System.currentTimeMillis()),
      User.getCurrent(), 0);
    TestRpcServiceProtos.TestProtobufRpcProto.BlockingInterface stub =
      TestRpcServiceProtos.TestProtobufRpcProto.newBlockingStub(channel);
    // Test ping method
    TestProtos.EmptyRequestProto emptyRequest =
      TestProtos.EmptyRequestProto.newBuilder().build();
    stub.ping(null, emptyRequest);

    // Test echo method
    EchoRequestProto echoRequest = EchoRequestProto.newBuilder().setMessage("hello").build();
    EchoResponseProto echoResponse = stub.echo(null, echoRequest);
    Assert.assertEquals(echoResponse.getMessage(), "hello");

    // Test error method - error should be thrown as RemoteException
    try {
      stub.error(null, emptyRequest);
      Assert.fail("Expected exception is not thrown");
    } catch (ServiceException e) {
    }
  } finally {
    rpcClient.stop();
  }
}
项目:c5    文件:TestCoprocessorEndpoint.java   
@Test
public void testMasterCoprocessorService() throws Throwable {
  HBaseAdmin admin = util.getHBaseAdmin();
  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());
}
项目:c5    文件:TestCoprocessorEndpoint.java   
@Test
public void testMasterCoprocessorError() throws Throwable {
  HBaseAdmin admin = util.getHBaseAdmin();
  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) {
  }
}
项目:c5    文件:TestProtoBufRpc.java   
@Test
public void testProtoBufRpc() throws Exception {
  RpcClient rpcClient = new RpcClient(conf, HConstants.CLUSTER_ID_DEFAULT);
  try {
    BlockingRpcChannel channel = rpcClient.createBlockingRpcChannel(
        ServerName.valueOf(this.isa.getHostName(), this.isa.getPort(), System.currentTimeMillis()),
      User.getCurrent(), 0);
    TestRpcServiceProtos.TestProtobufRpcProto.BlockingInterface stub =
      TestRpcServiceProtos.TestProtobufRpcProto.newBlockingStub(channel);
    // Test ping method
    TestProtos.EmptyRequestProto emptyRequest =
      TestProtos.EmptyRequestProto.newBuilder().build();
    stub.ping(null, emptyRequest);

    // Test echo method
    EchoRequestProto echoRequest = EchoRequestProto.newBuilder().setMessage("hello").build();
    EchoResponseProto echoResponse = stub.echo(null, echoRequest);
    Assert.assertEquals(echoResponse.getMessage(), "hello");

    // Test error method - error should be thrown as RemoteException
    try {
      stub.error(null, emptyRequest);
      Assert.fail("Expected exception is not thrown");
    } catch (ServiceException e) {
    }
  } finally {
    rpcClient.stop();
  }
}
项目:DominoHBase    文件:TestCoprocessorEndpoint.java   
@Test
public void testMasterCoprocessorService() throws Throwable {
  HBaseAdmin admin = util.getHBaseAdmin();
  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());
  admin.close();
}
项目:ditb    文件:TestSecureRPC.java   
private void callRpcService(Class<? extends RpcClient> rpcImplClass, User clientUser,
                            Configuration clientConf, boolean allowInsecureFallback)
    throws Exception {
  Configuration clientConfCopy = new Configuration(clientConf);
  clientConfCopy.set(RpcClientFactory.CUSTOM_RPC_CLIENT_IMPL_CONF_KEY, rpcImplClass.getName());

  Configuration conf = getSecuredConfiguration();
  conf.setBoolean(RpcServer.FALLBACK_TO_INSECURE_CLIENT_AUTH, allowInsecureFallback);

  SecurityInfo securityInfoMock = Mockito.mock(SecurityInfo.class);
  Mockito.when(securityInfoMock.getServerPrincipal())
      .thenReturn(HBaseKerberosUtils.KRB_PRINCIPAL);
  SecurityInfo.addInfo("TestProtobufRpcProto", securityInfoMock);

  InetSocketAddress isa = new InetSocketAddress(HOST, 0);

  RpcServerInterface rpcServer =
      new RpcServer(null, "AbstractTestSecureIPC",
          Lists.newArrayList(new RpcServer.BlockingServiceAndInterface(SERVICE, null)), isa,
          conf, new FifoRpcScheduler(conf, 1));
  rpcServer.start();
  try (RpcClient rpcClient = RpcClientFactory.createClient(clientConf,
      HConstants.DEFAULT_CLUSTER_ID.toString())) {
    InetSocketAddress address = rpcServer.getListenerAddress();
    if (address == null) {
      throw new IOException("Listener channel is closed");
    }
    BlockingRpcChannel channel =
        rpcClient.createBlockingRpcChannel(

          ServerName.valueOf(address.getHostName(), address.getPort(),
          System.currentTimeMillis()), clientUser, 5000);
    TestRpcServiceProtos.TestProtobufRpcProto.BlockingInterface stub =
        TestRpcServiceProtos.TestProtobufRpcProto.newBlockingStub(channel);
    List<String> results = new ArrayList<String>();
    TestThread th1 = new TestThread(stub, results);
    th1.start();
    th1.join();

  } finally {
    rpcServer.stop();
  }
}
项目:ditb    文件:TestSecureRPC.java   
public TestThread(TestRpcServiceProtos.TestProtobufRpcProto.BlockingInterface stub, List<String> results) {
  this.stub = stub;
  this.results = results;
}
项目:ditb    文件:AbstractTestIPC.java   
TestRpcServer1(RpcScheduler scheduler) throws IOException {
  super(null, "testRemoteAddressInCallObject", Lists
      .newArrayList(new BlockingServiceAndInterface(TestRpcServiceProtos.TestProtobufRpcProto
          .newReflectiveBlockingService(SERVICE1), null)),
      new InetSocketAddress("localhost", 0), CONF, scheduler);
}