use of com.jd.blockchain.consensus.NodeNetworkAddress in project jdchain-core by blockchain-jd-com.
the class LedgerPeersManager method updateTopology.
public Set<NetworkAddress> updateTopology() {
for (Map.Entry<NetworkAddress, LedgerPeerConnectionManager> entry : connections.entrySet()) {
try {
logger.debug("UpdateTopology by {}", entry.getKey());
NodeNetworkAddresses nodeNetworkAddresses = entry.getValue().loadMonitors();
if (null != nodeNetworkAddresses) {
NodeNetworkAddress[] nodeAddresses = nodeNetworkAddresses.getNodeNetworkAddresses();
if (nodeAddresses != null && nodeAddresses.length > 0) {
Set<NetworkAddress> addresses = new HashSet<>();
boolean satisfied = true;
for (NodeNetworkAddress address : nodeAddresses) {
// 存在端口小于0的情况则不使用此次查询结果
if (address.getMonitorPort() > 0) {
addresses.add(new NetworkAddress(address.getHost(), address.getMonitorPort(), address.isMonitorSecure()));
} else {
satisfied = false;
break;
}
}
if (satisfied) {
logger.debug("UpdateTopology by {} : {}", entry.getKey(), addresses);
return addresses;
} else {
continue;
}
}
}
} catch (Exception e) {
logger.warn("UpdateTopology by {}", entry.getKey(), e);
}
}
return null;
}
Aggregations