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;
}
Aggregations