Skip to content

Commit

Permalink
fixed non-termination bug for robinson remote crawl peer selection
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@3681 6c8d7289-2bf4-0310-a012-ef5d649a1542
  • Loading branch information
orbiter committed May 7, 2007
1 parent a3ecfe0 commit 0831034
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
3 changes: 2 additions & 1 deletion source/de/anomic/kelondro/kelondroCloneableMapIterator.java
Expand Up @@ -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();
Expand Down
10 changes: 7 additions & 3 deletions source/de/anomic/yacy/yacyDHTAction.java
Expand Up @@ -218,11 +218,15 @@ public synchronized yacySeed getGlobalCrawlSeed(String urlHash) {
}

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;
Expand Down

0 comments on commit 0831034

Please sign in to comment.