Package org.apache.hadoop.hbase.master

Examples of org.apache.hadoop.hbase.master.RegionPlan$RegionPlanComparator


  /**
   * Add a region from the head or tail to the List of regions to return.
   */
  private void addRegionPlan(final MinMaxPriorityQueue<RegionPlan> regionsToMove,
      final boolean fetchFromTail, final ServerName sn, List<RegionPlan> regionsToReturn) {
    RegionPlan rp = null;
    if (!fetchFromTail) rp = regionsToMove.remove();
    else rp = regionsToMove.removeLast();
    rp.setDestination(sn);
    regionsToReturn.add(rp);
  }
View Full Code Here


      if (this.retainAssignment) {
        // Region may be available in enablingTableRegions during master startup only.
        if (enablingTableRegions != null && enablingTableRegions.contains(hri)) {
          regions.add(hri);
          if (sn != null && serverManager.isServerOnline(sn)) {
            this.assignmentManager.addPlan(hri.getEncodedName(), new RegionPlan(hri, null, sn));
          }
        }
      } else if (onlineRegions.contains(hri)) {
        continue;
      } else {
View Full Code Here

      if (this.retainAssignment) {
        // Region may be available in enablingTableRegions during master startup only.
        if (enablingTableRegions != null && enablingTableRegions.contains(hri)) {
          regions.add(hri);
          if (sn != null && serverManager.isServerOnline(sn)) {
            this.assignmentManager.addPlan(hri.getEncodedName(), new RegionPlan(hri, null, sn));
            this.assignmentManager.putRegionPlan(hri, sn);
          }
        }
      } else if (onlineRegions.contains(hri)) {
        continue;
View Full Code Here

      ServerName sn = am.getRegionServerOfRegion(regionInfo);
      String indexTableName = IndexUtils.getIndexTableName(regionInfo.getTableNameAsString());
      List<HRegionInfo> tableRegions = am.getRegionsOfTable(Bytes.toBytes(indexTableName));
      for (HRegionInfo hRegionInfo : tableRegions) {
        if (0 == Bytes.compareTo(hRegionInfo.getStartKey(), regionInfo.getStartKey())) {
          am.addPlan(hRegionInfo.getEncodedName(), new RegionPlan(hRegionInfo, null, sn));
          LOG.info("Assigning region " + hRegionInfo.getRegionNameAsString() + " to server " + sn
              + '.');
          am.assign(hRegionInfo, true, false, false);
        }
      }
View Full Code Here

      for (HRegionInfo indexRegionInfo : tableRegions) {
        if (0 == Bytes.compareTo(indexRegionInfo.getStartKey(), regionInfo.getStartKey())) {
          LOG.info("Assigning region " + indexRegionInfo.getRegionNameAsString() + "from "
              + srcServer + " to server " + destServer + '.');
          am.putRegionPlan(indexRegionInfo, destServer);
          am.addPlan(indexRegionInfo.getEncodedName(), new RegionPlan(indexRegionInfo, null,
              destServer));
          am.unassign(indexRegionInfo);
          /*
           * ((HMaster) master).move(indexRegionInfo.getEncodedNameAsBytes(),
           * Bytes.toBytes(destServer.getServerName()));
 
View Full Code Here

            LOG.debug("No user table region plans present for index table " + tableName + '.');
          }
          return null;
        }
        for (Entry<HRegionInfo, ServerName> e : regionMap.entrySet()) {
          regionPlanList.add(new RegionPlan(e.getKey(), null, e.getValue()));
        }
        // for preparing the index plan
        List<RegionPlan> indexPlanList = new ArrayList<RegionPlan>(1);
        // copy of region plan to iterate.
        List<RegionPlan> regionPlanListCopy = new ArrayList<RegionPlan>(regionPlanList);
        if (LOG.isDebugEnabled()) {
          LOG.debug("Preparing index region plans from user region plans for table " + tableName
              + ".");
        }
        return prepareIndexPlan(clusterState, indexPlanList, regionPlanListCopy);
      } else {
        regionPlanList = this.delegator.balanceCluster(userClusterState);
        if (null == regionPlanList) {
          if (LOG.isDebugEnabled()) {
            LOG.debug("User region plan is null.");
          }
          regionPlanList = new ArrayList<RegionPlan>(1);
        } else {
          saveRegionPlanList(regionPlanList);
        }
        List<RegionPlan> userRegionPlans = new ArrayList<RegionPlan>(1);

        for (Entry<String, Map<HRegionInfo, ServerName>> tableVsRegions : this.regionLocation
            .entrySet()) {
          Map<HRegionInfo, ServerName> regionMap = regionLocation.get(tableVsRegions.getKey());
          // no previous region plan for user table.
          if (null == regionMap) {
            if (LOG.isDebugEnabled()) {
              LOG.debug("No user table region plans present for index table " + tableName + '.');
            }
          } else {
            for (Entry<HRegionInfo, ServerName> e : regionMap.entrySet()) {
              userRegionPlans.add(new RegionPlan(e.getKey(), null, e.getValue()));
            }
          }
        }
        List<RegionPlan> regionPlanListCopy = new ArrayList<RegionPlan>(userRegionPlans);
        if (LOG.isDebugEnabled()) {
View Full Code Here

            continue;
          }
          if (0 != Bytes.compareTo(hri.getStartKey(), indexRegionInfo.getStartKey())) {
            continue;
          }
          RegionPlan rp = new RegionPlan(indexRegionInfo, server, regionPlan.getDestination());
          if (LOG.isDebugEnabled()) {
            LOG.debug("Selected server " + regionPlan.getDestination()
                + " as destination for region " + indexRegionInfo.getRegionNameAsString()
                + "from user region plan.");
          }
View Full Code Here

      if (this.skipTableStateCheck) {
        // Region may be available in enablingTableRegions during master startup only.
        if (enablingTableRegions != null && enablingTableRegions.contains(hri)) {
          regions.add(hri);
          if (sn != null && serverManager.isServerOnline(sn)) {
            this.assignmentManager.addPlan(hri.getEncodedName(), new RegionPlan(hri, null, sn));
          }
        }
      } else if (onlineRegions.contains(hri)) {
        continue;
      } else {
        regions.add(hri);
        if (sn != null && serverManager.isServerOnline(sn)) {
          this.assignmentManager.addPlan(hri.getEncodedName(), new RegionPlan(hri, null, sn));
        }
      }
    }
    return regions;
  }
View Full Code Here

        ServerName tmpLocation = region_a_location;
        region_a_location = region_b_location;
        region_b_location = tmpLocation;
      }

      RegionPlan regionPlan = new RegionPlan(region_b, region_b_location,
          region_a_location);
      LOG.info("Moving regions to same server for merge: " + regionPlan.toString());
      masterServices.getAssignmentManager().balance(regionPlan);
      while (!masterServices.isStopped()) {
        try {
          Thread.sleep(20);
          // Make sure check RIT first, then get region location, otherwise
View Full Code Here

            destination = serverNameWithoutCodeToServerName.get(favoredNodes.get(2));
          }
        }

        if (destination != null) {
          RegionPlan plan = new RegionPlan(region, currentServer, destination);
          plans.add(plan);
        }
      }
    }
    return plans;
View Full Code Here

TOP

Related Classes of org.apache.hadoop.hbase.master.RegionPlan$RegionPlanComparator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.