-
Notifications
You must be signed in to change notification settings - Fork 3.4k
HBASE-24195 : Admin.getRegionServers() should return live servers exc… #1523
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
Changes from 1 commit
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 |
|---|---|---|
|
|
@@ -25,6 +25,7 @@ | |
| import java.io.IOException; | ||
| import java.util.ArrayList; | ||
| import java.util.Collection; | ||
| import java.util.Collections; | ||
| import java.util.EnumSet; | ||
| import java.util.HashMap; | ||
| import java.util.HashSet; | ||
|
|
@@ -864,4 +865,42 @@ public void testSlowLogResponses() throws Exception { | |
| Assert.assertEquals(onlineLogRecords.size(), 0); | ||
| } | ||
|
|
||
| @Test | ||
| public void testGetRegionServers() throws Exception { | ||
| // get all live server names | ||
| List<ServerName> serverNames = new ArrayList<>(ADMIN.getRegionServers(true)); | ||
| Assert.assertEquals(3, serverNames.size()); | ||
|
|
||
| List<ServerName> serversToDecom = new ArrayList<>(); | ||
| ServerName serverToDecommission = serverNames.get(0); | ||
|
|
||
| serversToDecom.add(serverToDecommission); | ||
| ADMIN.decommissionRegionServers(serversToDecom, false); | ||
| waitForServerDecom(serverToDecommission, true); | ||
|
|
||
| Assert.assertEquals(2, ADMIN.getRegionServers(true).size()); | ||
|
|
||
|
Member
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. Add
Contributor
Author
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. Sure, definitely |
||
| ADMIN.recommissionRegionServer(serverToDecommission, Collections.emptyList()); | ||
|
|
||
| Assert.assertEquals(3, ADMIN.getRegionServers(true).size()); | ||
| waitForServerDecom(serverToDecommission, false); | ||
|
Member
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. Why wait for decommission this server in the end?
Member
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. I was thinking the assertion
Contributor
Author
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.
Actually, we are waiting for server to be recommissioned (maybe method name not correct, last arg determines). Let me change the order. |
||
| } | ||
|
|
||
| private static void waitForServerDecom(ServerName excludeServer, | ||
| boolean anyServerDecommissioned) { | ||
| TEST_UTIL.waitFor(3000, () -> { | ||
|
HorizonNet marked this conversation as resolved.
|
||
| try { | ||
| List<ServerName> decomServers = TEST_UTIL.getAdmin().listDecommissionedRegionServers(); | ||
| if (anyServerDecommissioned) { | ||
| return decomServers.size() == 1 | ||
| && decomServers.get(0).equals(excludeServer); | ||
| } else { | ||
| return decomServers.size() == 0; | ||
| } | ||
| } catch (IOException e) { | ||
| throw new RuntimeException(e); | ||
| } | ||
| }); | ||
| } | ||
|
|
||
| } | ||
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.
to
I think this will save one time full copy (previous code copy twice, and this copies just once). Need to confirm.
Uh oh!
There was an error while loading. Please reload this page.
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.
The reason behind copy (
new ArrayList<>(allServers)) was makingallServersunmodifiable list. SoImmutableList.toImmutableList()seems to be solving our problem.