[
https://issues.apache.org/jira/browse/HBASE-22009?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Xiang Li updated HBASE-22009:
-----------------------------
Description:
{code:title=RSGroupInfoManagerImpl.java|borderStyle=solid}
private SortedSet<Address> getDefaultServers() throws IOException {
SortedSet<Address> defaultServers = Sets.newTreeSet();
for (ServerName serverName : getOnlineRS()) {
Address server = Address.fromParts(serverName.getHostname(),
serverName.getPort());
boolean found = false;
for (RSGroupInfo rsgi : listRSGroups()) {
if (!RSGroupInfo.DEFAULT_GROUP.equals(rsgi.getName()) &&
rsgi.containsServer(server)) {
found = true;
break;
}
}
if (!found) {
defaultServers.add(server);
}
}
return defaultServers;
}
{code}
That is a logic of 2 nest loops and for each server, listRSGroups() allocates a
new LinkedList and all Map#values(), both of which are very heavy operations.
Maybe the inner loop could be moved out, that is
# Build a list of servers of other groups than default group
# Iterate each online servers and check if it is in the list above. If it is
not, then it belongs to default group.
was:
{code:title=RSGroupInfoManagerImpl.java|borderStyle=solid}
private SortedSet<Address> getDefaultServers() throws IOException {
SortedSet<Address> defaultServers = Sets.newTreeSet();
for (ServerName serverName : getOnlineRS()) {
Address server = Address.fromParts(serverName.getHostname(),
serverName.getPort());
boolean found = false;
for (RSGroupInfo rsgi : listRSGroups()) {
if (!RSGroupInfo.DEFAULT_GROUP.equals(rsgi.getName()) &&
rsgi.containsServer(server)) {
found = true;
break;
}
}
if (!found) {
defaultServers.add(server);
}
}
return defaultServers;
}
{code}
> Improve RSGroupInfoManagerImpl#getDefaultServers()
> --------------------------------------------------
>
> Key: HBASE-22009
> URL: https://issues.apache.org/jira/browse/HBASE-22009
> Project: HBase
> Issue Type: Improvement
> Components: rsgroup
> Reporter: Xiang Li
> Assignee: Xiang Li
> Priority: Minor
>
> {code:title=RSGroupInfoManagerImpl.java|borderStyle=solid}
> private SortedSet<Address> getDefaultServers() throws IOException {
> SortedSet<Address> defaultServers = Sets.newTreeSet();
> for (ServerName serverName : getOnlineRS()) {
> Address server = Address.fromParts(serverName.getHostname(),
> serverName.getPort());
> boolean found = false;
> for (RSGroupInfo rsgi : listRSGroups()) {
> if (!RSGroupInfo.DEFAULT_GROUP.equals(rsgi.getName()) &&
> rsgi.containsServer(server)) {
> found = true;
> break;
> }
> }
> if (!found) {
> defaultServers.add(server);
> }
> }
> return defaultServers;
> }
> {code}
> That is a logic of 2 nest loops and for each server, listRSGroups() allocates
> a new LinkedList and all Map#values(), both of which are very heavy
> operations. Maybe the inner loop could be moved out, that is
> # Build a list of servers of other groups than default group
> # Iterate each online servers and check if it is in the list above. If it is
> not, then it belongs to default group.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)