virajjasani commented on a change in pull request #1523: HBASE-24195 : Admin.getRegionServers() should return live servers exc… URL: https://github.com/apache/hbase/pull/1523#discussion_r409412800
########## File path: hbase-client/src/main/java/org/apache/hadoop/hbase/client/Admin.java ########## @@ -1064,7 +1067,31 @@ default ServerName getMaster() throws IOException { * @throws IOException if a remote or network exception occurs */ default Collection<ServerName> getRegionServers() throws IOException { - return getClusterMetrics(EnumSet.of(Option.SERVERS_NAME)).getServersName(); + return getRegionServers(false); + } + + /** + * Retrieve all current live region servers including decommissioned + * if excludeDecommissionedRS is false, else non-decommissioned ones only + * + * @param excludeDecommissionedRS should we exclude decommissioned RS nodes + * @return all current live region servers including/excluding decommissioned hosts + * @throws IOException if a remote or network exception occurs + */ + default Collection<ServerName> getRegionServers(boolean excludeDecommissionedRS) + throws IOException { + List<ServerName> allServers = + getClusterMetrics(EnumSet.of(Option.SERVERS_NAME)).getServersName(); + if (!excludeDecommissionedRS) { + return allServers; + } + List<ServerName> decommissionedRegionServers = listDecommissionedRegionServers(); + if (CollectionUtils.isNotEmpty(decommissionedRegionServers)) { Review comment: The reason why I am copying (`new ArrayList<>(allServers)`) is because `allServers` is unmodifiable list. So `ImmutableList.toImmutableList()` seems to be solving our problem. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services