hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ramkris...@apache.org
Subject svn commit: r1328458 - in /hbase/trunk/src: main/java/org/apache/hadoop/hbase/master/HMaster.java test/java/org/apache/hadoop/hbase/client/TestAdmin.java
Date Fri, 20 Apr 2012 17:36:03 GMT
Author: ramkrishna
Date: Fri Apr 20 17:36:02 2012
New Revision: 1328458

URL: http://svn.apache.org/viewvc?rev=1328458&view=rev
Log:
HBASE-5809 Avoid move api to take the destination server same as the source server. (Rajesh)

Modified:
    hbase/trunk/src/main/java/org/apache/hadoop/hbase/master/HMaster.java
    hbase/trunk/src/test/java/org/apache/hadoop/hbase/client/TestAdmin.java

Modified: hbase/trunk/src/main/java/org/apache/hadoop/hbase/master/HMaster.java
URL: http://svn.apache.org/viewvc/hbase/trunk/src/main/java/org/apache/hadoop/hbase/master/HMaster.java?rev=1328458&r1=1328457&r2=1328458&view=diff
==============================================================================
--- hbase/trunk/src/main/java/org/apache/hadoop/hbase/master/HMaster.java (original)
+++ hbase/trunk/src/main/java/org/apache/hadoop/hbase/master/HMaster.java Fri Apr 20 17:36:02
2012
@@ -1174,6 +1174,11 @@ Server {
       this.assignmentManager.unassign(hri);
     } else {
       dest = new ServerName(Bytes.toString(destServerName));
+      if (dest.equals(p.getSecond())) {
+        LOG.debug("Skipping move of region " + hri.getRegionNameAsString()
+            + " because region already assigned to the same server " + dest +".");
+        return;
+      }
       try {
         if (this.cpHost != null) {
           if (this.cpHost.preMove(p.getFirst(), p.getSecond(), dest)) {

Modified: hbase/trunk/src/test/java/org/apache/hadoop/hbase/client/TestAdmin.java
URL: http://svn.apache.org/viewvc/hbase/trunk/src/test/java/org/apache/hadoop/hbase/client/TestAdmin.java?rev=1328458&r1=1328457&r2=1328458&view=diff
==============================================================================
--- hbase/trunk/src/test/java/org/apache/hadoop/hbase/client/TestAdmin.java (original)
+++ hbase/trunk/src/test/java/org/apache/hadoop/hbase/client/TestAdmin.java Fri Apr 20 17:36:02
2012
@@ -43,6 +43,8 @@ import org.apache.hadoop.hbase.*;
 import org.apache.hadoop.hbase.executor.EventHandler;
 import org.apache.hadoop.hbase.executor.EventHandler.EventType;
 import org.apache.hadoop.hbase.executor.ExecutorService;
+import org.apache.hadoop.hbase.master.AssignmentManager;
+import org.apache.hadoop.hbase.master.HMaster;
 import org.apache.hadoop.hbase.master.MasterServices;
 import org.apache.hadoop.hbase.regionserver.HRegion;
 import org.apache.hadoop.hbase.regionserver.HRegionServer;
@@ -1404,6 +1406,22 @@ public class TestAdmin {
     assertTrue(("actual count: " + count), count <= 2);
   }
 
+  @Test
+  public void testMoveToPreviouslyAssignedRS() throws IOException {
+    byte[] tableName = Bytes.toBytes("testMoveToPreviouslyAssignedRS");
+    MiniHBaseCluster cluster = TEST_UTIL.getHBaseCluster();
+    HMaster master = cluster.getMaster();
+    HBaseAdmin localAdmin = createTable(tableName);
+    List<HRegionInfo> tableRegions = localAdmin.getTableRegions(tableName);
+    HRegionInfo hri = tableRegions.get(0);
+    AssignmentManager am = master.getAssignmentManager();
+    ServerName server = am.getRegionServerOfRegion(hri);
+    localAdmin.move(hri.getEncodedNameAsBytes(), Bytes.toBytes(server.getServerName()));
+    assertEquals("Current region server and region server before move should be same.", server,
+        am.getRegionServerOfRegion(hri));
+  }
+
+
   private void setUpforLogRolling() {
     // Force a region split after every 768KB
     TEST_UTIL.getConfiguration().setLong(HConstants.HREGION_MAX_FILESIZE,



Mime
View raw message