HBASE-1743 [debug tool] Add regionsInTransition list to ClusterStatus detailed output

git-svn-id: https://svn.apache.org/repos/asf/hadoop/hbase/trunk@800676 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael Stack 2009-08-04 05:09:27 +00:00
parent 557bd85bc4
commit b3653a6295
5 changed files with 66 additions and 24 deletions

View File

@ -546,6 +546,8 @@ Release 0.20.0 - Unreleased
HBASE-1714 Thrift server: prefix scan API
HBASE-1719 hold a reference to the region in stores instead of only the
region info
HBASE-1743 [debug tool] Add regionsInTransition list to ClusterStatus
detailed output
OPTIMIZATIONS
HBASE-1412 Change values for delete column and column family in KeyValue

View File

@ -270,6 +270,11 @@ module HBase
status = @admin.getClusterStatus()
if format != nil and format == "detailed"
puts("version %s" % [ status.getHBaseVersion() ])
# Put regions in transition first because usually empty
puts("%d regionsInTransition" % status.getRegionsInTransition().size())
for k, v in status.getRegionsInTransition()
puts(" %s" % [v])
end
puts("%d live servers" % [ status.getServers() ])
for server in status.getServerInfo()
puts(" %s:%d %d" % \

View File

@ -26,6 +26,10 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.NavigableMap;
import java.util.TreeMap;
import org.apache.hadoop.io.VersionedWritable;
@ -41,6 +45,7 @@ import org.apache.hadoop.io.VersionedWritable;
* <li>The number of requests since last report.</li>
* <li>Detailed region server loading and resource usage information,
* per server and per region.</li>
* <li>Regions in transition at master</li>
* </ul>
*/
public class ClusterStatus extends VersionedWritable {
@ -49,6 +54,7 @@ public class ClusterStatus extends VersionedWritable {
private String hbaseVersion;
private Collection<HServerInfo> liveServerInfo;
private Collection<String> deadServers;
private NavigableMap<String, String> intransition;
/**
* Constructor, for Writable
@ -191,6 +197,14 @@ public class ClusterStatus extends VersionedWritable {
this.deadServers = deadServers;
}
public Map<String, String> getRegionsInTransition() {
return this.intransition;
}
public void setRegionsInTransition(final NavigableMap<String, String> m) {
this.intransition = m;
}
//
// Writable
//
@ -206,6 +220,11 @@ public class ClusterStatus extends VersionedWritable {
for (String server: deadServers) {
out.writeUTF(server);
}
out.writeInt(this.intransition.size());
for (Map.Entry<String, String> e: this.intransition.entrySet()) {
out.writeUTF(e.getKey());
out.writeUTF(e.getValue());
}
}
public void readFields(DataInput in) throws IOException {
@ -223,5 +242,12 @@ public class ClusterStatus extends VersionedWritable {
for (int i = 0; i < count; i++) {
deadServers.add(in.readUTF());
}
count = in.readInt();
this.intransition = new TreeMap<String, String>();
for (int i = 0; i < count; i++) {
String key = in.readUTF();
String value = in.readUTF();
this.intransition.put(key, value);
}
}
}
}

View File

@ -1053,6 +1053,7 @@ public class HMaster extends Thread implements HConstants, HMasterInterface,
status.setHBaseVersion(VersionInfo.getVersion());
status.setServerInfo(serverManager.serversToServerInfo.values());
status.setDeadServers(serverManager.deadServers);
status.setRegionsInTransition(this.regionManager.getRegionsInTransition());
return status;
}

View File

@ -20,21 +20,21 @@
package org.apache.hadoop.hbase.master;
import java.io.IOException;
import java.util.concurrent.atomic.AtomicReference;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.util.NavigableMap;
import java.util.Set;
import java.util.SortedMap;
import java.util.TreeMap;
import java.util.Collections;
import java.util.concurrent.ConcurrentSkipListMap;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@ -43,15 +43,15 @@ import org.apache.hadoop.fs.Path;
import org.apache.hadoop.fs.PathFilter;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.HMsg;
import org.apache.hadoop.hbase.HRegionInfo;
import org.apache.hadoop.hbase.HServerAddress;
import org.apache.hadoop.hbase.HServerInfo;
import org.apache.hadoop.hbase.HServerLoad;
import org.apache.hadoop.hbase.HRegionInfo;
import org.apache.hadoop.hbase.RegionHistorian;
import org.apache.hadoop.hbase.regionserver.HRegion;
import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.ipc.HRegionInterface;
import org.apache.hadoop.hbase.HMsg;
import org.apache.hadoop.hbase.regionserver.HRegion;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.util.Pair;
import org.apache.hadoop.hbase.util.Threads;
@ -1349,24 +1349,19 @@ class RegionManager implements HConstants {
double avg = master.serverManager.getAverageLoad();
// nothing to balance if server load not more then average load
if(servLoad.getLoad() <= Math.ceil(avg) || avg <= 2.0) {
return;
}
if (servLoad.getLoad() <= Math.ceil(avg) || avg <= 2.0) return;
// check if current server is overloaded
// check if server is overloaded
int numRegionsToClose = balanceFromOverloaded(servLoad, avg);
// check if we can unload server by low loaded servers
if(numRegionsToClose <= 0) {
numRegionsToClose = balanceToLowloaded(info.getServerName(), servLoad,
avg);
}
if (numRegionsToClose <= 0)
balanceToLowloaded(info.getServerName(), servLoad, avg);
if(maxRegToClose > 0) {
if (maxRegToClose > 0)
numRegionsToClose = Math.min(numRegionsToClose, maxRegToClose);
}
if(numRegionsToClose > 0) {
if (numRegionsToClose > 0){
unassignSomeRegions(info, numRegionsToClose, mostLoadedRegions,
returnMsgs);
}
@ -1421,13 +1416,26 @@ class RegionManager implements HConstants {
if (LOG.isDebugEnabled()) {
LOG.debug("Server " + srvName + " will be unloaded for " +
"balance. Server load: " + numSrvRegs + " avg: " +
avgLoad + ", regions can be moved: " + numMoveToLowLoaded +
". Regions to close: " + numRegionsToClose);
avgLoad + ", regions can be moved: " + numMoveToLowLoaded);
}
return numRegionsToClose;
}
}
/**
* @return Snapshot of regionsintransition as a sorted Map.
*/
NavigableMap<String, String> getRegionsInTransition() {
NavigableMap<String, String> result = new TreeMap<String, String>();
synchronized (this.regionsInTransition) {
if (this.regionsInTransition.isEmpty()) return result;
for (Map.Entry<String, RegionState> e: this.regionsInTransition.entrySet()) {
result.put(e.getKey(), e.getValue().toString());
}
}
return result;
}
/*
* State of a Region as it transitions from closed to open, etc. See
* note on regionsInTransition data member above for listing of state