hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From apurt...@apache.org
Subject svn commit: r1352981 - /hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/master/HMaster.java
Date Fri, 22 Jun 2012 17:39:14 GMT
Author: apurtell
Date: Fri Jun 22 17:39:13 2012
New Revision: 1352981

URL: http://svn.apache.org/viewvc?rev=1352981&view=rev
Log:
HBASE-6246. Admin.move without specifying destination does not go through AccessController
(rajeshbabu)

Modified:
    hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/master/HMaster.java

Modified: hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/master/HMaster.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/master/HMaster.java?rev=1352981&r1=1352980&r2=1352981&view=diff
==============================================================================
--- hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/master/HMaster.java (original)
+++ hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/master/HMaster.java Fri Jun
22 17:39:13 2012
@@ -1086,35 +1086,36 @@ Server {
       this.assignmentManager.getAssignment(encodedRegionName);
     if (p == null)
       throw new UnknownRegionException(Bytes.toStringBinary(encodedRegionName));
-    HRegionInfo hri = p.getFirst();
     ServerName dest = null;
     if (destServerName == null || destServerName.length == 0) {
-      LOG.info("Passed destination servername is null/empty so " +
-        "choosing a server at random");
-      this.assignmentManager.clearRegionPlan(hri);
-      // Unassign will reassign it elsewhere choosing random server.
-      this.assignmentManager.unassign(hri);
-    } else {
-      dest = new ServerName(Bytes.toString(destServerName));
-      try {
-        if (this.cpHost != null) {
-          if (this.cpHost.preMove(p.getFirst(), p.getSecond(), dest)) {
-            return;
-          }
-        }
-        RegionPlan rp = new RegionPlan(p.getFirst(), p.getSecond(), dest);
-        LOG.info("Added move plan " + rp + ", running balancer");
-        this.assignmentManager.balance(rp);
-        if (this.cpHost != null) {
-          this.cpHost.postMove(p.getFirst(), p.getSecond(), dest);
+      LOG.info("Passed destination servername is null or empty so choosing a server at random");
+      List<ServerName> destServers = this.serverManager.getOnlineServersList();
+      destServers.remove(p.getSecond());
+      // If i have only one RS then destination can be null.
+      dest = balancer.randomAssignment(destServers);
+    }
+    
+    // Now we can do the move
+    RegionPlan rp = new RegionPlan(p.getFirst(), p.getSecond(), dest);
+    
+    try {
+      if (this.cpHost != null) {
+        if (this.cpHost.preMove(p.getFirst(), p.getSecond(), dest)) {
+          return;
         }
-      } catch (IOException ioe) {
-        UnknownRegionException ure = new UnknownRegionException(
-            Bytes.toStringBinary(encodedRegionName));
-        ure.initCause(ioe);
-        throw ure;
       }
+      LOG.info("Added move plan " + rp + ", running balancer");
+      this.assignmentManager.balance(rp);
+      if (this.cpHost != null) {
+        this.cpHost.postMove(p.getFirst(), p.getSecond(), dest);
+      }
+    } catch (IOException ioe) {
+      UnknownRegionException ure = new UnknownRegionException(
+          Bytes.toStringBinary(encodedRegionName));
+      ure.initCause(ioe);
+      throw ure;
     }
+
   }
 
   public void createTable(HTableDescriptor hTableDescriptor,



Mime
View raw message