Remote clients selector error: / by zero (#1949)
* Fixed the bug of hash selector error cause of remote clients not build. #1948 * Fixed a style check error.
This commit is contained in:
parent
7c8a683c2f
commit
fd47fcb830
|
|
@ -83,6 +83,7 @@ public class RemoteClientManager implements Service {
|
|||
}
|
||||
|
||||
List<RemoteInstance> instanceList = clusterNodesQuery.queryRemoteNodes();
|
||||
instanceList = distinct(instanceList);
|
||||
Collections.sort(instanceList);
|
||||
|
||||
if (logger.isDebugEnabled()) {
|
||||
|
|
@ -90,13 +91,50 @@ public class RemoteClientManager implements Service {
|
|||
}
|
||||
|
||||
if (!compare(instanceList)) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("ReBuilding remote clients.");
|
||||
}
|
||||
reBuildRemoteClients(instanceList);
|
||||
}
|
||||
|
||||
printRemoteClientList();
|
||||
} catch (Throwable t) {
|
||||
logger.error(t.getMessage(), t);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Print the client list into log for confirm how many clients built.
|
||||
*/
|
||||
private void printRemoteClientList() {
|
||||
if (logger.isDebugEnabled()) {
|
||||
StringBuilder addresses = new StringBuilder();
|
||||
getRemoteClient().forEach(client -> addresses.append(client.getAddress().toString()).append(","));
|
||||
logger.debug("Remote client list: {}", addresses);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Because of OAP server register by the UUID which one-to-one mapping with process number.
|
||||
* The register information not delete immediately after process shutdown because of there
|
||||
* is always happened network fault, not really process shutdown. So, cluster module must
|
||||
* wait a few seconds to confirm it. Then there are more than one register information in
|
||||
* the cluster.
|
||||
*
|
||||
* @param instanceList the instances query from cluster module.
|
||||
* @return distinct remote instances
|
||||
*/
|
||||
private List<RemoteInstance> distinct(List<RemoteInstance> instanceList) {
|
||||
Set<Address> addresses = new HashSet<>();
|
||||
List<RemoteInstance> newInstanceList = new ArrayList<>();
|
||||
instanceList.forEach(instance -> {
|
||||
if (addresses.add(instance.getAddress())) {
|
||||
newInstanceList.add(instance);
|
||||
}
|
||||
});
|
||||
return newInstanceList;
|
||||
}
|
||||
|
||||
public List<RemoteClient> getRemoteClient() {
|
||||
return usingClients;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue