Java Code Examples for

The following examples show how to use These examples are extracted from open source projects. 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 Project: pxf   Source File:    License: Apache License 2.0 6 votes vote down vote up
private void grantPermissions(Table table,
                              String user, Action... actions)
        throws Exception {, getClass(), config.toString());, getClass(),"grant request for user=" + user + " table" + table);
    String hbaseAuthEnabled = config.get("");
    if (!isAuthorizationEnabled && (hbaseAuthEnabled == null || !hbaseAuthEnabled.equals("true"))) {, getClass(),
                "HBase security authorization is not enabled, cannot grant permissions");

    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 {
Example 2
Source Project: incubator-tajo   Source File:    License: 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",

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

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

  try {

  } finally {
    System.out.println("Closing Client");
    if (clientConnectionFactory instanceof Closeable) {
      ((PersistentRpcConnectionFactory) clientConnectionFactory).close();
    System.out.println("Closing Server");
Example 4
Source Project: protobuf-socket-rpc   Source File:    License: 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 Project: incubator-tajo   Source File:    License: Apache License 2.0 4 votes vote down vote up
public BlockingRpcChannel getBlockingRpcChannel() {
  return this.rpcChannel;