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


Java MasterCoprocessorEnvironment类代码示例

本文整理汇总了Java中org.apache.hadoop.hbase.coprocessor.MasterCoprocessorEnvironment的典型用法代码示例。如果您正苦于以下问题:Java MasterCoprocessorEnvironment类的具体用法?Java MasterCoprocessorEnvironment怎么用?Java MasterCoprocessorEnvironment使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


MasterCoprocessorEnvironment类属于org.apache.hadoop.hbase.coprocessor包,在下文中一共展示了MasterCoprocessorEnvironment类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: postStartMaster

import org.apache.hadoop.hbase.coprocessor.MasterCoprocessorEnvironment; //导入依赖的package包/类
/********************************* Master related hooks **********************************/

  @Override
  public void postStartMaster(ObserverContext<MasterCoprocessorEnvironment> ctx) throws IOException {
    // Need to create the new system table for labels here
    MasterServices master = ctx.getEnvironment().getMasterServices();
    if (!MetaTableAccessor.tableExists(master.getConnection(), LABELS_TABLE_NAME)) {
      HTableDescriptor labelsTable = new HTableDescriptor(LABELS_TABLE_NAME);
      HColumnDescriptor labelsColumn = new HColumnDescriptor(LABELS_TABLE_FAMILY);
      labelsColumn.setBloomFilterType(BloomType.NONE);
      labelsColumn.setBlockCacheEnabled(false); // We will cache all the labels. No need of normal
                                                 // table block cache.
      labelsTable.addFamily(labelsColumn);
      // Let the "labels" table having only one region always. We are not expecting too many labels in
      // the system.
      labelsTable.setValue(HTableDescriptor.SPLIT_POLICY,
          DisabledRegionSplitPolicy.class.getName());
      labelsTable.setValue(Bytes.toBytes(HConstants.DISALLOW_WRITES_IN_RECOVERING),
          Bytes.toBytes(true));
      master.createTable(labelsTable, null, HConstants.NO_NONCE, HConstants.NO_NONCE);
    }
  }
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:23,代码来源:VisibilityController.java

示例2: start

import org.apache.hadoop.hbase.coprocessor.MasterCoprocessorEnvironment; //导入依赖的package包/类
@Override
public void start(CoprocessorEnvironment env) throws IOException {
  this.conf = env.getConfiguration();

  authorizationEnabled = isAuthorizationSupported(conf);
  if (!authorizationEnabled) {
    LOG.warn("The VisibilityController has been loaded with authorization checks disabled.");
  }

  if (HFile.getFormatVersion(conf) < HFile.MIN_FORMAT_VERSION_WITH_TAGS) {
    throw new RuntimeException("A minimum HFile version of " + HFile.MIN_FORMAT_VERSION_WITH_TAGS
      + " is required to persist visibility labels. Consider setting " + HFile.FORMAT_VERSION_KEY
      + " accordingly.");
  }

  if (env instanceof RegionServerCoprocessorEnvironment) {
    throw new RuntimeException("Visibility controller should not be configured as "
        + "'hbase.coprocessor.regionserver.classes'.");
  }
  // Do not create for master CPs
  if (!(env instanceof MasterCoprocessorEnvironment)) {
    visibilityLabelService = VisibilityLabelServiceManager.getInstance()
        .getVisibilityLabelService(this.conf);
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:26,代码来源:VisibilityController.java

示例3: preTruncateTable

import org.apache.hadoop.hbase.coprocessor.MasterCoprocessorEnvironment; //导入依赖的package包/类
@Override
public void preTruncateTable(ObserverContext<MasterCoprocessorEnvironment> c,
    final TableName tableName) throws IOException {
  requirePermission("truncateTable", tableName, null, null, Action.ADMIN, Action.CREATE);

  final Configuration conf = c.getEnvironment().getConfiguration();
  User.runAsLoginUser(new PrivilegedExceptionAction<Void>() {
    @Override
    public Void run() throws Exception {
      List<UserPermission> acls = AccessControlLists.getUserTablePermissions(conf, tableName);
      if (acls != null) {
        tableAcls.put(tableName, acls);
      }
      return null;
    }
  });
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:18,代码来源:AccessController.java

示例4: postTruncateTable

import org.apache.hadoop.hbase.coprocessor.MasterCoprocessorEnvironment; //导入依赖的package包/类
@Override
public void postTruncateTable(ObserverContext<MasterCoprocessorEnvironment> ctx,
    final TableName tableName) throws IOException {
  final Configuration conf = ctx.getEnvironment().getConfiguration();
  User.runAsLoginUser(new PrivilegedExceptionAction<Void>() {
    @Override
    public Void run() throws Exception {
      List<UserPermission> perms = tableAcls.get(tableName);
      if (perms != null) {
        for (UserPermission perm : perms) {
          AccessControlLists.addUserPermission(conf, perm);
        }
      }
      tableAcls.remove(tableName);
      return null;
    }
  });
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:19,代码来源:AccessController.java

示例5: postModifyTable

import org.apache.hadoop.hbase.coprocessor.MasterCoprocessorEnvironment; //导入依赖的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

示例6: postListProcedures

import org.apache.hadoop.hbase.coprocessor.MasterCoprocessorEnvironment; //导入依赖的package包/类
@Override
public void postListProcedures(
    ObserverContext<MasterCoprocessorEnvironment> ctx,
    List<ProcedureInfo> procInfoList) throws IOException {
  if (procInfoList.isEmpty()) {
    return;
  }

  // Retains only those which passes authorization checks, as the checks weren't done as part
  // of preListProcedures.
  Iterator<ProcedureInfo> itr = procInfoList.iterator();
  User user = getActiveUser();
  while (itr.hasNext()) {
    ProcedureInfo procInfo = itr.next();
    try {
      if (!ProcedureInfo.isProcedureOwner(procInfo, user)) {
        // If the user is not the procedure owner, then we should further probe whether
        // he can see the procedure.
        requirePermission("listProcedures", Action.ADMIN);
      }
    } catch (AccessDeniedException e) {
      itr.remove();
    }
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:26,代码来源:AccessController.java

示例7: preGetTableDescriptors

import org.apache.hadoop.hbase.coprocessor.MasterCoprocessorEnvironment; //导入依赖的package包/类
@Override
public void preGetTableDescriptors(ObserverContext<MasterCoprocessorEnvironment> ctx,
     List<TableName> tableNamesList, List<HTableDescriptor> descriptors,
     String regex) throws IOException {
  // We are delegating the authorization check to postGetTableDescriptors as we don't have
  // any concrete set of table names when a regex is present or the full list is requested.
  if (regex == null && tableNamesList != null && !tableNamesList.isEmpty()) {
    // Otherwise, if the requestor has ADMIN or CREATE privs for all listed tables, the
    // request can be granted.
    MasterServices masterServices = ctx.getEnvironment().getMasterServices();
    for (TableName tableName: tableNamesList) {
      // Skip checks for a table that does not exist
      if (masterServices.getTableDescriptors().get(tableName) == null) {
        continue;
      }
      requirePermission("getTableDescriptors", tableName, null, null,
          Action.ADMIN, Action.CREATE);
    }
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:21,代码来源:AccessController.java

示例8: postGetTableDescriptors

import org.apache.hadoop.hbase.coprocessor.MasterCoprocessorEnvironment; //导入依赖的package包/类
@Override
public void postGetTableDescriptors(ObserverContext<MasterCoprocessorEnvironment> ctx,
    List<TableName> tableNamesList, List<HTableDescriptor> descriptors,
    String regex) throws IOException {
  // Skipping as checks in this case are already done by preGetTableDescriptors.
  if (regex == null && tableNamesList != null && !tableNamesList.isEmpty()) {
    return;
  }

  // Retains only those which passes authorization checks, as the checks weren't done as part
  // of preGetTableDescriptors.
  Iterator<HTableDescriptor> itr = descriptors.iterator();
  while (itr.hasNext()) {
    HTableDescriptor htd = itr.next();
    try {
      requirePermission("getTableDescriptors", htd.getTableName(), null, null,
          Action.ADMIN, Action.CREATE);
    } catch (AccessDeniedException e) {
      itr.remove();
    }
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:23,代码来源:AccessController.java

示例9: start

import org.apache.hadoop.hbase.coprocessor.MasterCoprocessorEnvironment; //导入依赖的package包/类
@Override
public void start(CoprocessorEnvironment env) throws IOException {
  this.conf = env.getConfiguration();
  if (HFile.getFormatVersion(conf) < HFile.MIN_FORMAT_VERSION_WITH_TAGS) {
    throw new RuntimeException("A minimum HFile version of " + HFile.MIN_FORMAT_VERSION_WITH_TAGS
      + " is required to persist visibility labels. Consider setting " + HFile.FORMAT_VERSION_KEY
      + " accordingly.");
  }

  if (env instanceof RegionServerCoprocessorEnvironment) {
    throw new RuntimeException("Visibility controller should not be configured as "
        + "'hbase.coprocessor.regionserver.classes'.");
  }
  // Do not create for master CPs
  if (!(env instanceof MasterCoprocessorEnvironment)) {
    visibilityLabelService = VisibilityLabelServiceManager.getInstance()
        .getVisibilityLabelService(this.conf);
  }
  Pair<List<String>, List<String>> superUsersAndGroups =
      VisibilityUtils.getSystemAndSuperUsers(this.conf);
  this.superUsers = superUsersAndGroups.getFirst();
  this.superGroups = superUsersAndGroups.getSecond();
}
 
开发者ID:grokcoder,项目名称:pbase,代码行数:24,代码来源:VisibilityController.java

示例10: postStartMaster

import org.apache.hadoop.hbase.coprocessor.MasterCoprocessorEnvironment; //导入依赖的package包/类
/********************************* Master related hooks **********************************/

  @Override
  public void postStartMaster(ObserverContext<MasterCoprocessorEnvironment> ctx) throws IOException {
    // Need to create the new system table for labels here
    MasterServices master = ctx.getEnvironment().getMasterServices();
    if (!MetaTableAccessor.tableExists(master.getConnection(), LABELS_TABLE_NAME)) {
      HTableDescriptor labelsTable = new HTableDescriptor(LABELS_TABLE_NAME);
      HColumnDescriptor labelsColumn = new HColumnDescriptor(LABELS_TABLE_FAMILY);
      labelsColumn.setBloomFilterType(BloomType.NONE);
      labelsColumn.setBlockCacheEnabled(false); // We will cache all the labels. No need of normal
                                                 // table block cache.
      labelsTable.addFamily(labelsColumn);
      // Let the "labels" table having only one region always. We are not expecting too many labels in
      // the system.
      labelsTable.setValue(HTableDescriptor.SPLIT_POLICY,
          DisabledRegionSplitPolicy.class.getName());
      labelsTable.setValue(Bytes.toBytes(HConstants.DISALLOW_WRITES_IN_RECOVERING),
          Bytes.toBytes(true));
      master.createTable(labelsTable, null);
    }
  }
 
开发者ID:grokcoder,项目名称:pbase,代码行数:23,代码来源:VisibilityController.java

示例11: postStartMaster

import org.apache.hadoop.hbase.coprocessor.MasterCoprocessorEnvironment; //导入依赖的package包/类
/********************************* Master related hooks **********************************/

  @Override
  public void postStartMaster(ObserverContext<MasterCoprocessorEnvironment> ctx) throws IOException {
    // Need to create the new system table for labels here
    MasterServices master = ctx.getEnvironment().getMasterServices();
    if (!MetaReader.tableExists(master.getCatalogTracker(), LABELS_TABLE_NAME)) {
      HTableDescriptor labelsTable = new HTableDescriptor(LABELS_TABLE_NAME);
      HColumnDescriptor labelsColumn = new HColumnDescriptor(LABELS_TABLE_FAMILY);
      labelsColumn.setBloomFilterType(BloomType.NONE);
      labelsColumn.setBlockCacheEnabled(false); // We will cache all the labels. No need of normal
                                                 // table block cache.
      labelsTable.addFamily(labelsColumn);
      // Let the "labels" table having only one region always. We are not expecting too many labels in
      // the system.
      labelsTable.setValue(HTableDescriptor.SPLIT_POLICY,
          DisabledRegionSplitPolicy.class.getName());
      labelsTable.setValue(Bytes.toBytes(HConstants.DISALLOW_WRITES_IN_RECOVERING),
          Bytes.toBytes(true));
      master.createTable(labelsTable, null);
    }
  }
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:23,代码来源:VisibilityController.java

示例12: preModifyTable

import org.apache.hadoop.hbase.coprocessor.MasterCoprocessorEnvironment; //导入依赖的package包/类
@Override
public void preModifyTable(ObserverContext<MasterCoprocessorEnvironment> ctx,
    TableName tableName, HTableDescriptor htd) throws IOException {
  if (!authorizationEnabled) {
    return;
  }
  if (LABELS_TABLE_NAME.equals(tableName)) {
    throw new ConstraintException("Cannot alter " + LABELS_TABLE_NAME);
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:11,代码来源:VisibilityController.java

示例13: preAddColumn

import org.apache.hadoop.hbase.coprocessor.MasterCoprocessorEnvironment; //导入依赖的package包/类
@Override
public void preAddColumn(ObserverContext<MasterCoprocessorEnvironment> ctx, TableName tableName,
    HColumnDescriptor column) throws IOException {
  if (!authorizationEnabled) {
    return;
  }
  if (LABELS_TABLE_NAME.equals(tableName)) {
    throw new ConstraintException("Cannot alter " + LABELS_TABLE_NAME);
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:11,代码来源:VisibilityController.java

示例14: preModifyColumn

import org.apache.hadoop.hbase.coprocessor.MasterCoprocessorEnvironment; //导入依赖的package包/类
@Override
public void preModifyColumn(ObserverContext<MasterCoprocessorEnvironment> ctx,
    TableName tableName, HColumnDescriptor descriptor) throws IOException {
  if (!authorizationEnabled) {
    return;
  }
  if (LABELS_TABLE_NAME.equals(tableName)) {
    throw new ConstraintException("Cannot alter " + LABELS_TABLE_NAME);
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:11,代码来源:VisibilityController.java

示例15: preDeleteColumn

import org.apache.hadoop.hbase.coprocessor.MasterCoprocessorEnvironment; //导入依赖的package包/类
@Override
public void preDeleteColumn(ObserverContext<MasterCoprocessorEnvironment> ctx,
    TableName tableName, byte[] c) throws IOException {
  if (!authorizationEnabled) {
    return;
  }
  if (LABELS_TABLE_NAME.equals(tableName)) {
    throw new ConstraintException("Cannot alter " + LABELS_TABLE_NAME);
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:11,代码来源:VisibilityController.java


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