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


Java TableDescriptors.getAll方法代码示例

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


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

示例1: chore

import org.apache.hadoop.hbase.TableDescriptors; //导入方法依赖的package包/类
@Override
@edu.umd.cs.findbugs.annotations.SuppressWarnings(value="REC_CATCH_EXCEPTION",
  justification="Intentional")
protected void chore() {
  try {
    TableDescriptors htds = master.getTableDescriptors();
    Map<String, TableDescriptor> map = htds.getAll();
    for (TableDescriptor htd : map.values()) {
      for (ColumnFamilyDescriptor hcd : htd.getColumnFamilies()) {
        if (hcd.isMobEnabled() && hcd.getMinVersions() == 0) {
          // clean only for mob-enabled column.
          // obtain a read table lock before cleaning, synchronize with MobFileCompactionChore.
          final LockManager.MasterLock lock = master.getLockManager().createMasterLock(
              MobUtils.getTableLockName(htd.getTableName()), LockType.SHARED,
              this.getClass().getSimpleName() + ": Cleaning expired mob files");
          try {
            lock.acquire();
            cleaner.cleanExpiredMobFiles(htd.getTableName().getNameAsString(), hcd);
          } finally {
            lock.release();
          }
        }
      }
    }
  } catch (Exception e) {
    LOG.error("Fail to clean the expired mob files", e);
  }
}
 
开发者ID:apache,项目名称:hbase,代码行数:29,代码来源:ExpiredMobFileCleanerChore.java

示例2: chore

import org.apache.hadoop.hbase.TableDescriptors; //导入方法依赖的package包/类
@Override
protected void chore() {
  try {
    TableDescriptors htds = master.getTableDescriptors();
    Map<String, TableDescriptor> map = htds.getAll();
    for (TableDescriptor htd : map.values()) {
      if (!master.getTableStateManager().isTableState(htd.getTableName(),
        TableState.State.ENABLED)) {
        continue;
      }
      boolean reported = false;
      try {
        final LockManager.MasterLock lock = master.getLockManager().createMasterLock(
            MobUtils.getTableLockName(htd.getTableName()), LockType.EXCLUSIVE,
            this.getClass().getName() + ": mob compaction");
        for (ColumnFamilyDescriptor hcd : htd.getColumnFamilies()) {
          if (!hcd.isMobEnabled()) {
            continue;
          }
          if (!reported) {
            master.reportMobCompactionStart(htd.getTableName());
            reported = true;
          }
          MobUtils.doMobCompaction(master.getConfiguration(), master.getFileSystem(),
              htd.getTableName(), hcd, pool, false, lock);
        }
      } finally {
        if (reported) {
          master.reportMobCompactionEnd(htd.getTableName());
        }
      }
    }
  } catch (Exception e) {
    LOG.error("Failed to compact mob files", e);
  }
}
 
开发者ID:apache,项目名称:hbase,代码行数:37,代码来源:MobCompactionChore.java

示例3: postModifyTableHandler

import org.apache.hadoop.hbase.TableDescriptors; //导入方法依赖的package包/类
@Override
public void postModifyTableHandler(ObserverContext<MasterCoprocessorEnvironment> ctx,
    TableName tableName, HTableDescriptor htd) throws IOException {
  String table = tableName.getNameAsString();
  MasterServices master = ctx.getEnvironment().getMasterServices();
  List<Pair<HRegionInfo, ServerName>> tableRegionsAndLocations = null;
  LOG.info("Entering postModifyTable for the table " + table);
  byte[] indexBytes = htd.getValue(Constants.INDEX_SPEC_KEY);
  if (indexBytes != null) {
    TableDescriptors tableDescriptors = master.getTableDescriptors();
    Map<String, HTableDescriptor> allTableDesc = tableDescriptors.getAll();
    String indexTableName = IndexUtils.getIndexTableName(table);
    if (allTableDesc.containsKey(indexTableName)) {
      // Do table modification
      TableIndices tableIndices = new TableIndices();
      tableIndices.readFields(indexBytes);
      List<IndexSpecification> indices = tableIndices.getIndices();
      if (indices.isEmpty()) {
        LOG.error("Empty indices are passed to modify the table " + table);
        return;
      }
      IndexManager idxManager = IndexManager.getInstance();
      idxManager.removeIndices(table);
      idxManager.addIndexForTable(table, indices);
      LOG.info("Successfully updated the indexes for the table  " + table + " to " + indices);
    } else {
      try {
        tableRegionsAndLocations =
            MetaReader.getTableRegionsAndLocations(master.getCatalogTracker(), tableName, true);
      } catch (InterruptedException e) {
        LOG.error("Exception while trying to create index table for the existing table " + table);
        return;
      }
      if (tableRegionsAndLocations != null) {
        HRegionInfo[] regionInfo = new HRegionInfo[tableRegionsAndLocations.size()];
        for (int i = 0; i < tableRegionsAndLocations.size(); i++) {
          regionInfo[i] = tableRegionsAndLocations.get(i).getFirst();
        }

        byte[][] splitKeys = getSplitKeys(regionInfo);
        createSecondaryIndexTable(htd, splitKeys, master, true);
      }
    }
  }
  LOG.info("Exiting postModifyTable for the table " + table);
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:47,代码来源:IndexMasterObserver.java

示例4: postModifyTableHandler

import org.apache.hadoop.hbase.TableDescriptors; //导入方法依赖的package包/类
@Override
public void postModifyTableHandler(ObserverContext<MasterCoprocessorEnvironment> ctx,
    byte[] tableName, HTableDescriptor htd) throws IOException {
  String table = Bytes.toString(tableName);
  MasterServices master = ctx.getEnvironment().getMasterServices();
  List<Pair<HRegionInfo, ServerName>> tableRegionsAndLocations = null;
  LOG.info("Entering postModifyTable for the table " + table);
  if (htd instanceof IndexedHTableDescriptor) {
    TableDescriptors tableDescriptors = master.getTableDescriptors();
    Map<String, HTableDescriptor> allTableDesc = tableDescriptors.getAll();
    String indexTableName = IndexUtils.getIndexTableName(tableName);
    if (allTableDesc.containsKey(indexTableName)) {
      // Do table modification
      List<IndexSpecification> indices = ((IndexedHTableDescriptor) htd).getIndices();
      if (indices.isEmpty()) {
        LOG.error("Empty indices are passed to modify the table " + Bytes.toString(tableName));
        return;
      }
      IndexManager idxManager = IndexManager.getInstance();
      idxManager.removeIndices(table);
      idxManager.addIndexForTable(table, indices);
      LOG.info("Successfully updated the indexes for the table  " + table + " to " + indices);
    } else {
      try {
        tableRegionsAndLocations =
            MetaReader.getTableRegionsAndLocations(master.getCatalogTracker(), tableName, true);
      } catch (InterruptedException e) {
        LOG.error("Exception while trying to create index table for the existing table " + table);
        return;
      }
      if (tableRegionsAndLocations != null) {
        HRegionInfo[] regionInfo = new HRegionInfo[tableRegionsAndLocations.size()];
        for (int i = 0; i < tableRegionsAndLocations.size(); i++) {
          regionInfo[i] = tableRegionsAndLocations.get(i).getFirst();
        }

        byte[][] splitKeys = IndexUtils.getSplitKeys(regionInfo);
        IndexedHTableDescriptor iDesc = (IndexedHTableDescriptor) htd;
        createSecondaryIndexTable(iDesc, splitKeys, master, true);
      }
    }
  }
  LOG.info("Exiting postModifyTable for the table " + table);
}
 
开发者ID:Huawei-Hadoop,项目名称:hindex,代码行数:45,代码来源:IndexMasterObserver.java


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