hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mbau...@apache.org
Subject svn commit: r1328559 - in /hbase/branches/0.89-fb: bin/ src/main/java/org/apache/hadoop/hbase/master/ src/main/java/org/apache/hadoop/hbase/regionserver/
Date Sat, 21 Apr 2012 01:31:20 GMT
Author: mbautin
Date: Sat Apr 21 01:31:19 2012
New Revision: 1328559

URL: http://svn.apache.org/viewvc?rev=1328559&view=rev
Log:
[master] A cmd line tool to customize and update the assignment plan

Summary:
D448467 (An easy interface to customize the region assignment plan) provides a web based interface
to customize the assignment plan. This diff is to provide a command line tool to update the
assignment plan as well.

Usage: hbase RegionPlacement -update -r region_name -f favoredNodes

For example:
hbase RegionPlacement -update -r t3,ff258b2f,1333644889988.d85269307a5ebfcc711d0f688738e748.
-f msgstore312.snc4.facebook.com:60020,msgstore331.snc4.facebook.com:60020,msgstore335.snc4.facebook.com:60020

Test Plan: Tested in migration cluster

Reviewers: kannan

Reviewed By: kannan

CC: hbase-eng@, hbase-ops@lists, rthiessen

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

Modified:
    hbase/branches/0.89-fb/bin/hbase
    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/RegionPlacement.java
    hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java

Modified: hbase/branches/0.89-fb/bin/hbase
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/bin/hbase?rev=1328559&r1=1328558&r2=1328559&view=diff
==============================================================================
--- hbase/branches/0.89-fb/bin/hbase (original)
+++ hbase/branches/0.89-fb/bin/hbase Sat Apr 21 01:31:19 2012
@@ -77,7 +77,7 @@ if [ $# = 0 ]; then
   echo "  migrate          upgrade an hbase.rootdir"
   echo "  hbck             run the hbase 'fsck' tool"
   echo "  localityck	     run the hbase locality check tool"
-  echo "  region_placement run the hbase region placement tool"
+  echo "  RegionPlacement  run the hbase region placement tool"
   echo "  verify [-help]   verify that the cluster is working properly"
   echo " or"
   echo "  CLASSNAME        run the class named CLASSNAME"
@@ -265,7 +265,7 @@ elif [ "$COMMAND" = "hbck" ] ; then
   CLASS='org.apache.hadoop.hbase.client.HBaseFsck'
 elif [ "$COMMAND" = "localityck" ] ; then
   CLASS='org.apache.hadoop.hbase.client.HBaseLocalityCheck'
-elif [ "$COMMAND" = "region_placement" ] ; then
+elif [ "$COMMAND" = "RegionPlacement" ] ; then
   CLASS='org.apache.hadoop.hbase.master.RegionPlacement'
 elif [ "$COMMAND" = "verify" ] ; then
   CLASS='org.apache.hadoop.hbase.loadtest.LoadTester'

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=1328559&r1=1328558&r2=1328559&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
Sat Apr 21 01:31:19 2012
@@ -104,6 +104,7 @@ public class AssignmentPlan implements W
       this.updateAssignmentPlan(regionInfo, serverList);
     }
   }
+
   /**
    * Add an assignment to the plan
    * @param region

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=1328559&r1=1328558&r2=1328559&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
Sat Apr 21 01:31:19 2012
@@ -628,25 +628,34 @@ public class RegionPlacement implements 
       currentAssignment.entrySet()) {
       try {
         // Keep track of the favored updates for the current region server
-        AssignmentPlan singleServerPlan = new AssignmentPlan();
-
+        AssignmentPlan singleServerPlan = null;
         // Find out all the updates for the current region server
         for (HRegionInfo region : entry.getValue()) {
           List<HServerAddress> favoredServerList = plan.getAssignment(region);
-          singleServerPlan.updateAssignmentPlan(region, favoredServerList);
-        }
+          if (favoredServerList != null &&
+              favoredServerList.size() == HConstants.FAVORED_NODES_NUM) {
+            // Create the single server plan if necessary
+            if (singleServerPlan == null) {
+              singleServerPlan = new AssignmentPlan();
+            }
+            // Update the single server update
+            singleServerPlan.updateAssignmentPlan(region, favoredServerList);
+          }
 
-        // Update the current region server with its updated favored nodes
-        HRegionInterface currentRegionServer =
-          connection.getHRegionConnection(entry.getKey());
-        int updatedRegionNum =
-          currentRegionServer.updateFavoredNodes(singleServerPlan);
-        LOG.info("Region server " +
-            currentRegionServer.getHServerInfo().getHostnamePort() +
-            " has updated " + updatedRegionNum + " / " +
-            singleServerPlan.getAssignmentMap().size() +
-            " regions with the assignment plan");
-        succeededNum ++;
+        }
+        if (singleServerPlan != null) {
+          // Update the current region server with its updated favored nodes
+          HRegionInterface currentRegionServer =
+            connection.getHRegionConnection(entry.getKey());
+          int updatedRegionNum =
+            currentRegionServer.updateFavoredNodes(singleServerPlan);
+          LOG.info("Region server " +
+              currentRegionServer.getHServerInfo().getHostnamePort() +
+              " has updated " + updatedRegionNum + " / " +
+              singleServerPlan.getAssignmentMap().size() +
+              " regions with the assignment plan");
+          succeededNum ++;
+        }
       } catch (Exception e) {
         failedUpdateMap.put(entry.getKey(), e);
       }
@@ -821,6 +830,12 @@ public class RegionPlacement implements 
     opt.addOption("d", "verification-details", false,
         "print the details of verification report");
 
+    opt.addOption("update", false,
+      "Update the favored nodes for a single region," +
+      "for example: -update -r regionName -f server1:port,server2:port,server3:port");
+    opt.addOption("r", true, "The region name that needs to be updated");
+    opt.addOption("f", true, "The new favored nodes");
+
     opt.addOption("tables", true,
         "The list of table names splitted by ',' ;" +
         "For example: -tables: t1,t2,...,tn");
@@ -888,7 +903,33 @@ public class RegionPlacement implements 
       } else if (cmd.hasOption("p") || cmd.hasOption("print")) {
         AssignmentPlan plan = rp.getExistingAssignmentPlan();
         RegionPlacement.printAssignmentPlan(plan);
-      } else {
+      } else if (cmd.hasOption("update")) {
+
+        if (!cmd.hasOption("f") || !cmd.hasOption("r")) {
+          throw new IllegalArgumentException("Please specify: " +
+			" -update -r regionName -f server1:port,server2:port,server3:port");
+        }
+
+        String regionName = cmd.getOptionValue("r");
+        String favoredNodesStr = cmd.getOptionValue("f");
+        LOG.info("Going to update the region " + regionName + " with the new favored nodes
" +
+            favoredNodesStr);
+        List<HServerAddress> favoredNodes = null;
+        HRegionInfo regionInfo =
+          rp.getRegionAssignmentSnapshot().getRegionNameToRegionInfoMap().get(regionName);
+        if (regionInfo == null) {
+          LOG.error("Cannot find the region " + regionName + " from the META");
+        } else {
+          try {
+            favoredNodes = RegionPlacement.getFavoredNodeList(favoredNodesStr);
+          } catch (IllegalArgumentException e) {
+            LOG.error("Cannot parse the invalid favored nodes because " + e);
+          }
+          AssignmentPlan newPlan = new AssignmentPlan();
+          newPlan.updateAssignmentPlan(regionInfo, favoredNodes);
+          rp.updateAssignmentPlan(newPlan);
+        }
+      }else {
         printHelp(opt);
       }
     } catch (ParseException e) {
@@ -898,8 +939,8 @@ public class RegionPlacement implements 
 
   private static void printHelp(Options opt) {
     new HelpFormatter().printHelp(
-        "RegionPlacement < -w | -n | -v | -t | -h >" +
-        "[-l false] [-m false] [-d] [-tables t1,t2,...tn]", opt);
+        "RegionPlacement < -w | -n | -v | -t | -h | -update -r regionName -f favoredNodes
>" +
+        " [-l false] [-m false] [-d] [-tables t1,t2,...tn]", opt);
   }
 
   /**

Modified: hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java?rev=1328559&r1=1328558&r2=1328559&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
(original)
+++ hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
Sat Apr 21 01:31:19 2012
@@ -84,7 +84,6 @@ import org.apache.hadoop.hbase.Leases.Le
 import org.apache.hadoop.hbase.LocalHBaseCluster;
 import org.apache.hadoop.hbase.NotServingRegionException;
 import org.apache.hadoop.hbase.RemoteExceptionHandler;
-import org.apache.hadoop.hbase.StopStatus;
 import org.apache.hadoop.hbase.Stoppable;
 import org.apache.hadoop.hbase.UnknownRowLockException;
 import org.apache.hadoop.hbase.UnknownScannerException;
@@ -3040,7 +3039,7 @@ public class HRegionServer implements HR
 
       if (region == null) {
         LOG.warn("Region " + entry.getKey().getRegionNameAsString() +
-            " is not running on this" + this.serverInfo.getHostnamePort()
+            " is not running on this " + this.serverInfo.getHostnamePort()
             + " region server any more !");
         continue;
       }



Mime
View raw message