From 1351769c16b5c2f7010105a13ee8a9063ba1bebb Mon Sep 17 00:00:00 2001 From: Jonathan Gray Date: Tue, 2 Nov 2010 04:16:56 +0000 Subject: [PATCH] HBASE-3180: Review periodic master logging, especially ServerManager once a minute git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1029949 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES.txt | 2 + .../hadoop/hbase/master/CatalogJanitor.java | 7 +++- .../hadoop/hbase/master/LoadBalancer.java | 11 +++--- .../hadoop/hbase/master/ServerManager.java | 38 ++----------------- 4 files changed, 16 insertions(+), 42 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 8afc3c25daf..a1ef0107e02 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1088,6 +1088,8 @@ Release 0.21.0 - Unreleased HBASE-3120 [rest] Content transcoding HBASE-3181 Review, document, and fix up Regions-in-Transition timeout logic + HBASE-3180 Review periodic master logging, especially ServerManager once + a minute NEW FEATURES diff --git a/src/main/java/org/apache/hadoop/hbase/master/CatalogJanitor.java b/src/main/java/org/apache/hadoop/hbase/master/CatalogJanitor.java index ffac6c4018d..ba84719d934 100644 --- a/src/main/java/org/apache/hadoop/hbase/master/CatalogJanitor.java +++ b/src/main/java/org/apache/hadoop/hbase/master/CatalogJanitor.java @@ -110,8 +110,13 @@ class CatalogJanitor extends Chore { for (Map.Entry e : splitParents.entrySet()) { if (cleanParent(e.getKey(), e.getValue())) cleaned++; } - LOG.info("Scanned " + count.get() + " catalog row(s) and gc'd " + 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)"); + } } /** diff --git a/src/main/java/org/apache/hadoop/hbase/master/LoadBalancer.java b/src/main/java/org/apache/hadoop/hbase/master/LoadBalancer.java index 5fbf0f7b4c3..5b9f1dfa269 100644 --- a/src/main/java/org/apache/hadoop/hbase/master/LoadBalancer.java +++ b/src/main/java/org/apache/hadoop/hbase/master/LoadBalancer.java @@ -155,12 +155,10 @@ public class LoadBalancer { if(serversByLoad.lastKey().getLoad().getNumberOfRegions() <= max && serversByLoad.firstKey().getLoad().getNumberOfRegions() >= min) { // Skipped because no server outside (min,max) range - if(LOG.isDebugEnabled()) { - LOG.debug("Skipping load balancing. servers=" + numServers + " " + - "regions=" + numRegions + " average=" + average + " " + - "mostloaded=" + serversByLoad.lastKey().getLoad().getNumberOfRegions() + - " leastloaded=" + serversByLoad.lastKey().getLoad().getNumberOfRegions()); - } + LOG.info("Skipping load balancing. servers=" + numServers + " " + + "regions=" + numRegions + " average=" + average + " " + + "mostloaded=" + serversByLoad.lastKey().getLoad().getNumberOfRegions() + + " leastloaded=" + serversByLoad.lastKey().getLoad().getNumberOfRegions()); return null; } @@ -394,6 +392,7 @@ public class LoadBalancer { * @return ordered list of hosts holding blocks of the specified region * @throws IOException if any filesystem errors */ + @SuppressWarnings("unused") private List getTopBlockLocations(FileSystem fs, HRegionInfo region) throws IOException { String encodedName = region.getEncodedName(); diff --git a/src/main/java/org/apache/hadoop/hbase/master/ServerManager.java b/src/main/java/org/apache/hadoop/hbase/master/ServerManager.java index 3558aabc4ca..ae87c152366 100644 --- a/src/main/java/org/apache/hadoop/hbase/master/ServerManager.java +++ b/src/main/java/org/apache/hadoop/hbase/master/ServerManager.java @@ -31,7 +31,6 @@ import java.util.concurrent.ConcurrentHashMap; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.hadoop.conf.Configuration; -import org.apache.hadoop.hbase.Chore; import org.apache.hadoop.hbase.HMsg; import org.apache.hadoop.hbase.HRegionInfo; import org.apache.hadoop.hbase.HServerAddress; @@ -39,7 +38,6 @@ import org.apache.hadoop.hbase.HServerInfo; import org.apache.hadoop.hbase.HServerLoad; import org.apache.hadoop.hbase.PleaseHoldException; import org.apache.hadoop.hbase.Server; -import org.apache.hadoop.hbase.Stoppable; import org.apache.hadoop.hbase.YouAreDeadException; import org.apache.hadoop.hbase.catalog.CatalogTracker; import org.apache.hadoop.hbase.client.HConnection; @@ -50,10 +48,7 @@ import org.apache.hadoop.hbase.master.handler.MetaServerShutdownHandler; import org.apache.hadoop.hbase.master.handler.ServerShutdownHandler; import org.apache.hadoop.hbase.master.metrics.MasterMetrics; import org.apache.hadoop.hbase.regionserver.Leases.LeaseStillHeldException; -import org.apache.hadoop.hbase.util.Pair; import org.apache.hadoop.hbase.util.Threads; -import org.apache.hadoop.util.StringUtils; -import org.apache.zookeeper.KeeperException; /** * The ServerManager class manages info about region servers - HServerInfo, @@ -89,8 +84,6 @@ public class ServerManager { private final Server master; private final MasterServices services; - private final ServerMonitor serverMonitorThread; - private final LogCleaner logCleaner; // Reporting to track master metrics. @@ -98,32 +91,11 @@ public class ServerManager { final DeadServer deadservers = new DeadServer(); - /** - * Dumps into log current stats on dead servers and number of servers - * TODO: Make this a metric; dump metrics into log. - */ - class ServerMonitor extends Chore { - ServerMonitor(final int period, final Stoppable stopper) { - super("ServerMonitor", period, stopper); - } - - @Override - protected void chore() { - int numServers = countOfRegionServers(); - int numDeadServers = deadservers.size(); - double averageLoad = getAverageLoad(); - String deadServersList = deadservers.toString(); - LOG.info("regionservers=" + numServers + - ", averageload=" + StringUtils.limitDecimalTo2(averageLoad) + - ((numDeadServers > 0)? (", deadservers=" + deadServersList): "")); - } - } - /** * Constructor. * @param master * @param services - * @param metrics + * @param metrics * @param freshClusterStartup True if we are original master on a fresh * cluster startup else if false, we are joining an already running cluster. */ @@ -133,10 +105,7 @@ public class ServerManager { this.services = services; this.metrics = metrics; Configuration c = master.getConfiguration(); - int monitorInterval = c.getInt("hbase.master.monitor.interval", 60 * 1000); - this.serverMonitorThread = new ServerMonitor(monitorInterval, master); String n = Thread.currentThread().getName(); - Threads.setDaemonThreadRunning(this.serverMonitorThread, n + ".serverMonitor"); this.logCleaner = new LogCleaner(c.getInt("hbase.master.cleaner.interval", 60 * 1000), master, c, this.services.getMasterFileSystem().getFileSystem(), @@ -538,7 +507,7 @@ public class ServerManager { * @param server server to open a region * @param region region to open */ - public void sendRegionOpen(HServerInfo server, HRegionInfo region) + public void sendRegionOpen(HServerInfo server, HRegionInfo region) throws IOException { HRegionInterface hri = getServerConnection(server); if (hri == null) { @@ -618,7 +587,7 @@ public class ServerManager { /** * Waits for the regionservers to report in. * @return Count of regions out on cluster - * @throws InterruptedException + * @throws InterruptedException */ public int waitForRegionServers() throws InterruptedException { @@ -681,7 +650,6 @@ public class ServerManager { * Currently just interrupts the ServerMonitor and LogCleaner chores. */ public void stop() { - this.serverMonitorThread.interrupt(); this.logCleaner.interrupt(); } }