You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@hbase.apache.org by GitBox <gi...@apache.org> on 2021/06/23 02:54:25 UTC

[GitHub] [hbase] ddupg commented on a change in pull request #3405: HBASE-26011 Introduce a new API to sync the live region server list m…

ddupg commented on a change in pull request #3405:
URL: https://github.com/apache/hbase/pull/3405#discussion_r656720923



##########
File path: hbase-server/src/main/java/org/apache/hadoop/hbase/master/ServerManager.java
##########
@@ -163,6 +169,44 @@
   private final ConcurrentNavigableMap<ServerName, ServerMetrics> onlineServers =
     new ConcurrentSkipListMap<>();
 
+  /**
+   * Store the snapshot of the current region server list, for improving read performance.
+   * <p/>
+   * The hashCode is used to determine whether there are changes to the region servers.
+   */
+  private static final class OnlineServerListSnapshot {
+
+    private static final HashFunction HASH = Hashing.murmur3_128();
+
+    final List<ServerName> servers;
+
+    final long hashCode;
+
+    public OnlineServerListSnapshot(List<ServerName> servers) {
+      this.servers = Collections.unmodifiableList(servers);
+      Hasher hasher = HASH.newHasher();
+      for (ServerName server : servers) {
+        hasher.putString(server.getServerName(), StandardCharsets.UTF_8);
+      }
+      this.hashCode = hasher.hash().asLong();

Review comment:
       Does hash conflict need to be considered? Although the probability is small.
   And if a server go online and offline between a client two calls, the hashCode is same for the client, is this expected? 




-- 
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:
users@infra.apache.org