This is an automated email from the ASF dual-hosted git repository.

zhangduo pushed a commit to branch branch-2.4
in repository https://gitbox.apache.org/repos/asf/hbase.git


The following commit(s) were added to refs/heads/branch-2.4 by this push:
     new dc5539ce678 HBASE-28146: Make ServerManager rsAdmins map thread safe 
(#5461)
dc5539ce678 is described below

commit dc5539ce6780e81a6859a82918785ad3388fd39d
Author: Ray Mattingly <[email protected]>
AuthorDate: Mon Oct 23 05:16:14 2023 -0400

    HBASE-28146: Make ServerManager rsAdmins map thread safe (#5461)
    
    Co-authored-by: Ray Mattingly <[email protected]>
    Signed-off-by: Duo Zhang <[email protected]>
    Signed-off-by: Bryan Beaudreault <[email protected]>
    (cherry picked from commit 1641a4abc13c7ad4da216a115107fc772d24d543)
---
 .../apache/hadoop/hbase/master/ServerManager.java  | 27 ++++++----------------
 1 file changed, 7 insertions(+), 20 deletions(-)

diff --git 
a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/ServerManager.java 
b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/ServerManager.java
index 98a12e69217..937789266b0 100644
--- 
a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/ServerManager.java
+++ 
b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/ServerManager.java
@@ -23,7 +23,6 @@ import java.io.IOException;
 import java.net.InetAddress;
 import java.util.ArrayList;
 import java.util.Collections;
-import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
@@ -44,6 +43,7 @@ import org.apache.hadoop.hbase.ServerName;
 import org.apache.hadoop.hbase.YouAreDeadException;
 import org.apache.hadoop.hbase.client.ClusterConnection;
 import org.apache.hadoop.hbase.client.RegionInfo;
+import org.apache.hadoop.hbase.client.RetriesExhaustedException;
 import org.apache.hadoop.hbase.ipc.HBaseRpcController;
 import org.apache.hadoop.hbase.ipc.RemoteWithExtrasException;
 import org.apache.hadoop.hbase.ipc.RpcControllerFactory;
@@ -123,12 +123,6 @@ public class ServerManager {
   private final ConcurrentNavigableMap<ServerName, ServerMetrics> 
onlineServers =
     new ConcurrentSkipListMap<>();
 
-  /**
-   * Map of admin interfaces per registered regionserver; these interfaces we 
use to control
-   * regionservers out on the cluster
-   */
-  private final Map<ServerName, AdminService.BlockingInterface> rsAdmins = new 
HashMap<>();
-
   /** List of region servers that should not get any more new regions. */
   private final ArrayList<ServerName> drainingServers = new ArrayList<>();
 
@@ -393,7 +387,6 @@ public class ServerManager {
   void recordNewServerWithLock(final ServerName serverName, final 
ServerMetrics sl) {
     LOG.info("Registering regionserver=" + serverName);
     this.onlineServers.put(serverName, sl);
-    this.rsAdmins.remove(serverName);
   }
 
   public RegionStoreSequenceIds getLastFlushedSequenceId(byte[] 
encodedRegionName) {
@@ -595,7 +588,6 @@ public class ServerManager {
         LOG.trace("Expiration of {} but server not online", sn);
       }
     }
-    this.rsAdmins.remove(sn);
   }
 
   /*
@@ -707,18 +699,13 @@ public class ServerManager {
    * @throws RetriesExhaustedException wrapping a ConnectException if failed
    */
   public AdminService.BlockingInterface getRsAdmin(final ServerName sn) throws 
IOException {
-    AdminService.BlockingInterface admin = this.rsAdmins.get(sn);
-    if (admin == null) {
-      LOG.debug("New admin connection to " + sn.toString());
-      if (sn.equals(master.getServerName()) && master instanceof 
HRegionServer) {
-        // A master is also a region server now, see HBASE-10569 for details
-        admin = ((HRegionServer) master).getRSRpcServices();
-      } else {
-        admin = this.connection.getAdmin(sn);
-      }
-      this.rsAdmins.put(sn, admin);
+    LOG.debug("New admin connection to {}", sn);
+    if (sn.equals(master.getServerName()) && master instanceof HRegionServer) {
+      // A master is also a region server now, see HBASE-10569 for details
+      return ((HRegionServer) master).getRSRpcServices();
+    } else {
+      return this.connection.getAdmin(sn);
     }
-    return admin;
   }
 
   /**

Reply via email to