fixed non-termination bug for robinson remote crawl peer selection

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@3681 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
orbiter 18 years ago
parent a3ecfe0a45
commit 0831034e07

@ -39,8 +39,9 @@ public class kelondroCloneableMapIterator implements kelondroCloneableIterator {
public kelondroCloneableMapIterator(TreeMap map, Object start) { public kelondroCloneableMapIterator(TreeMap map, Object start) {
// set must contain byte[] elements or String elements. // map must contain eiter a byte[]/Object or a String/Object mapping.
// start must be either of type byte[] or String // start must be either of type byte[] or String
// this iterator iterates then only the key elements of the map
this.map = map; this.map = map;
this.start = start; this.start = start;
this.iter = map.keySet().iterator(); this.iter = map.keySet().iterator();

@ -218,11 +218,15 @@ public class yacyDHTAction implements yacyPeerAction {
} }
public synchronized yacySeed getPublicClusterCrawlSeed(String urlHash, TreeMap clusterhashes) { public synchronized yacySeed getPublicClusterCrawlSeed(String urlHash, TreeMap clusterhashes) {
// clusterhashes is a String(hash)/String(IP) - mapping
kelondroCloneableIterator i = new kelondroRotateIterator(new kelondroCloneableMapIterator(clusterhashes, urlHash), null); kelondroCloneableIterator i = new kelondroRotateIterator(new kelondroCloneableMapIterator(clusterhashes, urlHash), null);
while (i.hasNext()) { String hash;
yacySeed seed = seedDB.getConnected((String) i.next()); int count = clusterhashes.size(); // counter to ensure termination
while ((i.hasNext()) && (count-- > 0)) {
hash = (String) i.next();
yacySeed seed = seedDB.getConnected(hash);
if (seed == null) continue; if (seed == null) continue;
if (clusterhashes != null) seed.setAlternativeAddress((String) clusterhashes.get(seed.hash)); seed.setAlternativeAddress((String) clusterhashes.get(hash));
return seed; return seed;
} }
return null; return null;

Loading…
Cancel
Save