fixed cluster search

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@8083 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
orbiter 13 years ago
parent c0c6e9e7a5
commit 8e0b2c5832

@ -85,7 +85,16 @@ public final class search {
sb.remoteSearchLastAccess = System.currentTimeMillis();
final serverObjects prop = new serverObjects();
if ((post == null) || (env == null)) return prop;
// set nice default values for error cases
prop.put("searchtime", "0");
prop.put("references", "");
prop.put("joincount", "0");
prop.put("linkcount", "0");
prop.put("links", "");
prop.put("indexcount", "");
prop.put("indexabstract", "");
if (post == null || env == null) return prop;
if (!Protocol.authentifyRequest(post, env)) return prop;
final String client = header.get(HeaderFramework.CONNECTION_PROP_CLIENTIP);
@ -101,7 +110,7 @@ public final class search {
// final String fwdep = post.get("fwdep", ""); // forward depth. if "0" then peer may NOT ask another peer for more results
// final String fwden = post.get("fwden", ""); // forward deny, a list of seed hashes. They may NOT be target of forward hopping
final int count = Math.min((int) sb.getConfigLong(SwitchboardConstants.REMOTESEARCH_MAXCOUNT_DEFAULT, 100), post.getInt("count", 10)); // maximum number of wanted results
final long maxtime = Math.min((int) sb.getConfigLong(SwitchboardConstants.REMOTESEARCH_MAXTIME_DEFAULT, 3000), post.getLong("time", 3000)); // maximum number of wanted results
final long maxtime = Math.min((int) sb.getConfigLong(SwitchboardConstants.REMOTESEARCH_MAXTIME_DEFAULT, 3000), post.getLong("time", 3000)); // maximum waiting time
final int maxdist= post.getInt("maxdist", Integer.MAX_VALUE);
final String prefer = post.get("prefer", "");
final String contentdom = post.get("contentdom", "text");
@ -144,9 +153,6 @@ public final class search {
if (sb.isRobinsonMode() && !sb.isPublicRobinson()) {
// if we are a robinson cluster, answer only if this client is known by our network definition
prop.put("links", "");
prop.put("linkcount", "0");
prop.put("references", "");
return prop;
}
@ -158,19 +164,19 @@ public final class search {
if (trackerHandles.tailSet(Long.valueOf(System.currentTimeMillis() - 3000)).size() > 1) {
block = true;
}
}
if (!block) synchronized (trackerHandles) {
if (trackerHandles.tailSet(Long.valueOf(System.currentTimeMillis() - 60000)).size() > 12) {
block = true;
}
}
if (!block) synchronized (trackerHandles) {
if (trackerHandles.tailSet(Long.valueOf(System.currentTimeMillis() - 600000)).size() > 36) {
block = true;
}
}
if (block && Domains.isLocal(client, null)) block = false;
if (block && Domains.isLocal(client, null)) block = false; // check isLocal here to prevent dns lookup for client
if (block) {
prop.put("links", "");
prop.put("linkcount", "0");
prop.put("references", "");
prop.put("searchtime", "0");
return prop;
}

@ -207,16 +207,9 @@ public class yacysearch {
}
// SEARCH
final boolean indexReceiveGranted = sb.getConfigBool(SwitchboardConstants.INDEX_RECEIVE_ALLOW, true) ||
sb.getConfigBool(SwitchboardConstants.INDEX_RECEIVE_AUTODISABLED, true);
global = global && indexReceiveGranted; // if the user does not want indexes from remote peers, it cannot be a global search
final boolean clustersearch = sb.isRobinsonMode() &&
(sb.getConfig("cluster.mode", "").equals("privatecluster") ||
sb.getConfig("cluster.mode", "").equals("publiccluster"));
if (clustersearch) {
global = true;
} // switches search on, but search target is limited to cluster nodes
final boolean clustersearch = sb.isRobinsonMode() && (sb.getConfig("cluster.mode", "").equals("privatecluster") || sb.getConfig("cluster.mode", "").equals("publiccluster"));
final boolean indexReceiveGranted = sb.getConfigBool(SwitchboardConstants.INDEX_RECEIVE_ALLOW, true) || sb.getConfigBool(SwitchboardConstants.INDEX_RECEIVE_AUTODISABLED, true) || clustersearch;
global = global && indexReceiveGranted; // if the user does not want indexes from remote peers, it cannot be a global searchnn
// increase search statistic counter
if (!global) {
@ -542,9 +535,6 @@ public class yacysearch {
}
}
// prepare search properties
final boolean globalsearch = (global) && indexReceiveGranted;
// do the search
final HandleSet queryHashes = Word.words2hashesHandles(query[0]);
final Pattern snippetPattern = QueryParams.stringSearchPattern(originalquerystring);
@ -584,8 +574,8 @@ public class yacysearch {
itemsPerPage,
offset,
urlmask,
(clustersearch && globalsearch) ? QueryParams.Searchdom.CLUSTER :
((globalsearch) ? QueryParams.Searchdom.GLOBAL : QueryParams.Searchdom.LOCAL),
clustersearch && global ? QueryParams.Searchdom.CLUSTER :
(global && indexReceiveGranted ? QueryParams.Searchdom.GLOBAL : QueryParams.Searchdom.LOCAL),
20,
constraint,
true,
@ -715,7 +705,7 @@ public class yacysearch {
prop.put("num-results_itemscount", Formatter.number(0, true));
prop.put("num-results_itemsPerPage", itemsPerPage);
prop.put("num-results_totalcount", Formatter.number(indexcount, true));
prop.put("num-results_globalresults", (globalsearch) ? "1" : "0");
prop.put("num-results_globalresults", global && (indexReceiveGranted || clustersearch) ? "1" : "0");
prop.put("num-results_globalresults_localResourceSize", Formatter.number(theSearch.getRankingResult().getLocalIndexCount(), true));
prop.put("num-results_globalresults_localMissCount", Formatter.number(theSearch.getRankingResult().getMissCount(), true));
prop.put("num-results_globalresults_remoteResourceSize", Formatter.number(theSearch.getRankingResult().getRemoteResourceSize(), true));

@ -651,12 +651,14 @@ public final class Protocol {
final boolean global,
final int partitions,
final String hostname,
final String hostaddress,
String hostaddress,
final SearchEvent.SecondarySearchSuperviser secondarySearchSuperviser,
final RankingProfile rankingProfile,
final Bitfield constraint) throws IOException {
// send a search request to peer with remote Hash
//if (hostaddress.equals(mySeed.getClusterAddress())) hostaddress = "127.0.0.1:" + mySeed.getPort(); // for debugging
// INPUT:
// iam : complete seed of the requesting peer
// youare : seed hash of the target peer, used for testing network stability

@ -115,7 +115,7 @@ public final class SearchEvent {
this.IAneardhthash = null;
this.localSearchThread = null;
this.order = new ReferenceOrder(this.query.ranking, UTF8.getBytes(this.query.targetlang));
final boolean remote = (this.query.domType == QueryParams.Searchdom.GLOBAL || this.query.domType == QueryParams.Searchdom.CLUSTER) && peers.sizeConnected() > 0 && peers.mySeed().getFlagAcceptRemoteIndex();
final boolean remote = peers.sizeConnected() > 0 && (this.query.domType == QueryParams.Searchdom.CLUSTER || (this.query.domType == QueryParams.Searchdom.GLOBAL && peers.mySeed().getFlagAcceptRemoteIndex()));
final long start = System.currentTimeMillis();
if (remote) {
// initialize a ranking process that is the target for data

Loading…
Cancel
Save