hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From apurt...@apache.org
Subject svn commit: r774152 - in /hadoop/hbase/trunk: CHANGES.txt src/java/org/apache/hadoop/hbase/master/ServerManager.java
Date Wed, 13 May 2009 00:27:52 GMT
Author: apurtell
Date: Wed May 13 00:27:51 2009
New Revision: 774152

URL: http://svn.apache.org/viewvc?rev=774152&view=rev
Log:
HBASE-1414 Add server status logging chore to ServerManager

Modified:
    hadoop/hbase/trunk/CHANGES.txt
    hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/master/ServerManager.java

Modified: hadoop/hbase/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/CHANGES.txt?rev=774152&r1=774151&r2=774152&view=diff
==============================================================================
--- hadoop/hbase/trunk/CHANGES.txt (original)
+++ hadoop/hbase/trunk/CHANGES.txt Wed May 13 00:27:51 2009
@@ -229,7 +229,9 @@
    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
 

Modified: hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/master/ServerManager.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/master/ServerManager.java?rev=774152&r1=774151&r2=774152&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/master/ServerManager.java (original)
+++ hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/master/ServerManager.java Wed May
13 00:27:51 2009
@@ -27,12 +27,14 @@
 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 @@
 
   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 @@
         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;
   }



Mime
View raw message