Search in sources :

Example 1 with NodeConnectionPhaseEnum

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);
    }
}
Also used : RemoteNodeData(neo.network.model.RemoteNodeData) NodeConnectionPhaseEnum(neo.network.model.NodeConnectionPhaseEnum) EnumMap(java.util.EnumMap)

Aggregations

EnumMap (java.util.EnumMap)1 NodeConnectionPhaseEnum (neo.network.model.NodeConnectionPhaseEnum)1 RemoteNodeData (neo.network.model.RemoteNodeData)1