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


Java MetaReader.parseCatalogResult方法代码示例

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


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

示例1: getTableRegionForRow

import org.apache.hadoop.hbase.catalog.MetaReader; //导入方法依赖的package包/类
/**
 * Return the region and current deployment for the region containing
 * the given row. If the region cannot be found, returns null. If it
 * is found, but not currently deployed, the second element of the pair
 * may be null.
 */
Pair<HRegionInfo, ServerName> getTableRegionForRow(
    final byte [] tableName, final byte [] rowKey)
throws IOException {
  final AtomicReference<Pair<HRegionInfo, ServerName>> result =
    new AtomicReference<Pair<HRegionInfo, ServerName>>(null);

  MetaScannerVisitor visitor =
    new MetaScannerVisitorBase() {
      @Override
      public boolean processRow(Result data) throws IOException {
        if (data == null || data.size() <= 0) {
          return true;
        }
        Pair<HRegionInfo, ServerName> pair = MetaReader.parseCatalogResult(data);
        if (pair == null) {
          return false;
        }
        if (!Bytes.equals(pair.getFirst().getTableName(), tableName)) {
          return false;
        }
        result.set(pair);
        return true;
      }
  };

  MetaScanner.metaScan(conf, visitor, tableName, rowKey, 1);
  return result.get();
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:35,代码来源:HMaster.java

示例2: getTableRegionForRow

import org.apache.hadoop.hbase.catalog.MetaReader; //导入方法依赖的package包/类
/**
 * Return the region and current deployment for the region containing
 * the given row. If the region cannot be found, returns null. If it
 * is found, but not currently deployed, the second element of the pair
 * may be null.
 */
Pair<HRegionInfo, ServerName> getTableRegionForRow(
    final byte [] tableName, final byte [] rowKey)
throws IOException {
  final AtomicReference<Pair<HRegionInfo, ServerName>> result =
    new AtomicReference<Pair<HRegionInfo, ServerName>>(null);

  MetaScannerVisitor visitor =
    new MetaScannerVisitor() {
      @Override
      public boolean processRow(Result data) throws IOException {
        if (data == null || data.size() <= 0) {
          return true;
        }
        Pair<HRegionInfo, ServerName> pair = MetaReader.parseCatalogResult(data);
        if (pair == null) {
          return false;
        }
        if (!Bytes.equals(pair.getFirst().getTableName(), tableName)) {
          return false;
        }
        result.set(pair);
        return true;
      }
  };

  MetaScanner.metaScan(conf, visitor, tableName, rowKey, 1);
  return result.get();
}
 
开发者ID:lifeng5042,项目名称:RStore,代码行数:35,代码来源:HMaster.java

示例3: loadMetaEntries

import org.apache.hadoop.hbase.catalog.MetaReader; //导入方法依赖的package包/类
/**
 * Scan .META. and -ROOT-, adding all regions found to the regionInfo map.
 * @throws IOException if an error is encountered
 */
boolean loadMetaEntries() throws IOException {

  // get a list of all regions from the master. This involves
  // scanning the META table
  if (!recordRootRegion()) {
    // Will remove later if we can fix it
    errors.reportError("Fatal error: unable to get root region location. Exiting...");
    return false;
  }

  MetaScannerVisitor visitor = new MetaScannerVisitorBase() {
    int countRecord = 1;

    // comparator to sort KeyValues with latest modtime
    final Comparator<KeyValue> comp = new Comparator<KeyValue>() {
      public int compare(KeyValue k1, KeyValue k2) {
        return (int)(k1.getTimestamp() - k2.getTimestamp());
      }
    };

    public boolean processRow(Result result) throws IOException {
      try {

        // record the latest modification of this META record
        long ts =  Collections.max(result.list(), comp).getTimestamp();
        Pair<HRegionInfo, ServerName> pair = MetaReader.parseCatalogResult(result);
        if (pair == null || pair.getFirst() == null) {
          emptyRegionInfoQualifiers.add(result);
          return true;
        }
        ServerName sn = null;
        if (pair.getSecond() != null) {
          sn = pair.getSecond();
        }
        HRegionInfo hri = pair.getFirst();
        if (!(isTableIncluded(hri.getTableNameAsString())
            || hri.isMetaRegion() || hri.isRootRegion())) {
          return true;
        }
        PairOfSameType<HRegionInfo> daughters = MetaReader.getDaughterRegions(result);
        MetaEntry m = new MetaEntry(hri, sn, ts, daughters.getFirst(), daughters.getSecond());
        HbckInfo hbInfo = new HbckInfo(m);
        HbckInfo previous = regionInfoMap.put(hri.getEncodedName(), hbInfo);
        if (previous != null) {
          throw new IOException("Two entries in META are same " + previous);
        }

        // show proof of progress to the user, once for every 100 records.
        if (countRecord % 100 == 0) {
          errors.progress();
        }
        countRecord++;
        return true;
      } catch (RuntimeException e) {
        LOG.error("Result=" + result);
        throw e;
      }
    }
  };

  // Scan -ROOT- to pick up META regions
  MetaScanner.metaScan(getConf(), null, visitor, null, null,
    Integer.MAX_VALUE, HConstants.ROOT_TABLE_NAME);

  if (!checkMetaOnly) {
    // Scan .META. to pick up user regions
    MetaScanner.metaScan(getConf(), visitor);
  }

  errors.print("");
  return true;
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:77,代码来源:HBaseFsck.java

示例4: rebuildUserRegions

import org.apache.hadoop.hbase.catalog.MetaReader; //导入方法依赖的package包/类
/**
 * Rebuild the list of user regions and assignment information.
 * <p>
 * Returns a map of servers that are not found to be online and the regions
 * they were hosting.
 * @return map of servers not online to their assigned regions, as stored
 *         in META
 * @throws IOException
 */
Map<ServerName, List<Pair<HRegionInfo, Result>>> rebuildUserRegions()
throws IOException, KeeperException {
  // Region assignment from META
  List<Result> results = MetaReader.fullScan(this.catalogTracker);
  // Map of offline servers and their regions to be returned
  Map<ServerName, List<Pair<HRegionInfo,Result>>> offlineServers =
    new TreeMap<ServerName, List<Pair<HRegionInfo, Result>>>();
  // Iterate regions in META
  for (Result result : results) {
    Pair<HRegionInfo, ServerName> region = MetaReader.parseCatalogResult(result);
    if (region == null) continue;
    HRegionInfo regionInfo = region.getFirst();
    ServerName regionLocation = region.getSecond();
    if (regionInfo == null) continue;
    String tableName = regionInfo.getTableNameAsString();
    if (regionLocation == null) {
      // regionLocation could be null if createTable didn't finish properly.
      // When createTable is in progress, HMaster restarts.
      // Some regions have been added to .META., but have not been assigned.
      // When this happens, the region's table must be in ENABLING state.
      // It can't be in ENABLED state as that is set when all regions are
      // assigned.
      // It can't be in DISABLING state, because DISABLING state transitions
      // from ENABLED state when application calls disableTable.
      // It can't be in DISABLED state, because DISABLED states transitions
      // from DISABLING state.
      if (false == checkIfRegionsBelongsToEnabling(regionInfo)) {
        LOG.warn("Region " + regionInfo.getEncodedName() +
          " has null regionLocation." + " But its table " + tableName +
          " isn't in ENABLING state.");
      }
      addTheTablesInPartialState(this.disablingTables, this.enablingTables, regionInfo,
          tableName);
    } else if (!this.serverManager.isServerOnline(regionLocation)) {
      // Region is located on a server that isn't online
      List<Pair<HRegionInfo, Result>> offlineRegions =
        offlineServers.get(regionLocation);
      if (offlineRegions == null) {
        offlineRegions = new ArrayList<Pair<HRegionInfo,Result>>(1);
        offlineServers.put(regionLocation, offlineRegions);
      }
      offlineRegions.add(new Pair<HRegionInfo,Result>(regionInfo, result));
    } else {
      // Region is being served and on an active server
      // add only if region not in disabled and enabling table
      if (false == checkIfRegionBelongsToDisabled(regionInfo)
          && false == checkIfRegionsBelongsToEnabling(regionInfo)) {
        regions.put(regionInfo, regionLocation);
        addToServers(regionLocation, regionInfo);
      }
      addTheTablesInPartialState(this.disablingTables, this.enablingTables, regionInfo,
          tableName);
    }
  }
  return offlineServers;
}
 
开发者ID:lifeng5042,项目名称:RStore,代码行数:66,代码来源:AssignmentManager.java

示例5: getMetaEntries

import org.apache.hadoop.hbase.catalog.MetaReader; //导入方法依赖的package包/类
/**
 * Scan .META. and -ROOT-, adding all regions found to the regionInfo map.
 * @throws IOException if an error is encountered
 */
void getMetaEntries() throws IOException {
  MetaScannerVisitor visitor = new MetaScannerVisitor() {
    int countRecord = 1;

    // comparator to sort KeyValues with latest modtime
    final Comparator<KeyValue> comp = new Comparator<KeyValue>() {
      public int compare(KeyValue k1, KeyValue k2) {
        return (int)(k1.getTimestamp() - k2.getTimestamp());
      }
    };

    public boolean processRow(Result result) throws IOException {
      try {

        // record the latest modification of this META record
        long ts =  Collections.max(result.list(), comp).getTimestamp();
        Pair<HRegionInfo, ServerName> pair = MetaReader.parseCatalogResult(result);
        if (pair == null || pair.getFirst() == null) {
          emptyRegionInfoQualifiers.add(result);
          return true;
        }
        ServerName sn = null;
        if (pair.getSecond() != null) {
          sn = pair.getSecond();
        }
        MetaEntry m = new MetaEntry(pair.getFirst(), sn, ts);
        HbckInfo hbInfo = new HbckInfo(m);
        HbckInfo previous = regionInfo.put(pair.getFirst().getEncodedName(), hbInfo);
        if (previous != null) {
          throw new IOException("Two entries in META are same " + previous);
        }

        // show proof of progress to the user, once for every 100 records.
        if (countRecord % 100 == 0) {
          errors.progress();
        }
        countRecord++;
        return true;
      } catch (RuntimeException e) {
        LOG.error("Result=" + result);
        throw e;
      }
    }
  };

  // Scan -ROOT- to pick up META regions
  MetaScanner.metaScan(conf, visitor, null, null,
    Integer.MAX_VALUE, HConstants.ROOT_TABLE_NAME);

  if (!checkMetaOnly) {
    // Scan .META. to pick up user regions
    MetaScanner.metaScan(conf, visitor);
  }
  
  errors.print("");
}
 
开发者ID:lifeng5042,项目名称:RStore,代码行数:61,代码来源:HBaseFsck.java


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