Skip to content

Commit 574fdc2

Browse files
rmdmattinglyRay Mattingly
authored andcommitted
HBASE-28146: Make ServerManager rsAdmins map thread safe (#5461)
Co-authored-by: Ray Mattingly <rmattingly@hubspot.com> Signed-off-by: Duo Zhang <zhangduo@apache.org> Signed-off-by: Bryan Beaudreault <bbeaudreault@apache.org> (cherry picked from commit 1641a4a)
1 parent 2ac964c commit 574fdc2

1 file changed

Lines changed: 6 additions & 20 deletions

File tree

hbase-server/src/main/java/org/apache/hadoop/hbase/master/ServerManager.java

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
import java.net.InetAddress;
2424
import java.util.ArrayList;
2525
import java.util.Collections;
26-
import java.util.HashMap;
2726
import java.util.HashSet;
2827
import java.util.List;
2928
import java.util.Map;
@@ -124,12 +123,6 @@ public class ServerManager {
124123
private final ConcurrentNavigableMap<ServerName, ServerMetrics> onlineServers =
125124
new ConcurrentSkipListMap<>();
126125

127-
/**
128-
* Map of admin interfaces per registered regionserver; these interfaces we use to control
129-
* regionservers out on the cluster
130-
*/
131-
private final Map<ServerName, AdminService.BlockingInterface> rsAdmins = new HashMap<>();
132-
133126
/** List of region servers that should not get any more new regions. */
134127
private final ArrayList<ServerName> drainingServers = new ArrayList<>();
135128

@@ -397,7 +390,6 @@ private ServerName findServerWithSameHostnamePortWithLock(final ServerName serve
397390
void recordNewServerWithLock(final ServerName serverName, final ServerMetrics sl) {
398391
LOG.info("Registering regionserver=" + serverName);
399392
this.onlineServers.put(serverName, sl);
400-
this.rsAdmins.remove(serverName);
401393
}
402394

403395
public RegionStoreSequenceIds getLastFlushedSequenceId(byte[] encodedRegionName) {
@@ -599,7 +591,6 @@ public synchronized void moveFromOnlineToDeadServers(final ServerName sn) {
599591
LOG.trace("Expiration of {} but server not online", sn);
600592
}
601593
}
602-
this.rsAdmins.remove(sn);
603594
}
604595

605596
/*
@@ -711,18 +702,13 @@ public static void closeRegionSilentlyAndWait(ClusterConnection connection, Serv
711702
* @throws RetriesExhaustedException wrapping a ConnectException if failed
712703
*/
713704
public AdminService.BlockingInterface getRsAdmin(final ServerName sn) throws IOException {
714-
AdminService.BlockingInterface admin = this.rsAdmins.get(sn);
715-
if (admin == null) {
716-
LOG.debug("New admin connection to " + sn.toString());
717-
if (sn.equals(master.getServerName()) && master instanceof HRegionServer) {
718-
// A master is also a region server now, see HBASE-10569 for details
719-
admin = ((HRegionServer) master).getRSRpcServices();
720-
} else {
721-
admin = this.connection.getAdmin(sn);
722-
}
723-
this.rsAdmins.put(sn, admin);
705+
LOG.debug("New admin connection to {}", sn);
706+
if (sn.equals(master.getServerName()) && master instanceof HRegionServer) {
707+
// A master is also a region server now, see HBASE-10569 for details
708+
return ((HRegionServer) master).getRSRpcServices();
709+
} else {
710+
return this.connection.getAdmin(sn);
724711
}
725-
return admin;
726712
}
727713

728714
/**

0 commit comments

Comments
 (0)