You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by zg...@apache.org on 2019/09/02 09:23:39 UTC
[hbase] branch branch-2 updated: HBASE-22642 Make move operations
of RSGroup idempotent (#387)
This is an automated email from the ASF dual-hosted git repository.
zghao pushed a commit to branch branch-2
in repository https://gitbox.apache.org/repos/asf/hbase.git
The following commit(s) were added to refs/heads/branch-2 by this push:
new fae0e18 HBASE-22642 Make move operations of RSGroup idempotent (#387)
fae0e18 is described below
commit fae0e18a7321a5a2379e98e6aae7a04a8b0e567e
Author: linkaline <li...@gmail.com>
AuthorDate: Mon Sep 2 17:15:42 2019 +0800
HBASE-22642 Make move operations of RSGroup idempotent (#387)
Signed-off-by: Guanghao Zhang <zg...@apache.org>
---
.../hadoop/hbase/rsgroup/RSGroupAdminServer.java | 19 +------------------
.../hadoop/hbase/rsgroup/TestRSGroupsAdmin2.java | 18 ++++++------------
2 files changed, 7 insertions(+), 30 deletions(-)
diff --git a/hbase-rsgroup/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupAdminServer.java b/hbase-rsgroup/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupAdminServer.java
index 8b38e72..76541aa 100644
--- a/hbase-rsgroup/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupAdminServer.java
+++ b/hbase-rsgroup/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupAdminServer.java
@@ -162,10 +162,7 @@ public class RSGroupAdminServer implements RSGroupAdmin {
+ " does not exist.");
}
RSGroupInfo srcGrp = new RSGroupInfo(tmpSrcGrp);
- if (srcGrp.getName().equals(targetGroupName)) {
- throw new ConstraintException("Target RSGroup " + targetGroupName +
- " is same as source " + srcGrp.getName() + " RSGroup.");
- }
+
// Only move online servers
checkOnlineServersOnly(servers);
@@ -327,10 +324,6 @@ public class RSGroupAdminServer implements RSGroupAdmin {
throw new ConstraintException("Source RSGroup for server " + firstServer
+ " does not exist.");
}
- if (srcGrp.getName().equals(targetGroupName)) {
- throw new ConstraintException("Target RSGroup " + targetGroupName +
- " is same as source " + srcGrp + " RSGroup.");
- }
// Only move online servers (when moving from 'default') or servers from other
// groups. This prevents bogus servers from entering groups
if (RSGroupInfo.DEFAULT_GROUP.equals(srcGrp.getName())) {
@@ -382,16 +375,6 @@ public class RSGroupAdminServer implements RSGroupAdmin {
throw new ConstraintException("Target RSGroup must have at least one server.");
}
}
-
- for (TableName table : tables) {
- String srcGroup = rsGroupInfoManager.getRSGroupOfTable(table);
- if(srcGroup != null && srcGroup.equals(targetGroup)) {
- throw new ConstraintException(
- "Source RSGroup " + srcGroup + " is same as target " + targetGroup +
- " RSGroup for table " + table);
- }
- LOG.info("Moving table {} to RSGroup {}", table.getNameAsString(), targetGroup);
- }
rsGroupInfoManager.moveTables(tables, targetGroup);
// targetGroup is null when a table is being deleted. In this case no further
diff --git a/hbase-rsgroup/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroupsAdmin2.java b/hbase-rsgroup/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroupsAdmin2.java
index e3f56c5..f86fecf 100644
--- a/hbase-rsgroup/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroupsAdmin2.java
+++ b/hbase-rsgroup/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroupsAdmin2.java
@@ -20,6 +20,7 @@ package org.apache.hadoop.hbase.rsgroup;
import static org.apache.hadoop.hbase.util.Threads.sleep;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
@@ -29,6 +30,7 @@ import java.util.EnumSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.Random;
import java.util.Set;
import java.util.concurrent.atomic.AtomicBoolean;
import org.apache.hadoop.hbase.ClusterMetrics.Option;
@@ -54,6 +56,7 @@ import org.junit.experimental.categories.Category;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.apache.hbase.thirdparty.com.google.common.base.Preconditions;
import org.apache.hbase.thirdparty.com.google.common.collect.Sets;
@Category({ LargeTests.class })
@@ -338,17 +341,9 @@ public class TestRSGroupsAdmin2 extends TestRSGroupsBase {
assertTrue(msg + " " + ex.getMessage(), ex.getMessage().contains(exp));
}
- // test fail server move
- try {
- rsGroupAdmin.moveServersAndTables(Sets.newHashSet(targetServer.getAddress()),
- Sets.newHashSet(tableName), RSGroupInfo.DEFAULT_GROUP);
- fail("servers shouldn't have been successfully moved.");
- } catch (IOException ex) {
- String exp = "Target RSGroup " + RSGroupInfo.DEFAULT_GROUP + " is same as source " +
- RSGroupInfo.DEFAULT_GROUP + " RSGroup.";
- String msg = "Expected '" + exp + "' in exception message: ";
- assertTrue(msg + " " + ex.getMessage(), ex.getMessage().contains(exp));
- }
+ // test move when src = dst
+ rsGroupAdmin.moveServersAndTables(Sets.newHashSet(targetServer.getAddress()),
+ Sets.newHashSet(tableName), RSGroupInfo.DEFAULT_GROUP);
// verify default group info
Assert.assertEquals(oldDefaultGroupServerSize,
@@ -655,5 +650,4 @@ public class TestRSGroupsAdmin2 extends TestRSGroupsBase {
}
});
}
-
}