HBASE-16275 Change ServerManager#onlineServers from ConcurrentHashMap to ConcurrentSkipListMap (Huaxiang Sun)
This commit is contained in:
parent
968e464aed
commit
7983d2f45b
|
@ -137,8 +137,8 @@ public class ServerManager {
|
||||||
new ConcurrentSkipListMap<byte[], ConcurrentNavigableMap<byte[], Long>>(Bytes.BYTES_COMPARATOR);
|
new ConcurrentSkipListMap<byte[], ConcurrentNavigableMap<byte[], Long>>(Bytes.BYTES_COMPARATOR);
|
||||||
|
|
||||||
/** Map of registered servers to their current load */
|
/** Map of registered servers to their current load */
|
||||||
private final ConcurrentHashMap<ServerName, ServerLoad> onlineServers =
|
private final ConcurrentNavigableMap<ServerName, ServerLoad> onlineServers =
|
||||||
new ConcurrentHashMap<ServerName, ServerLoad>();
|
new ConcurrentSkipListMap<ServerName, ServerLoad>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Map of admin interfaces per registered regionserver; these interfaces we use to control
|
* Map of admin interfaces per registered regionserver; these interfaces we use to control
|
||||||
|
@ -449,8 +449,14 @@ public class ServerManager {
|
||||||
*/
|
*/
|
||||||
private ServerName findServerWithSameHostnamePortWithLock(
|
private ServerName findServerWithSameHostnamePortWithLock(
|
||||||
final ServerName serverName) {
|
final ServerName serverName) {
|
||||||
for (ServerName sn: this.onlineServers.keySet()) {
|
ServerName end = ServerName.valueOf(serverName.getHostname(), serverName.getPort(),
|
||||||
if (ServerName.isSameHostnameAndPort(serverName, sn)) return sn;
|
Long.MAX_VALUE);
|
||||||
|
|
||||||
|
ServerName r = onlineServers.lowerKey(end);
|
||||||
|
if (r != null) {
|
||||||
|
if (ServerName.isSameHostnameAndPort(r, serverName)) {
|
||||||
|
return r;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue