Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
small update for timing in search result processing
orbiter4f45605f04a3
diff --git a/htroot/yacysearchitem.java b/htroot/yacysearchitem.javaindex a50d7c77c..14c6a42c3 100644--- a/htroot/yacysearchitem.java+++ b/htroot/yacysearchitem.java@@ -88,8 +88,6 @@ public class yacysearchitem {prop.put("remoteResourceSize", yFormatter.number(theSearch.getRankingResult().getRemoteResourceSize(), true));prop.put("remoteIndexCount", yFormatter.number(theSearch.getRankingResult().getRemoteIndexCount(), true));prop.put("remotePeerCount", yFormatter.number(theSearch.getRankingResult().getRemotePeerCount(), true));-- prop.put("rss", "0");if (theQuery.contentdom == plasmaSearchQuery.CONTENTDOM_TEXT) {// text searchdiff --git a/source/de/anomic/plasma/plasmaSearchEvent.java b/source/de/anomic/plasma/plasmaSearchEvent.javaindex 656674888..cce8e1738 100644--- a/source/de/anomic/plasma/plasmaSearchEvent.java+++ b/source/de/anomic/plasma/plasmaSearchEvent.java@@ -200,7 +200,7 @@ public final class plasmaSearchEvent {// start worker threads to fetch urls and snippetsthis.workerThreads = new resultWorker[workerThreadCount];for (int i = 0; i < workerThreadCount; i++) {- this.workerThreads[i] = new resultWorker(i, 6000, 2);+ this.workerThreads[i] = new resultWorker(i, 10000, 2);this.workerThreads[i].start();}serverProfiling.update("SEARCH", new plasmaProfiling.searchEvent(query.id(true), "online snippet fetch threads started", 0, 0));@@ -375,6 +375,15 @@ public final class plasmaSearchEvent {return false;}+ private int countWorkerFinished() {+ if (this.workerThreads == null) return 0;+ int c = 0;+ for (int i = 0; i < workerThreadCount; i++) {+ if (this.workerThreads[i] == null || !this.workerThreads[i].isAlive()) c++;+ }+ return c;+ }+boolean anyRemoteSearchAlive() {// check primary search threadsif ((this.primarySearchThreads != null) && (this.primarySearchThreads.length != 0)) {@@ -547,6 +556,10 @@ public final class plasmaSearchEvent {}public ResultEntry oneResult(final int item) {+ return oneResult(item, System.currentTimeMillis() + 100);+ }++ public ResultEntry oneResult(final int item, long timeout) {// check if we already retrieved this item (happens if a search pages is accessed a second time)serverProfiling.update("SEARCH", new plasmaProfiling.searchEvent(query.id(true), "obtain one result entry - start", 0, 0));if (this.result.sizeStore() > item) {@@ -557,21 +570,28 @@ public final class plasmaSearchEvent {if ((query.domType == plasmaSearchQuery.SEARCHDOM_GLOBALDHT) ||(query.domType == plasmaSearchQuery.SEARCHDOM_CLUSTERALL)) {// this is a search using remote search threads. Also the local search thread is started as background process- if ((localSearchThread != null) && (localSearchThread.isAlive())) {+ while (+ localSearchThread != null &&+ localSearchThread.isAlive() &&+ System.currentTimeMillis() < timeout) {// in case that the local search takes longer than some other remote search requests,// do some sleeps to give the local process a chance to contribute- try {Thread.sleep(item * 100L);} catch (final InterruptedException e) {}+ try {Thread.sleep(10);} catch (final InterruptedException e) {}}// now wait until as many remote worker threads have finished, as we want to display results- while ((this.primarySearchThreads != null) && (this.primarySearchThreads.length > item) && (anyWorkerAlive()) &&- ((result.size() <= item) || (countFinishedRemoteSearch() <= item))) {- try {Thread.sleep(100);} catch (final InterruptedException e) {}+ while (+ this.primarySearchThreads != null &&+ anyWorkerAlive() &&+ countWorkerFinished() <= item &&+ System.currentTimeMillis() < timeout &&+ (result.size() <= item || countFinishedRemoteSearch() <= item)) {+ try {Thread.sleep(10);} catch (final InterruptedException e) {}}}// finally wait until enough results are there produced from the snippet fetch process- while ((anyWorkerAlive()) && (result.size() <= item)) {- try {Thread.sleep(100);} catch (final InterruptedException e) {}+ while (anyWorkerAlive() && result.size() <= item) {+ try {Thread.sleep(10);} catch (final InterruptedException e) {}}// finally, if there is something, return the result