Search in sources :

Example 1 with NodeHandler

use of org.tron.common.overlay.discover.NodeHandler in project java-tron by tronprotocol.

the class SyncPool method logActivePeers.

synchronized void logActivePeers() {
    logger.info("-------- active node.");
    for (NodeHandler nodeHandler : nodeManager.getActiveNodes()) {
        logger.info(nodeHandler.toString());
    }
    logger.info("-------- active channel {}, node in user size {}", channelManager.getActivePeers().size(), channelManager.nodesInUse().size());
    for (Channel channel : channelManager.getActivePeers()) {
        logger.info(channel.toString());
    }
    if (logger.isInfoEnabled()) {
        StringBuilder sb = new StringBuilder("Peer stats:\n");
        sb.append("Active peers\n");
        sb.append("============\n");
        Set<Node> activeSet = new HashSet<>();
        for (PeerConnection peer : new ArrayList<>(activePeers)) {
            sb.append(peer.logSyncStats()).append('\n');
            activeSet.add(peer.getNode());
        }
        sb.append("Other connected peers\n");
        sb.append("============\n");
        for (Channel peer : new ArrayList<>(channelManager.getActivePeers())) {
            if (!activeSet.contains(peer.getNode())) {
                sb.append(peer.logSyncStats()).append('\n');
            }
        }
        logger.info(sb.toString());
    }
}
Also used : NodeHandler(org.tron.common.overlay.discover.NodeHandler) PeerConnection(org.tron.core.net.peer.PeerConnection) Node(org.tron.common.overlay.discover.Node) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet)

Aggregations

ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 Node (org.tron.common.overlay.discover.Node)1 NodeHandler (org.tron.common.overlay.discover.NodeHandler)1 PeerConnection (org.tron.core.net.peer.PeerConnection)1