Skip to content

HBASE-28146: Make ServerManager rsAdmins map thread safe #5461

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Oct 23, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import java.net.InetAddress;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -124,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<>();

Expand Down Expand Up @@ -402,7 +395,6 @@ public ServerName findServerWithSameHostnamePortWithLock(final ServerName server
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) {
Expand Down Expand Up @@ -604,7 +596,6 @@ public synchronized void moveFromOnlineToDeadServers(final ServerName sn) {
LOG.trace("Expiration of {} but server not online", sn);
}
}
this.rsAdmins.remove(sn);
}

/*
Expand Down Expand Up @@ -716,18 +707,13 @@ public static void closeRegionSilentlyAndWait(ClusterConnection connection, Serv
* @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;
}

/**
Expand Down