when searching the network, do not search on robinson peers with the old

DHT search interface. Now use the solr interface.
pull/1/head
Michael Peter Christen 12 years ago
parent 6f6ddaf7e7
commit e1da39245a

@ -55,7 +55,7 @@ import net.yacy.peers.operation.yacyVersion;
public class DHTSelection {
public static Seed[] selectClusterPeers(final SeedDB seedDB, final SortedMap<byte[], String> peerhashes) {
public static List<Seed> selectClusterPeers(final SeedDB seedDB, final SortedMap<byte[], String> peerhashes) {
final Iterator<Map.Entry<byte[], String>> i = peerhashes.entrySet().iterator();
final List<Seed> l = new ArrayList<Seed>();
Map.Entry<byte[], String> entry;
@ -68,10 +68,10 @@ public class DHTSelection {
l.add(s);
}
}
return l.toArray(new Seed[l.size()]);
return l;
}
public static Seed[] selectNodeSearchTargets(final SeedDB seedDB, int maxCount, Set<Seed> omit) {
public static List<Seed> selectNodeSearchTargets(final SeedDB seedDB, int maxCount, Set<Seed> omit) {
if (seedDB == null) { return null; }
final List<Seed> goodSeeds = new ArrayList<Seed>();
@ -93,13 +93,10 @@ public class DHTSelection {
goodSeeds.add(optionalSeeds.remove(r.nextInt(optionalSeeds.size())));
}
// produce return set
Seed[] result = new Seed[goodSeeds.size()];
result = goodSeeds.toArray(result);
return result;
return goodSeeds;
}
public static Seed[] selectSearchTargets(
public static List<Seed> selectSearchTargets(
final SeedDB seedDB,
final HandleSet wordhashes,
int redundancy,
@ -186,8 +183,8 @@ public class DHTSelection {
}
// produce return set
Seed[] result = new Seed[regularSeeds.size()];
result = regularSeeds.values().toArray(result);
List<Seed> result = new ArrayList<Seed>(regularSeeds.size());
result.addAll(regularSeeds.values());
return result;
}

@ -26,6 +26,7 @@ package net.yacy.peers;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import java.util.SortedMap;
@ -145,7 +146,7 @@ public class RemoteSearch extends Thread {
//if (wordIndex.seedDB.mySeed() == null || wordIndex.seedDB.mySeed().getPublicAddress() == null) { return null; }
// prepare seed targets and threads
final Seed[] targetPeers =
final List<Seed> dhtPeers =
(clusterselection == null) ?
DHTSelection.selectSearchTargets(
event.peers,
@ -154,21 +155,33 @@ public class RemoteSearch extends Thread {
burstRobinsonPercent,
burstMultiwordPercent)
: DHTSelection.selectClusterPeers(event.peers, clusterselection);
if (targetPeers == null) return;
if (dhtPeers == null) return;
// start solr searches
// find nodes
Set<Seed> omit = new HashSet<Seed>();
for (Seed s: targetPeers) omit.add(s);
Seed[] nodes = DHTSelection.selectNodeSearchTargets(event.peers, 20, omit);
for (Seed s: nodes) {
for (Seed s: dhtPeers) omit.add(s);
List<Seed> nodePeers = DHTSelection.selectNodeSearchTargets(event.peers, 20, omit);
// remove all robinson peers from the dhtPeers and put them to the nodes
Iterator<Seed> si = dhtPeers.iterator();
while (si.hasNext()) {
Seed s = si.next();
if (!s.getFlagAcceptRemoteIndex()) {
si.remove();
nodePeers.add(s);
}
}
// start solr searches
for (Seed s: nodePeers) {
solrRemoteSearch(event, count, s, blacklist);
}
// start search to YaCy peers
final int targets = targetPeers.length;
// start search to YaCy DHT peers
final int targets = dhtPeers.size();
if (targets == 0) return;
for (int i = 0; i < targets; i++) {
if (targetPeers[i] == null || targetPeers[i].hash == null) continue;
if (dhtPeers.get(i) == null || dhtPeers.get(i).hash == null) continue;
try {
RemoteSearch rs = new RemoteSearch(
event,
@ -183,7 +196,7 @@ public class RemoteSearch extends Thread {
time,
event.query.maxDistance,
targets,
targetPeers[i],
dhtPeers.get(i),
event.secondarySearchSuperviser,
blacklist);
rs.start();

Loading…
Cancel
Save