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


Java HTableDescriptor.getOwnerString方法代码示例

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


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

示例1: postModifyTable

import org.apache.hadoop.hbase.HTableDescriptor; //导入方法依赖的package包/类
@Override
public void postModifyTable(ObserverContext<MasterCoprocessorEnvironment> c,
    TableName tableName, final HTableDescriptor htd) throws IOException {
  final Configuration conf = c.getEnvironment().getConfiguration();
  // default the table owner to current user, if not specified.
  final String owner = (htd.getOwnerString() != null) ? htd.getOwnerString() :
    getActiveUser().getShortName();
  User.runAsLoginUser(new PrivilegedExceptionAction<Void>() {
    @Override
    public Void run() throws Exception {
      UserPermission userperm = new UserPermission(Bytes.toBytes(owner),
        htd.getTableName(), null, Action.values());
      AccessControlLists.addUserPermission(conf, userperm);
      return null;
    }
  });
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:18,代码来源:AccessController.java

示例2: postCreateTableHandler

import org.apache.hadoop.hbase.HTableDescriptor; //导入方法依赖的package包/类
@Override
public void postCreateTableHandler(final ObserverContext<MasterCoprocessorEnvironment> c,
    HTableDescriptor desc, HRegionInfo[] regions) throws IOException {
  // When AC is used, it should be configured as the 1st CP.
  // In Master, the table operations like create, are handled by a Thread pool but the max size
  // for this pool is 1. So if multiple CPs create tables on startup, these creations will happen
  // sequentially only.
  // Related code in HMaster#startServiceThreads
  // {code}
  //   // We depend on there being only one instance of this executor running
  //   // at a time. To do concurrency, would need fencing of enable/disable of
  //   // tables.
  //   this.service.startExecutorService(ExecutorType.MASTER_TABLE_OPERATIONS, 1);
  // {code}
  // In future if we change this pool to have more threads, then there is a chance for thread,
  // creating acl table, getting delayed and by that time another table creation got over and
  // this hook is getting called. In such a case, we will need a wait logic here which will
  // wait till the acl table is created.
  if (AccessControlLists.isAclTable(desc)) {
    this.aclTabAvailable = true;
  } else if (!(TableName.NAMESPACE_TABLE_NAME.equals(desc.getTableName()))) {
    if (!aclTabAvailable) {
      LOG.warn("Not adding owner permission for table " + desc.getTableName() + ". "
          + AccessControlLists.ACL_TABLE_NAME + " is not yet created. "
          + getClass().getSimpleName() + " should be configured as the first Coprocessor");
    } else {
      String owner = desc.getOwnerString();
      // default the table owner to current user, if not specified.
      if (owner == null)
        owner = getActiveUser().getShortName();
      final UserPermission userperm = new UserPermission(Bytes.toBytes(owner),
          desc.getTableName(), null, Action.values());
      // switch to the real hbase master user for doing the RPC on the ACL table
      User.runAsLoginUser(new PrivilegedExceptionAction<Void>() {
        @Override
        public Void run() throws Exception {
          AccessControlLists.addUserPermission(c.getEnvironment().getConfiguration(),
              userperm);
          return null;
        }
      });
    }
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:45,代码来源:AccessController.java


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