You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by zh...@apache.org on 2018/02/05 04:09:04 UTC
[05/42] hbase git commit: HBASE-19917 Improve
RSGroupBasedLoadBalancer#filterServers() to be more efficient
HBASE-19917 Improve RSGroupBasedLoadBalancer#filterServers() to be more efficient
Signed-off-by: tedyu <yu...@gmail.com>
Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/c2e3d520
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/c2e3d520
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/c2e3d520
Branch: refs/heads/HBASE-19397-branch-2
Commit: c2e3d52080ed28dbffbb83314dff4a75f072f400
Parents: 30a7e4a
Author: Xiang Li <li...@freewheel.tv>
Authored: Sat Feb 3 04:46:55 2018 +0000
Committer: tedyu <yu...@gmail.com>
Committed: Sun Feb 4 17:23:06 2018 -0800
----------------------------------------------------------------------
.../hbase/rsgroup/RSGroupBasedLoadBalancer.java | 22 ++++++++++++--------
1 file changed, 13 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hbase/blob/c2e3d520/hbase-rsgroup/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupBasedLoadBalancer.java
----------------------------------------------------------------------
diff --git a/hbase-rsgroup/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupBasedLoadBalancer.java b/hbase-rsgroup/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupBasedLoadBalancer.java
index 550f734..c47972d 100644
--- a/hbase-rsgroup/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupBasedLoadBalancer.java
+++ b/hbase-rsgroup/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupBasedLoadBalancer.java
@@ -20,7 +20,6 @@ package org.apache.hadoop.hbase.rsgroup;
import java.io.IOException;
import java.util.ArrayList;
-import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
@@ -29,6 +28,7 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
+
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.ClusterMetrics;
import org.apache.hadoop.hbase.HBaseIOException;
@@ -288,16 +288,20 @@ public class RSGroupBasedLoadBalancer implements RSGroupableBalancer {
* List of servers which are online.
* @return the list
*/
- private List<ServerName> filterServers(Collection<Address> servers,
- Collection<ServerName> onlineServers) {
- ArrayList<ServerName> finalList = new ArrayList<ServerName>();
- for (Address server : servers) {
- for(ServerName curr: onlineServers) {
- if(curr.getAddress().equals(server)) {
- finalList.add(curr);
- }
+ private List<ServerName> filterServers(Set<Address> servers,
+ List<ServerName> onlineServers) {
+ /**
+ * servers is actually a TreeSet (see {@link org.apache.hadoop.hbase.rsgroup.RSGroupInfo}),
+ * having its contains()'s time complexity as O(logn), which is good enough.
+ * TODO: consider using HashSet to pursue O(1) for contains() throughout the calling chain
+ * if needed. */
+ ArrayList<ServerName> finalList = new ArrayList<>();
+ for (ServerName onlineServer : onlineServers) {
+ if (servers.contains(onlineServer.getAddress())) {
+ finalList.add(onlineServer);
}
}
+
return finalList;
}