use of neo.network.model.NodeConnectionPhaseEnum in project neo-java by coranos.
the class StatsModel method addNodeConnectionPhaseStats.
/**
* adds stats for how many peers are in each onnection [hase.
*
* @param peerDataList
* the set of connected remote peers.
*/
private void addNodeConnectionPhaseStats(final List<RemoteNodeData> peerDataList) {
final Map<NodeConnectionPhaseEnum, Integer> connectionPhaseMap = new EnumMap<>(NodeConnectionPhaseEnum.class);
for (final NodeConnectionPhaseEnum connectionPhase : NodeConnectionPhaseEnum.values()) {
connectionPhaseMap.put(connectionPhase, 0);
}
for (final RemoteNodeData data : peerDataList) {
synchronized (data) {
final int oldCount = connectionPhaseMap.get(data.getConnectionPhase());
connectionPhaseMap.put(data.getConnectionPhase(), oldCount + 1);
}
}
for (final NodeConnectionPhaseEnum connectionPhase : connectionPhaseMap.keySet()) {
final int count = connectionPhaseMap.get(connectionPhase);
addNameAndValue(WordUtils.capitalize(connectionPhase.name()), count);
}
}
Aggregations