hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject svn commit: r800676 - in /hadoop/hbase/trunk: CHANGES.txt bin/HBase.rb src/java/org/apache/hadoop/hbase/ClusterStatus.java src/java/org/apache/hadoop/hbase/master/HMaster.java src/java/org/apache/hadoop/hbase/master/RegionManager.java
Date Tue, 04 Aug 2009 05:09:27 GMT
Author: stack
Date: Tue Aug  4 05:09:27 2009
New Revision: 800676

URL: http://svn.apache.org/viewvc?rev=800676&view=rev
Log:
HBASE-1743 [debug tool] Add regionsInTransition list to ClusterStatus detailed output

Modified:
    hadoop/hbase/trunk/CHANGES.txt
    hadoop/hbase/trunk/bin/HBase.rb
    hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/ClusterStatus.java
    hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/master/HMaster.java
    hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/master/RegionManager.java

Modified: hadoop/hbase/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/CHANGES.txt?rev=800676&r1=800675&r2=800676&view=diff
==============================================================================
--- hadoop/hbase/trunk/CHANGES.txt (original)
+++ hadoop/hbase/trunk/CHANGES.txt Tue Aug  4 05:09:27 2009
@@ -546,6 +546,8 @@
    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

Modified: hadoop/hbase/trunk/bin/HBase.rb
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/bin/HBase.rb?rev=800676&r1=800675&r2=800676&view=diff
==============================================================================
--- hadoop/hbase/trunk/bin/HBase.rb (original)
+++ hadoop/hbase/trunk/bin/HBase.rb Tue Aug  4 05:09:27 2009
@@ -270,6 +270,11 @@
       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" % \

Modified: hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/ClusterStatus.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/ClusterStatus.java?rev=800676&r1=800675&r2=800676&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/ClusterStatus.java (original)
+++ hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/ClusterStatus.java Tue Aug  4 05:09:27
2009
@@ -26,6 +26,10 @@
 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 @@
  * <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 @@
   private String hbaseVersion;
   private Collection<HServerInfo> liveServerInfo;
   private Collection<String> deadServers;
+  private NavigableMap<String, String> intransition;
 
   /**
    * Constructor, for Writable
@@ -191,6 +197,14 @@
     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 @@
     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 @@
     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);
+    }
   }
-}
+}
\ No newline at end of file

Modified: hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/master/HMaster.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/master/HMaster.java?rev=800676&r1=800675&r2=800676&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/master/HMaster.java (original)
+++ hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/master/HMaster.java Tue Aug  4 05:09:27
2009
@@ -1053,6 +1053,7 @@
     status.setHBaseVersion(VersionInfo.getVersion());
     status.setServerInfo(serverManager.serversToServerInfo.values());
     status.setDeadServers(serverManager.deadServers);
+    status.setRegionsInTransition(this.regionManager.getRegionsInTransition());
     return status;
   }
 

Modified: hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/master/RegionManager.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/master/RegionManager.java?rev=800676&r1=800675&r2=800676&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/master/RegionManager.java (original)
+++ hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/master/RegionManager.java Tue Aug
 4 05:09:27 2009
@@ -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.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 @@
       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 @@
       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



Mime
View raw message