hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mbau...@apache.org
Subject svn commit: r1333197 - in /hbase/branches/0.89-fb/src/main: java/org/apache/hadoop/hbase/master/ resources/hbase-webapps/master/
Date Wed, 02 May 2012 20:52:29 GMT
Author: mbautin
Date: Wed May  2 20:52:28 2012
New Revision: 1333197

URL: http://svn.apache.org/viewvc?rev=1333197&view=rev
Log:
[master] Sort the assignment plan if necessary

Author: liyintang

Summary:
After investigating some issues in DL cluster, we found the compareTo function in RegionInfo
is quite expensive.
So it would be more efficient to use a hashmap instead of tree map inside of the assignment
plan and only sort the assignment plan if necessary.

Test Plan:
tested in dev cluster
run all the unit tests

Reviewers: kannan

Reviewed By: kannan

CC: hbase-eng@, aaiyer

Differential Revision: https://phabricator.fb.com/D460858

Modified:
    hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/master/AssignmentPlan.java
    hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/master/RegionAssignmentSnapshot.java
    hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/master/RegionPlacement.java
    hbase/branches/0.89-fb/src/main/resources/hbase-webapps/master/assignmentPlan.jsp

Modified: hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/master/AssignmentPlan.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/master/AssignmentPlan.java?rev=1333197&r1=1333196&r2=1333197&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/master/AssignmentPlan.java
(original)
+++ hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/master/AssignmentPlan.java
Wed May  2 20:52:28 2012
@@ -26,7 +26,6 @@ import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
-import java.util.TreeMap;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -64,7 +63,7 @@ public class AssignmentPlan implements W
   };
 
   public AssignmentPlan() {
-    assignmentMap = new TreeMap<HRegionInfo, List<HServerAddress>>();
+    assignmentMap = new HashMap<HRegionInfo, List<HServerAddress>>();
     assignmentUpdateTS = new HashMap<HRegionInfo, Long>();
   }
 
@@ -179,9 +178,9 @@ public class AssignmentPlan implements W
    * @return the mapping between each region to its favored region server list
    */
   public synchronized Map<HRegionInfo, List<HServerAddress>> getAssignmentMap()
{
-    return assignmentMap;
+    return this.assignmentMap;
   }
-
+  
   @Override
   public void write(DataOutput out) throws IOException {
     out.writeInt(VERSION);

Modified: hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/master/RegionAssignmentSnapshot.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/master/RegionAssignmentSnapshot.java?rev=1333197&r1=1333196&r2=1333197&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/master/RegionAssignmentSnapshot.java
(original)
+++ hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/master/RegionAssignmentSnapshot.java
Wed May  2 20:52:28 2012
@@ -25,6 +25,7 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
+import java.util.TreeMap;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -63,7 +64,7 @@ public class RegionAssignmentSnapshot {
     tableToRegionMap = new HashMap<String, List<HRegionInfo>>();
     regionToRegionServerMap = new HashMap<HRegionInfo, HServerAddress>();
     regionServerToRegionMap = new HashMap<HServerAddress, List<HRegionInfo>>();
-    regionNameToRegionInfoMap = new HashMap<String, HRegionInfo>();
+    regionNameToRegionInfoMap = new TreeMap<String, HRegionInfo>();
     exsitingAssignmentPlan = new AssignmentPlan();
     globalAssignmentDomain = new AssignmentDomain(conf);
   }

Modified: hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/master/RegionPlacement.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/master/RegionPlacement.java?rev=1333197&r1=1333196&r2=1333197&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/master/RegionPlacement.java
(original)
+++ hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/master/RegionPlacement.java
Wed May  2 20:52:28 2012
@@ -9,6 +9,7 @@ import java.util.List;
 import java.util.Map;
 import java.util.Random;
 import java.util.Set;
+import java.util.TreeMap;
 
 import org.apache.commons.cli.CommandLine;
 import org.apache.commons.cli.GnuParser;
@@ -721,10 +722,12 @@ public class RegionPlacement implements 
    */
   public static String getFavoredNodes(List<HServerAddress> serverAddrList) {
     String favoredNodes = "";
-    for (int i = 0 ; i < serverAddrList.size(); i++) {
-      favoredNodes += serverAddrList.get(i).getHostNameWithPort();
-      if (i != serverAddrList.size() - 1 ) {
-        favoredNodes += ",";
+    if (serverAddrList != null) {
+      for (int i = 0 ; i < serverAddrList.size(); i++) {
+        favoredNodes += serverAddrList.get(i).getHostNameWithPort();
+        if (i != serverAddrList.size() - 1 ) {
+          favoredNodes += ",";
+        }
       }
     }
     return favoredNodes;
@@ -804,9 +807,10 @@ public class RegionPlacement implements 
   public static void printAssignmentPlan(AssignmentPlan plan) {
     if (plan == null) return;
     LOG.info("========== Start to print the assignment plan ================");
+    // sort the map based on region info
     Map<HRegionInfo, List<HServerAddress>> assignmentMap =
-      plan.getAssignmentMap();
-
+      new TreeMap<HRegionInfo, List<HServerAddress>>(plan.getAssignmentMap());
+    
     for (Map.Entry<HRegionInfo, List<HServerAddress>> entry :
       assignmentMap.entrySet()) {
       String serverList = RegionPlacement.getFavoredNodes(entry.getValue());

Modified: hbase/branches/0.89-fb/src/main/resources/hbase-webapps/master/assignmentPlan.jsp
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/main/resources/hbase-webapps/master/assignmentPlan.jsp?rev=1333197&r1=1333196&r2=1333197&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/main/resources/hbase-webapps/master/assignmentPlan.jsp (original)
+++ hbase/branches/0.89-fb/src/main/resources/hbase-webapps/master/assignmentPlan.jsp Wed
May  2 20:52:28 2012
@@ -104,13 +104,15 @@
 			<tr>
 			<th>Region Name</th> <th>Position</th> <th>Primary RS</th>
<th>Secondary RS</th> <th>Tertiary RS</th>  <th>Actions</th>
 			</tr>
-<%				for(Map.Entry<HRegionInfo, List<HServerAddress>> entry : assignmentMap.entrySet()
) {
-					List<HServerAddress> favoredNodeList = entry.getValue();
-					favoredNodes =  RegionPlacement.getFavoredNodes(favoredNodeList);
-						regionName = entry.getKey().getRegionNameAsString();
-						HServerAddress currentRS = currentAssignment.get(entry.getKey());
+<%				
+					for (Map.Entry<String, HRegionInfo> entry : regionNameToRegionInfoMap.entrySet())
{
+						HRegionInfo regionInfo = entry.getValue();
+						List<HServerAddress> favoredNodeList = assignmentMap.get(regionInfo);
+						regionName = regionInfo.getRegionNameAsString();
+						HServerAddress currentRS = currentAssignment.get(regionInfo);
 						String position = "Not Assigned";
-						AssignmentPlan.POSITION favoredNodePosition = AssignmentPlan.getFavoredServerPosition(favoredNodeList,
currentRS);
+						AssignmentPlan.POSITION favoredNodePosition =
+							AssignmentPlan.getFavoredServerPosition(favoredNodeList, currentRS);
 						if (favoredNodePosition == null) {
 							position = "Not on FavoredNode";
 						} else {



Mime
View raw message