HBASE-1414 Add server status logging chore to ServerManager

git-svn-id: https://svn.apache.org/repos/asf/hadoop/hbase/trunk@774152 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Andrew Kyle Purtell 2009-05-13 00:27:51 +00:00
parent bf9a5aeb19
commit 8f472ec416
2 changed files with 33 additions and 15 deletions

View File

@ -229,7 +229,9 @@ Release 0.20.0 - Unreleased
HBASE-1405 Threads.shutdown has unnecessary branch
HBASE-1407 Changing internal structure of ImmutableBytesWritable
contructor (Erik Holstad via Stack)
HBASE-1345 Remove distributed mode from MiniZooKeeper (Nitay Joffe via Stack)
HBASE-1345 Remove distributed mode from MiniZooKeeper (Nitay Joffe via
Stack)
HBASE-1414 Add server status logging chore to ServerManager
OPTIMIZATIONS

View File

@ -27,12 +27,14 @@ import java.util.Set;
import java.util.HashSet;
import java.util.ArrayList;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.Collections;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.hbase.Chore;
import org.apache.hadoop.hbase.HServerInfo;
import org.apache.hadoop.hbase.HServerLoad;
import org.apache.hadoop.hbase.HServerAddress;
@ -93,25 +95,47 @@ class ServerManager implements HConstants {
protected HMaster master;
// Last time we logged average load.
private volatile long lastLogOfAverageLaod = 0;
private final long loggingPeriodForAverageLoad;
/* The regionserver will not be assigned or asked close regions if it
* is currently opening >= this many regions.
*/
private final int nobalancingCount;
class ServerMonitor extends Chore {
ServerMonitor(final int period, final AtomicBoolean stop) {
super(period, stop);
}
protected void chore() {
int numServers = serverAddressToServerInfo.size();
int numDeadServers = deadServers.size();
double averageLoad = getAverageLoad();
LOG.info(numServers + " region servers, " + numDeadServers +
" dead, average load " + averageLoad);
if (numDeadServers > 0) {
LOG.info("DEAD [");
for (String server: deadServers) {
LOG.info(" " + server);
}
LOG.info("]");
}
}
}
ServerMonitor serverMonitorThread;
/**
* @param master
*/
public ServerManager(HMaster master) {
this.master = master;
zooKeeperWrapper = master.getZooKeeperWrapper();
this.loggingPeriodForAverageLoad = master.getConfiguration().
getLong("hbase.master.avgload.logging.period", 60000);
this.nobalancingCount = master.getConfiguration().
getInt("hbase.regions.nobalancing.count", 4);
serverMonitorThread = new ServerMonitor(master.metaRescanInterval,
master.shutdownRequested);
serverMonitorThread.start();
}
/**
@ -621,14 +645,6 @@ class ServerManager implements HConstants {
totalLoad += load.getNumberOfRegions();
}
averageLoad = Math.ceil((double)totalLoad / (double)numServers);
// Only log on a period, not on every invocation of this method.
long now = System.currentTimeMillis();
if (LOG.isDebugEnabled() &&
(now > (this.loggingPeriodForAverageLoad + this.lastLogOfAverageLaod))) {
LOG.debug("Total Load: " + totalLoad + ", Num Servers: " + numServers
+ ", Avg Load: " + averageLoad);
this.lastLogOfAverageLaod = now;
}
}
return averageLoad;
}