com.google.protobuf.BlockingRpcChannel Java Examples

The following examples show how to use com.google.protobuf.BlockingRpcChannel. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HBase.java    From pxf with Apache License 2.0 6 votes vote down vote up
private void grantPermissions(Table table,
                              String user, Action... actions)
        throws Exception {

    ReportUtils.report(report, getClass(), config.toString());
    ReportUtils.report(report, getClass(),"grant request for user=" + user + " table" + table);
    String hbaseAuthEnabled = config.get("hbase.security.authorization");
    if (!isAuthorizationEnabled && (hbaseAuthEnabled == null || !hbaseAuthEnabled.equals("true"))) {
        ReportUtils.report(report, getClass(),
                "HBase security authorization is not enabled, cannot grant permissions");
        return;
    }

    org.apache.hadoop.hbase.client.Table acl = connection.getTable(AccessControlLists.ACL_TABLE_NAME);
    try {
        BlockingRpcChannel service = acl.coprocessorService(HConstants.EMPTY_START_ROW);
        AccessControlProtos.AccessControlService.BlockingInterface protocol = AccessControlProtos.AccessControlService.newBlockingStub(service);
        if (table == null) {
            ProtobufUtil.grant(protocol, user, actions);
        } else {
            ProtobufUtil.grant(protocol, user, TableName.valueOf(table.getName()), null, null, actions);
        }
    } finally {
        acl.close();
    }
}
 
Example #2
Source File: BlockingRpcClient.java    From incubator-tajo with Apache License 2.0 6 votes vote down vote up
BlockingRpcClient(final Class<?> protocol,
                         final InetSocketAddress addr, ClientSocketChannelFactory factory)
    throws Exception {

  this.protocol = protocol;
  String serviceClassName = protocol.getName() + "$"
      + protocol.getSimpleName() + "Service";
  Class<?> serviceClass = Class.forName(serviceClassName);
  stubMethod = serviceClass.getMethod("newBlockingStub",
      BlockingRpcChannel.class);

  this.handler = new ClientChannelUpstreamHandler();
  pipeFactory = new ProtoPipelineFactory(handler,
      RpcResponse.getDefaultInstance());
  super.init(addr, pipeFactory, factory);
  rpcChannel = new ProxyRpcChannel();

  this.key = new RpcConnectionKey(addr, protocol, false);
}
 
Example #3
Source File: IntegrationTest.java    From protobuf-socket-rpc with MIT License 5 votes vote down vote up
private void doTest(RpcServer rpcServer) throws InterruptedException,
    ServiceException, IOException {
  BlockingRpcChannel blockingChannel = RpcChannels
      .newBlockingRpcChannel(clientConnectionFactory);
  RpcChannel channel = RpcChannels.newRpcChannel(clientConnectionFactory,
      threadPool);
  BlockingInterface blockingStub = TestService
      .newBlockingStub(blockingChannel);
  TestService stub = TestService.newStub(channel);

  try {
    rpcServer.startServer();
    Thread.sleep(500);

    doRpc(stub);
    doBlockingRpc(blockingStub);
    doBlockingRpc(blockingStub);
    doRpc(stub);
  } finally {
    Thread.sleep(500);
    System.out.println("Closing Client");
    if (clientConnectionFactory instanceof Closeable) {
      ((PersistentRpcConnectionFactory) clientConnectionFactory).close();
    }
    Thread.sleep(100);
    System.out.println("Closing Server");
    rpcServer.shutDown();
  }
}
 
Example #4
Source File: RpcChannels.java    From protobuf-socket-rpc with MIT License 4 votes vote down vote up
/**
 * Create a {@link BlockingRpcChannel} that uses the given
 * {@link RpcConnectionFactory} to connect to the RPC server.
 */
public static BlockingRpcChannel newBlockingRpcChannel(
    RpcConnectionFactory connectionFactory) {
  return new RpcChannelImpl(connectionFactory, SAME_THREAD_EXECUTOR);
}
 
Example #5
Source File: BlockingRpcClient.java    From incubator-tajo with Apache License 2.0 4 votes vote down vote up
public BlockingRpcChannel getBlockingRpcChannel() {
  return this.rpcChannel;
}