Search in sources :

Example 1 with PeerSelectionCriteria

use of net.i2p.router.PeerSelectionCriteria in project i2p.i2p by i2p.

the class PeerTestJob method selectPeersToTest.

/**
 * Retrieve a group of 0 or more peers that we want to test.
 * Returned list will not include ourselves.
 *
 * @return set of RouterInfo structures
 */
private Set<RouterInfo> selectPeersToTest() {
    PeerSelectionCriteria criteria = new PeerSelectionCriteria();
    criteria.setMinimumRequired(getTestConcurrency());
    criteria.setMaximumRequired(getTestConcurrency());
    criteria.setPurpose(PeerSelectionCriteria.PURPOSE_TEST);
    List<Hash> peerHashes = _manager.selectPeers(criteria);
    if (_log.shouldLog(Log.DEBUG))
        _log.debug("Peer selection found " + peerHashes.size() + " peers");
    Set<RouterInfo> peers = new HashSet<RouterInfo>(peerHashes.size());
    for (Hash peer : peerHashes) {
        RouterInfo peerInfo = getContext().netDb().lookupRouterInfoLocally(peer);
        if (peerInfo != null) {
            peers.add(peerInfo);
        } else {
            if (_log.shouldLog(Log.WARN))
                _log.warn("Test peer " + peer.toBase64() + " had no local routerInfo?");
        }
    }
    return peers;
}
Also used : RouterInfo(net.i2p.data.router.RouterInfo) PeerSelectionCriteria(net.i2p.router.PeerSelectionCriteria) Hash(net.i2p.data.Hash) HashSet(java.util.HashSet)

Aggregations

HashSet (java.util.HashSet)1 Hash (net.i2p.data.Hash)1 RouterInfo (net.i2p.data.router.RouterInfo)1 PeerSelectionCriteria (net.i2p.router.PeerSelectionCriteria)1