HBASE-2978 LoadBalancer IndexOutOfBoundsException

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@995679 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael Stack 2010-09-10 06:01:30 +00:00
parent 94b78b4997
commit 32800d3be6
2 changed files with 4 additions and 7 deletions

View File

@ -517,6 +517,7 @@ Release 0.21.0 - Unreleased
HBASE-2973 NPE in LogCleaner
HBASE-2974 LoadBalancer ArithmeticException: / by zero
HBASE-2975 DFSClient names in master and RS should be unique
HBASE-2978 LoadBalancer IndexOutOfBoundsException
IMPROVEMENTS
HBASE-1760 Cleanup TODOs in HTable

View File

@ -19,8 +19,6 @@
*/
package org.apache.hadoop.hbase.master;
import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Comparator;
@ -39,7 +37,6 @@ import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hbase.HRegionInfo;
import org.apache.hadoop.hbase.HServerInfo;
import org.apache.hadoop.io.Writable;
/**
* Makes decisions about the placement and movement of Regions across
@ -131,8 +128,6 @@ public class LoadBalancer {
*/
public List<RegionPlan> balanceCluster(
Map<HServerInfo,List<HRegionInfo>> clusterState) {
LOG.debug("Running load balancer");
long startTime = System.currentTimeMillis();
// Make a map sorted by load and count regions
@ -141,7 +136,7 @@ public class LoadBalancer {
new HServerInfo.LoadComparator());
int numServers = clusterState.size();
if (numServers == 0) {
LOG.debug("numServers=0 so nothing to balance");
LOG.debug("numServers=0 so skipping load balancing");
return null;
}
int numRegions = 0;
@ -240,13 +235,14 @@ public class LoadBalancer {
// Either more regions to assign out or servers that are still underloaded
// If we need more to fill min, grab one from each most loaded until enough
if(neededRegions != 0) {
if (neededRegions != 0) {
// Walk down most loaded, grabbing one from each until we get enough
for(Map.Entry<HServerInfo, List<HRegionInfo>> server :
serversByLoad.descendingMap().entrySet()) {
BalanceInfo balanceInfo = serverBalanceInfo.get(server.getKey());
int idx =
balanceInfo == null ? 0 : balanceInfo.getNextRegionForUnload();
if (idx >= server.getValue().size()) break;
HRegionInfo region = server.getValue().get(idx);
if (region.isMetaRegion()) continue; // Don't move meta regions.
regionsToMove.add(new RegionPlan(region, server.getKey(), null));