diff --git a/htroot/js/yacysearch.js b/htroot/js/yacysearch.js index a3aa2603b..6a6abf1e4 100644 --- a/htroot/js/yacysearch.js +++ b/htroot/js/yacysearch.js @@ -93,12 +93,21 @@ function parseFormattedInt(strIntValue) { return intValue; } -function statistics(offset, itemscount, itemsperpage, totalcount, localResourceSize, remoteResourceSize, remoteIndexCount, remotePeerCount, navurlbase, localQuery) { +function statistics(offset, itemscount, itemsperpage, totalcount, localResourceSize, remoteResourceSize, remoteIndexCount, remotePeerCount, navurlbase, localQuery, feedRunning) { var totalcountIntValue = parseFormattedInt(totalcount); var offsetIntValue = parseFormattedInt(offset); var itemscountIntValue = parseFormattedInt(itemscount); var itemsperpageIntValue = parseFormattedInt(itemsperpage); + var feedingStatusElement = document.getElementById("feedingStatus"); + if(feedingStatusElement != null) { + if(feedRunning) { + feedingStatusElement.style.visibility = "visible"; + } else { + feedingStatusElement.style.visibility = "hidden"; + } + } + if (totalcountIntValue == 0) { return; } diff --git a/htroot/yacysearch.html b/htroot/yacysearch.html index a7f2aa476..b5483f4c8 100644 --- a/htroot/yacysearch.html +++ b/htroot/yacysearch.html @@ -125,7 +125,7 @@ Use the RSS search result format to add static searches to your RSS reader, if y
-    #[offset]#-#[itemscount]# of #[totalcount]# #(globalresults)#::; (#[localResourceSize]# local, #[remoteResourceSize]# remote), #[remoteIndexCount]# from #[remotePeerCount]# remote YaCy peers.#(/globalresults)# +    #[offset]#-#[itemscount]# of #[totalcount]# #(globalresults)#::; (#[localResourceSize]# local, #[remoteResourceSize]# remote), #[remoteIndexCount]# from #[remotePeerCount]# remote YaCy peers.#(/globalresults)#
:: @@ -221,28 +221,28 @@ function latestinfo() { self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); self.xmlHttpReq.onreadystatechange = function() { if (self.xmlHttpReq.readyState == 4) { - var rsp = eval("(" + self.xmlHttpReq.responseText + ")"); + var rsp = null; + if(self.xmlHttpReq.responseText) { + if(window.JSON && window.JSON.parse) { + /* Prefer use of JSON parser when available instead of discouraged eval() function */ + rsp = window.JSON.parse(self.xmlHttpReq.responseText); + } else { + rsp = eval("(" + self.xmlHttpReq.responseText + ")"); + } + } - statistics(rsp.offset, rsp.itemscount, rsp.itemsperpage, rsp.totalcount, rsp.localResourceSize, rsp.remoteResourceSize, rsp.remoteIndexCount, rsp.remotePeerCount, rsp.navurlBase, #[localQuery]#); + if(rsp && rsp.offset != null) { + statistics(rsp.offset, rsp.itemscount, rsp.itemsperpage, rsp.totalcount, rsp.localResourceSize, rsp.remoteResourceSize, rsp.remoteIndexCount, rsp.remotePeerCount, rsp.navurlBase, #[localQuery]#, rsp.feedRunning); + if(rsp.feedRunning) { + /* Refresh statistics while server feeders are still running */ + window.setTimeout(latestinfo, 1000); + } + } } }; self.xmlHttpReq.send(null); } -window.setTimeout('latestinfo();',500); // we need that to get a correct pagination bar at the end of the page -window.setTimeout('latestinfo();',1000); -// TODO: resets statistic on navigating to next page in Jetty implementation -/* -window.setTimeout('latestinfo();',500); -window.setTimeout('latestinfo();',1000); -window.setTimeout('latestinfo();',1500); -window.setTimeout('latestinfo();',2000); -window.setTimeout('latestinfo();',3000); -window.setTimeout('latestinfo();',4000); -window.setTimeout('latestinfo();',5000); -window.setTimeout('latestinfo();',6000); -window.setTimeout('latestinfo();',8000); -window.setTimeout('latestinfo();',10000); -*/ +window.setTimeout(latestinfo, 500); // we need that to get a correct pagination bar at the end of the page #%env/templates/footer.template%# diff --git a/htroot/yacysearchitem.html b/htroot/yacysearchitem.html index ce3d072ba..e3742a646 100644 --- a/htroot/yacysearchitem.html +++ b/htroot/yacysearchitem.html @@ -58,6 +58,6 @@ #(statistics)#:: #(/statistics)# diff --git a/htroot/yacysearchitem.java b/htroot/yacysearchitem.java index 60a680e08..2f03a82f3 100644 --- a/htroot/yacysearchitem.java +++ b/htroot/yacysearchitem.java @@ -123,6 +123,7 @@ public class yacysearchitem { prop.put("statistics_remotePeerCount", Formatter.number(theSearch.remote_rwi_peerCount.get() + theSearch.remote_solr_peerCount.get(), true)); prop.put("statistics_navurlBase", QueryParams.navurlBase(RequestHeader.FileType.HTML, theSearch.query, null, false).toString()); prop.put("statistics_localQuery", theSearch.query.isLocal() ? "1" : "0"); + prop.put("statistics_feedRunning", Boolean.toString(!theSearch.isFeedingFinished())); final String target_special_pattern = sb.getConfig(SwitchboardConstants.SEARCH_TARGET_SPECIAL_PATTERN, ""); final boolean noreferrer = sb.getConfigBool(SwitchboardConstants.SEARCH_RESULT_NOREFERRER, SwitchboardConstants.SEARCH_RESULT_NOREFERRER_DEFAULT); diff --git a/htroot/yacysearchlatestinfo.java b/htroot/yacysearchlatestinfo.java index 7a0bebcc5..1c38f78ca 100644 --- a/htroot/yacysearchlatestinfo.java +++ b/htroot/yacysearchlatestinfo.java @@ -28,6 +28,7 @@ public class yacysearchlatestinfo { prop.put("remoteIndexCount", 0); prop.put("remotePeerCount", 0); prop.putJSON("navurlBase", "#"); + prop.put("feedRunning", Boolean.FALSE.toString()); return prop; } @@ -42,6 +43,7 @@ public class yacysearchlatestinfo { prop.put("remoteIndexCount", Formatter.number(theSearch.remote_rwi_available.get() + theSearch.remote_solr_available.get(), true)); prop.put("remotePeerCount", Formatter.number(theSearch.remote_rwi_peerCount.get() + theSearch.remote_solr_peerCount.get(), true)); prop.putJSON("navurlBase", QueryParams.navurlBase(RequestHeader.FileType.HTML, theSearch.query, null, false).toString()); + prop.put("feedRunning", Boolean.toString(!theSearch.isFeedingFinished())); return prop; } diff --git a/htroot/yacysearchlatestinfo.json b/htroot/yacysearchlatestinfo.json index 0de0c8e7b..97d296620 100644 --- a/htroot/yacysearchlatestinfo.json +++ b/htroot/yacysearchlatestinfo.json @@ -7,5 +7,6 @@ "remoteResourceSize": "#[remoteResourceSize]#", "remoteIndexCount": "#[remoteIndexCount]#", "remotePeerCount": "#[remotePeerCount]#", -"navurlBase": "#[navurlBase]#" +"navurlBase": "#[navurlBase]#", +"feedRunning": #[feedRunning]# } diff --git a/source/net/yacy/search/query/SearchEvent.java b/source/net/yacy/search/query/SearchEvent.java index cf53dbab0..e3aa44de6 100644 --- a/source/net/yacy/search/query/SearchEvent.java +++ b/source/net/yacy/search/query/SearchEvent.java @@ -1605,7 +1605,7 @@ public final class SearchEvent { } while ( this.resultList.sizeAvailable() <= resultListIndex && (this.rwiQueueSize() > 0 || this.nodeStack.sizeQueue() > 0 || - (!this.feedingIsFinished() && System.currentTimeMillis() < finishTime))) { + (!this.isFeedingFinished() && System.currentTimeMillis() < finishTime))) { if (!drainStacksToResult()) { try { Thread.sleep(10); @@ -1797,7 +1797,13 @@ public final class SearchEvent { return this.order; } - protected boolean feedingIsFinished() { + /** + * Check whether feeding from all available data sources is finished (remote + * RWI and Solr requests, local RWI and Solr requests, Heuristics + * requests...) + * @return true when all available feeders on this search event are terminated + */ + public boolean isFeedingFinished() { return this.feedersTerminated.intValue() > (this.remote ? 1 : 0) && this.feedersAlive.get() == 0;