-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HBASE-24112 [RSGroup] Support renaming rsgroup #1435
Changes from 2 commits
9c473f0
6105914
d4163d6
65a7b19
1f2ade5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,6 +38,9 @@ public class RSGroupInfo { | |
// Keep servers in a sorted set so has an expected ordering when displayed. | ||
private final SortedSet<Address> servers; | ||
// Keep tables sorted too. | ||
|
||
// TODO: Don't understand why all these should be deprecated. we have table -> rsgroup mapping. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because we do not store the table informations in RSGroupInfo anymore, if you use the new API to get RSGroupInfo, the tables will always be empty. |
||
// Isn't it reasonable to have rsgroup -> tables mapping as well. Any contradictory? | ||
/** | ||
* @deprecated Since 3.0.0, will be removed in 4.0.0. The rsgroup information will be stored in | ||
* the configuration of a table so this will be removed. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -468,4 +468,33 @@ public boolean evaluate() throws Exception { | |
// Cleanup | ||
TEST_UTIL.deleteTable(tn1); | ||
} | ||
|
||
@Test | ||
public void testRenameRSGroup() throws Exception { | ||
// Add rsgroup, and assign 2 servers and a table to it. | ||
RSGroupInfo oldgroup = addGroup("oldgroup", 2); | ||
TableName tb = TableName.valueOf("testRename"); | ||
TEST_UTIL.createTable(tb, "tr"); | ||
ADMIN.setRSGroup(Sets.newHashSet(tb), oldgroup.getName()); | ||
TEST_UTIL.waitFor(1000, | ||
(Waiter.Predicate<Exception>) () -> | ||
ADMIN.getRSGroup("oldgroup").getServers().size() == 2); | ||
oldgroup = ADMIN.getRSGroup(oldgroup.getName()); | ||
assertEquals(2, oldgroup.getServers().size()); | ||
assertEquals(oldgroup.getName(), ADMIN.getRSGroup(tb).getName()); | ||
|
||
// Rename rsgroup | ||
ADMIN.renameRSGroup(oldgroup.getName(), "newgroup"); | ||
Set<Address> servers = oldgroup.getServers(); | ||
RSGroupInfo newgroup = ADMIN.getRSGroup("newgroup"); | ||
assertEquals(servers.size(), newgroup.getServers().size()); | ||
int match = 0; | ||
for (Address addr : newgroup.getServers()) { | ||
if (servers.contains(addr)) { | ||
match++; | ||
} | ||
} | ||
assertEquals(servers.size(), match); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this redundant assert? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The for loop above is to check the servers are exactly the same before renaming. And the match is the number of 「exactly the same」. Not redundant regarding to its purpose. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes I agree this is useful assertion. Actually I was wondering if we can add more context to this test as well as assertions. For example, we create and assign another table to another rsgroup. So the "if" clause checking rsgroup name in
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Get your idea. Fixed in new commit. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes the test now is very comprehensive. Thanks, |
||
assertEquals(newgroup.getName(), ADMIN.getRSGroup(tb).getName()); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you like to provide any validation for both strings? e.g. non-empty
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is ok to leave it as it is, server side will throw ConstraintException if both are empty. Other methods like addRSGroup neither checks non-empty.