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


Java ProtobufUtil.toIOException方法代码示例

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


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

示例1: checkTablePerms

import org.apache.hadoop.hbase.protobuf.ProtobufUtil; //导入方法依赖的package包/类
public static void checkTablePerms(Configuration conf, TableName table, Permission... perms)
throws IOException {
  CheckPermissionsRequest.Builder request = CheckPermissionsRequest.newBuilder();
  for (Permission p : perms) {
    request.addPermission(ProtobufUtil.toPermission(p));
  }
  try (Connection connection = ConnectionFactory.createConnection(conf)) {
    try (Table acl = connection.getTable(table)) {
      AccessControlService.BlockingInterface protocol =
          AccessControlService.newBlockingStub(acl.coprocessorService(new byte[0]));
      try {
        protocol.checkPermissions(null, request.build());
      } catch (ServiceException se) {
        ProtobufUtil.toIOException(se);
      }
    }
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:19,代码来源:SecureTestUtil.java

示例2: checkGlobalPerms

import org.apache.hadoop.hbase.protobuf.ProtobufUtil; //导入方法依赖的package包/类
public static void checkGlobalPerms(HBaseTestingUtility testUtil, Permission.Action... actions)
    throws IOException {
  Permission[] perms = new Permission[actions.length];
  for (int i = 0; i < actions.length; i++) {
    perms[i] = new Permission(actions[i]);
  }
  CheckPermissionsRequest.Builder request = CheckPermissionsRequest.newBuilder();
  for (Action a : actions) {
    request.addPermission(AccessControlProtos.Permission.newBuilder()
        .setType(AccessControlProtos.Permission.Type.Global)
        .setGlobalPermission(
            AccessControlProtos.GlobalPermission.newBuilder()
                .addAction(ProtobufUtil.toPermissionAction(a)).build()));
  }
  try(Connection conn = ConnectionFactory.createConnection(testUtil.getConfiguration());
      Table acl = conn.getTable(AccessControlLists.ACL_TABLE_NAME)) {
    BlockingRpcChannel channel = acl.coprocessorService(new byte[0]);
    AccessControlService.BlockingInterface protocol =
      AccessControlService.newBlockingStub(channel);
    try {
      protocol.checkPermissions(null, request.build());
    } catch (ServiceException se) {
      ProtobufUtil.toIOException(se);
    }
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:27,代码来源:SecureTestUtil.java

示例3: obtainToken

import org.apache.hadoop.hbase.protobuf.ProtobufUtil; //导入方法依赖的package包/类
/**
 * Obtain and return an authentication token for the current user.
 * @param conn The HBase cluster connection
 * @return the authentication token instance
 */
public static Token<AuthenticationTokenIdentifier> obtainToken(
    Connection conn) throws IOException {
  Table meta = null;
  try {
    meta = conn.getTable(TableName.META_TABLE_NAME);
    CoprocessorRpcChannel rpcChannel = meta.coprocessorService(HConstants.EMPTY_START_ROW);
    AuthenticationProtos.AuthenticationService.BlockingInterface service =
        AuthenticationProtos.AuthenticationService.newBlockingStub(rpcChannel);
    AuthenticationProtos.GetAuthenticationTokenResponse response = service.getAuthenticationToken(null,
        AuthenticationProtos.GetAuthenticationTokenRequest.getDefaultInstance());

    return ProtobufUtil.toToken(response.getToken());
  } catch (ServiceException se) {
    ProtobufUtil.toIOException(se);
  } finally {
    if (meta != null) {
      meta.close();
    }
  }
  // dummy return for ServiceException block
  return null;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:28,代码来源:TokenUtil.java

示例4: multiMutate

import org.apache.hadoop.hbase.protobuf.ProtobufUtil; //导入方法依赖的package包/类
/**
 * Performs an atomic multi-Mutate operation against the given table.
 */
private static void multiMutate(Table table, byte[] row, Mutation... mutations)
    throws IOException {
  CoprocessorRpcChannel channel = table.coprocessorService(row);
  MultiRowMutationProtos.MutateRowsRequest.Builder mmrBuilder
    = MultiRowMutationProtos.MutateRowsRequest.newBuilder();
  for (Mutation mutation : mutations) {
    if (mutation instanceof Put) {
      mmrBuilder.addMutationRequest(ProtobufUtil.toMutation(
        ClientProtos.MutationProto.MutationType.PUT, mutation));
    } else if (mutation instanceof Delete) {
      mmrBuilder.addMutationRequest(ProtobufUtil.toMutation(
        ClientProtos.MutationProto.MutationType.DELETE, mutation));
    } else {
      throw new DoNotRetryIOException("multi in MetaEditor doesn't support "
        + mutation.getClass().getName());
    }
  }

  MultiRowMutationProtos.MultiRowMutationService.BlockingInterface service =
    MultiRowMutationProtos.MultiRowMutationService.newBlockingStub(channel);
  try {
    service.mutateRows(null, mmrBuilder.build());
  } catch (ServiceException ex) {
    ProtobufUtil.toIOException(ex);
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:30,代码来源:MetaTableAccessor.java


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