From 0831034e076c1c0262031a6471609706a8c08598 Mon Sep 17 00:00:00 2001 From: orbiter Date: Mon, 7 May 2007 14:37:50 +0000 Subject: [PATCH] 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 --- .../anomic/kelondro/kelondroCloneableMapIterator.java | 3 ++- source/de/anomic/yacy/yacyDHTAction.java | 10 +++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/source/de/anomic/kelondro/kelondroCloneableMapIterator.java b/source/de/anomic/kelondro/kelondroCloneableMapIterator.java index f35852583..dd11c16cd 100644 --- a/source/de/anomic/kelondro/kelondroCloneableMapIterator.java +++ b/source/de/anomic/kelondro/kelondroCloneableMapIterator.java @@ -39,8 +39,9 @@ public class kelondroCloneableMapIterator implements kelondroCloneableIterator { 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 + // this iterator iterates then only the key elements of the map this.map = map; this.start = start; this.iter = map.keySet().iterator(); diff --git a/source/de/anomic/yacy/yacyDHTAction.java b/source/de/anomic/yacy/yacyDHTAction.java index bf1215d80..b0d7ddd43 100644 --- a/source/de/anomic/yacy/yacyDHTAction.java +++ b/source/de/anomic/yacy/yacyDHTAction.java @@ -218,11 +218,15 @@ public class yacyDHTAction implements yacyPeerAction { } 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); - while (i.hasNext()) { - yacySeed seed = seedDB.getConnected((String) i.next()); + String hash; + 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 (clusterhashes != null) seed.setAlternativeAddress((String) clusterhashes.get(seed.hash)); + seed.setAlternativeAddress((String) clusterhashes.get(hash)); return seed; } return null;