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


Java MetaReader.fullScan方法代码示例

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


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

示例1: isDaughterMissing

import org.apache.hadoop.hbase.catalog.MetaReader; //导入方法依赖的package包/类
/**
 * Look for presence of the daughter OR of a split of the daughter in .META.
 * Daughter could have been split over on regionserver before a run of the
 * catalogJanitor had chance to clear reference from parent.
 * @param daughter Daughter region to search for.
 * @throws IOException 
 */
private static boolean isDaughterMissing(final CatalogTracker catalogTracker,
    final HRegionInfo daughter) throws IOException {
  FindDaughterVisitor visitor = new FindDaughterVisitor(daughter);
  // Start the scan at what should be the daughter's row in the .META.
  // We will either 1., find the daughter or some derivative split of the
  // daughter (will have same table name and start row at least but will sort
  // after because has larger regionid -- the regionid is timestamp of region
  // creation), OR, we will not find anything with same table name and start
  // row.  If the latter, then assume daughter missing and do fixup.
  byte [] startrow = daughter.getRegionName();
  MetaReader.fullScan(catalogTracker, visitor, startrow);
  return !visitor.foundDaughter();
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:21,代码来源:ServerShutdownHandler.java

示例2: fixupDaughters

import org.apache.hadoop.hbase.catalog.MetaReader; //导入方法依赖的package包/类
void fixupDaughters(final MonitoredTask status) throws IOException, KeeperException {
  final Map<HRegionInfo, Result> offlineSplitParents =
    new HashMap<HRegionInfo, Result>();
  // This visitor collects offline split parents in the .META. table
  MetaReader.Visitor visitor = new MetaReader.Visitor() {
    @Override
    public boolean visit(Result r) throws IOException {
      if (r == null || r.isEmpty()) return true;
      HRegionInfo info =
        MetaReader.parseHRegionInfoFromCatalogResult(
          r, HConstants.REGIONINFO_QUALIFIER);
      if (info == null) return true; // Keep scanning
      if (info.isOffline() && info.isSplit()) {
        offlineSplitParents.put(info, r);
      }
      // Returning true means "keep scanning"
      return true;
    }
  };
  // Run full scan of .META. catalog table passing in our custom visitor
  MetaReader.fullScan(this.catalogTracker, visitor);
  // Now work on our list of found parents. See if any we can clean up.
  int fixups = 0;
  for (Map.Entry<HRegionInfo, Result> e : offlineSplitParents.entrySet()) {
    String node = ZKAssign.getNodeName(zooKeeper, e.getKey().getEncodedName());
    byte[] data = ZKUtil.getData(zooKeeper, node);
    if (data == null) { // otherwise, splitting is still going on, skip it
      fixups += ServerShutdownHandler.fixupDaughters(
        e.getValue(), assignmentManager, catalogTracker);
    }
  }
  if (fixups != 0) {
    LOG.info("Scanned the catalog and fixed up " + fixups +
      " missing daughter region(s)");
  }
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:37,代码来源:HMaster.java

示例3: scan

import org.apache.hadoop.hbase.catalog.MetaReader; //导入方法依赖的package包/类
/**
 * Run janitorial scan of catalog <code>.META.</code> table looking for
 * garbage to collect.
 * @throws IOException
 */
void scan() throws IOException {
  // TODO: Only works with single .META. region currently.  Fix.
  final AtomicInteger count = new AtomicInteger(0);
  // Keep Map of found split parents.  There are candidates for cleanup.
  // Use a comparator that has split parents come before its daughters.
  final Map<HRegionInfo, Result> splitParents =
    new TreeMap<HRegionInfo, Result>(new SplitParentFirstComparator());
  // This visitor collects split parents and counts rows in the .META. table
  MetaReader.Visitor visitor = new MetaReader.Visitor() {
    @Override
    public boolean visit(Result r) throws IOException {
      if (r == null || r.isEmpty()) return true;
      count.incrementAndGet();
      HRegionInfo info = getHRegionInfo(r);
      if (info == null) return true; // Keep scanning
      if (info.isSplitParent()) splitParents.put(info, r);
      // Returning true means "keep scanning"
      return true;
    }
  };
  // Run full scan of .META. catalog table passing in our custom visitor
  MetaReader.fullScan(this.server.getCatalogTracker(), visitor);
  // Now work on our list of found parents. See if any we can clean up.
  int cleaned = 0;
  for (Map.Entry<HRegionInfo, Result> e : splitParents.entrySet()) {
    if (cleanParent(e.getKey(), e.getValue())) cleaned++;
  }
  if (cleaned != 0) {
    LOG.info("Scanned " + count.get() + " catalog row(s) and gc'd " + cleaned +
      " unreferenced parent region(s)");
  } else if (LOG.isDebugEnabled()) {
    LOG.debug("Scanned " + count.get() + " catalog row(s) and gc'd " + cleaned +
    " unreferenced parent region(s)");
  }
}
 
开发者ID:lifeng5042,项目名称:RStore,代码行数:41,代码来源:CatalogJanitor.java

示例4: fixupDaughters

import org.apache.hadoop.hbase.catalog.MetaReader; //导入方法依赖的package包/类
void fixupDaughters(final MonitoredTask status) throws IOException {
  final Map<HRegionInfo, Result> offlineSplitParents =
    new HashMap<HRegionInfo, Result>();
  // This visitor collects offline split parents in the .META. table
  MetaReader.Visitor visitor = new MetaReader.Visitor() {
    @Override
    public boolean visit(Result r) throws IOException {
      if (r == null || r.isEmpty()) return true;
      HRegionInfo info =
        MetaReader.parseHRegionInfoFromCatalogResult(
          r, HConstants.REGIONINFO_QUALIFIER);
      if (info == null) return true; // Keep scanning
      if (info.isOffline() && info.isSplit()) {
        offlineSplitParents.put(info, r);
      }
      // Returning true means "keep scanning"
      return true;
    }
  };
  // Run full scan of .META. catalog table passing in our custom visitor
  MetaReader.fullScan(this.catalogTracker, visitor);
  // Now work on our list of found parents. See if any we can clean up.
  int fixups = 0;
  for (Map.Entry<HRegionInfo, Result> e : offlineSplitParents.entrySet()) {
    fixups += ServerShutdownHandler.fixupDaughters(
        e.getValue(), assignmentManager, catalogTracker);
  }
  if (fixups != 0) {
    LOG.info("Scanned the catalog and fixed up " + fixups +
      " missing daughter region(s)");
  }
}
 
开发者ID:lifeng5042,项目名称:RStore,代码行数:33,代码来源:HMaster.java

示例5: assignAllUserRegions

import org.apache.hadoop.hbase.catalog.MetaReader; //导入方法依赖的package包/类
/**
 * Assigns all user regions, if any exist.  Used during cluster startup.
 * <p>
 * This is a synchronous call and will return once every region has been
 * assigned.  If anything fails, an exception is thrown and the cluster
 * should be shutdown.
 * @throws InterruptedException
 * @throws IOException
 */
public void assignAllUserRegions() throws IOException, InterruptedException {
  // Get all available servers
  List<ServerName> servers = serverManager.getOnlineServersList();

  // If there are no servers we need not proceed with region assignment.
  if(servers.isEmpty()) return;

  // Scan META for all user regions, skipping any disabled tables
  Map<HRegionInfo, ServerName> allRegions =
    MetaReader.fullScan(catalogTracker, this.zkTable.getDisabledTables(), true);
  if (allRegions == null || allRegions.isEmpty()) return;

  // Determine what type of assignment to do on startup
  boolean retainAssignment = master.getConfiguration().
    getBoolean("hbase.master.startup.retainassign", true);

  Map<ServerName, List<HRegionInfo>> bulkPlan = null;
  if (retainAssignment) {
    // Reuse existing assignment info
    bulkPlan = balancer.retainAssignment(allRegions, servers);
  } else {
    // assign regions in round-robin fashion
    assignUserRegions(new ArrayList<HRegionInfo>(allRegions.keySet()), servers);
    return;
  }
  LOG.info("Bulk assigning " + allRegions.size() + " region(s) across " +
    servers.size() + " server(s), retainAssignment=" + retainAssignment);

  // Use fixed count thread pool assigning.
  BulkAssigner ba = new StartupBulkAssigner(this.master, bulkPlan, this);
  ba.bulkAssign();
  LOG.info("Bulk assigning done");
}
 
开发者ID:lifeng5042,项目名称:RStore,代码行数:43,代码来源:AssignmentManager.java

示例6: initialize

import org.apache.hadoop.hbase.catalog.MetaReader; //导入方法依赖的package包/类
/**
 * Initialize the region assignment snapshot by scanning the hbase:meta table
 * @throws IOException
 */
public void initialize() throws IOException {
  LOG.info("Start to scan the hbase:meta for the current region assignment " +
"snappshot");
  // TODO: at some point this code could live in the MetaReader
  Visitor v = new Visitor() {
    @Override
    public boolean visit(Result result) throws IOException {
      try {
        if (result ==  null || result.isEmpty()) return true;
        Pair<HRegionInfo, ServerName> regionAndServer =
            HRegionInfo.getHRegionInfoAndServerName(result);
        HRegionInfo hri = regionAndServer.getFirst();
        if (hri  == null) return true;
        if (hri.getTable() == null) return true;
        if (disabledTables.contains(hri.getTable())) {
          return true;
        }
        // Are we to include split parents in the list?
        if (excludeOfflinedSplitParents && hri.isSplit()) return true;
        // Add the current assignment to the snapshot
        addAssignment(hri, regionAndServer.getSecond());
        addRegion(hri);
        
        // the code below is to handle favored nodes
        byte[] favoredNodes = result.getValue(HConstants.CATALOG_FAMILY,
            FavoredNodeAssignmentHelper.FAVOREDNODES_QUALIFIER);
        if (favoredNodes == null) return true;
        // Add the favored nodes into assignment plan
        ServerName[] favoredServerList =
            FavoredNodeAssignmentHelper.getFavoredNodesList(favoredNodes);
        // Add the favored nodes into assignment plan
        existingAssignmentPlan.updateFavoredNodesMap(hri,
            Arrays.asList(favoredServerList));
        return true;
      } catch (RuntimeException e) {
        LOG.error("Catche remote exception " + e.getMessage() +
            " when processing" + result);
        throw e;
      }
    }
  };
  // Scan hbase:meta to pick up user regions
  MetaReader.fullScan(tracker, v);
  //regionToRegionServerMap = regions;
  LOG.info("Finished to scan the hbase:meta for the current region assignment" +
    "snapshot");
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:52,代码来源:SnapshotOfRegionAssignmentFromMeta.java

示例7: 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


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