HBASE-22642 Make move operations of RSGroup idempotent (#387)
Signed-off-by: Guanghao Zhang <zghao@apache.org>
This commit is contained in:
parent
076bfa1cc6
commit
fae0e18a73
|
@ -162,10 +162,7 @@ public class RSGroupAdminServer implements RSGroupAdmin {
|
||||||
+ " does not exist.");
|
+ " does not exist.");
|
||||||
}
|
}
|
||||||
RSGroupInfo srcGrp = new RSGroupInfo(tmpSrcGrp);
|
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
|
// Only move online servers
|
||||||
checkOnlineServersOnly(servers);
|
checkOnlineServersOnly(servers);
|
||||||
|
|
||||||
|
@ -327,10 +324,6 @@ public class RSGroupAdminServer implements RSGroupAdmin {
|
||||||
throw new ConstraintException("Source RSGroup for server " + firstServer
|
throw new ConstraintException("Source RSGroup for server " + firstServer
|
||||||
+ " does not exist.");
|
+ " 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
|
// Only move online servers (when moving from 'default') or servers from other
|
||||||
// groups. This prevents bogus servers from entering groups
|
// groups. This prevents bogus servers from entering groups
|
||||||
if (RSGroupInfo.DEFAULT_GROUP.equals(srcGrp.getName())) {
|
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.");
|
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);
|
rsGroupInfoManager.moveTables(tables, targetGroup);
|
||||||
|
|
||||||
// targetGroup is null when a table is being deleted. In this case no further
|
// targetGroup is null when a table is being deleted. In this case no further
|
||||||
|
|
|
@ -20,6 +20,7 @@ package org.apache.hadoop.hbase.rsgroup;
|
||||||
import static org.apache.hadoop.hbase.util.Threads.sleep;
|
import static org.apache.hadoop.hbase.util.Threads.sleep;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
|
import static org.junit.Assert.assertNotEquals;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
import static org.junit.Assert.fail;
|
import static org.junit.Assert.fail;
|
||||||
|
|
||||||
|
@ -29,6 +30,7 @@ import java.util.EnumSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Random;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
import org.apache.hadoop.hbase.ClusterMetrics.Option;
|
import org.apache.hadoop.hbase.ClusterMetrics.Option;
|
||||||
|
@ -54,6 +56,7 @@ import org.junit.experimental.categories.Category;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import org.apache.hbase.thirdparty.com.google.common.base.Preconditions;
|
||||||
import org.apache.hbase.thirdparty.com.google.common.collect.Sets;
|
import org.apache.hbase.thirdparty.com.google.common.collect.Sets;
|
||||||
|
|
||||||
@Category({ LargeTests.class })
|
@Category({ LargeTests.class })
|
||||||
|
@ -338,17 +341,9 @@ public class TestRSGroupsAdmin2 extends TestRSGroupsBase {
|
||||||
assertTrue(msg + " " + ex.getMessage(), ex.getMessage().contains(exp));
|
assertTrue(msg + " " + ex.getMessage(), ex.getMessage().contains(exp));
|
||||||
}
|
}
|
||||||
|
|
||||||
// test fail server move
|
// test move when src = dst
|
||||||
try {
|
|
||||||
rsGroupAdmin.moveServersAndTables(Sets.newHashSet(targetServer.getAddress()),
|
rsGroupAdmin.moveServersAndTables(Sets.newHashSet(targetServer.getAddress()),
|
||||||
Sets.newHashSet(tableName), RSGroupInfo.DEFAULT_GROUP);
|
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));
|
|
||||||
}
|
|
||||||
|
|
||||||
// verify default group info
|
// verify default group info
|
||||||
Assert.assertEquals(oldDefaultGroupServerSize,
|
Assert.assertEquals(oldDefaultGroupServerSize,
|
||||||
|
@ -655,5 +650,4 @@ public class TestRSGroupsAdmin2 extends TestRSGroupsBase {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue