當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。