yacy_search_server/htroot/js/WatchCrawler.js
orbiter 5bb8074150 removed the indexing queue. This queue was superfluous since the introduction of the blocking queues last year, where documents are parsed, analysed and stored in the index with concurrency.
- The indexing queue was a historic data structure that was introduced at the very beginning at the project as a part of the switchboard organisation object structure. Without the indexing queue the switchboard queue becomes also superfluous. It has been removed as well.
- Removing the switchboard queue requires that all servlets are called without a opaque generic ('<?>'). That caused that all serlets had to be modified.
- Many servlets displayed the indexing queue or the size of that queue. In the past months the indexer was so fast that mostly the indexing queue appeared empty, so there was no use of it any more. Because the queue has been removed, the display in the servlets had also to be removed.
- The surrogate work task had been a part of the indexing queue control structure. Without the indexing queue the surrogates needed its own task management. That has been integrated here.
- Because the indexing queue had a special queue entry object and properties attached to this object, the propterties had to be moved to the queue entry object which is part of the new indexing queue withing the blocking queue, the Response Object. That object has now also the new properties of the removed indexing queue entry object.

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@6225 6c8d7289-2bf4-0310-a012-ef5d649a1542
2009-07-17 13:59:21 +00:00

246 lines
8.2 KiB
JavaScript

DELETE_STRING="delete";
BAR_IMG1="/env/grafics/green-block.png";
BAR_IMG2="/env/grafics/red-block.png";
WORDCACHEBAR_LENGTH=1/4;
var statusRPC;
var queuesRPC;
var refreshInterval=5;
var wait=0;
var changing=false; //change the interval
var statusLoaded=true;
var queueLoaded=true;
function initWatchCrawler(){
refresh();
//loadInterval=window.setInterval("refresh()", refreshInterval*1000);
countInterval=window.setInterval("countdown()", 1000);
}
function changeInterval(){
if(!changing){
window.clearInterval(countInterval);
counter=document.getElementById("nextUpdate");
//counter.innerHTML='<input type="text" id="newInterval" onblur="newInterval()" size="2" />';
//document.getElementById("newInterval").focus();
counter.value=refreshInterval;
changing=true;
}
}
function newInterval(){
refreshInterval=document.getElementById("nextUpdate").value;
refresh();
countInterval=window.setInterval("countdown()", 1000);
changing=false;
}
function countdown(){
if(statusLoaded && queueLoaded){
document.getElementById("nextUpdate").value=wait;
wait--;
if(wait==0){
refresh();
}
}
}
function refresh(){
wait=refreshInterval;
statusLoaded=false;
queueLoaded=false;
requestStatus();
requestQueues();
}
function requestStatus(){
statusRPC=createRequestObject();
statusRPC.open('get', '/api/status_p.xml?html=');
statusRPC.onreadystatechange = handleStatus;
statusRPC.send(null);
}
function requestQueues(){
queuesRPC=createRequestObject();
queuesRPC.open('get', '/api/queues_p.xml?html=');
queuesRPC.onreadystatechange = handleQueues;
queuesRPC.send(null);
}
function handleStatus(){
if(statusRPC.readyState != 4){
return;
}
var statusResponse = statusRPC.responseXML;
statusTag=getFirstChild(statusResponse, "status");
ppm=getValue(getFirstChild(statusTag, "ppm"));
var ppmNum = document.getElementById("ppmNum");
removeAllChildren(ppmNum);
ppmNum.appendChild(document.createTextNode(ppm));
var ppmSpan = document.getElementById("ppmSpan");
removeAllChildren(ppmSpan);
for(i = 0; i < ppm / 10; i++){
img=document.createElement("img");
img.setAttribute("src", BAR_IMG1);
ppmSpan.appendChild(img);
}
// traffic output (no bar up to now)
traffic = getFirstChild(statusTag, "traffic");
trafficCrawlerValue = getValue(getFirstChild(traffic, "crawler"));
trafCrawlerSpan = document.getElementById("trafficCrawler");
removeAllChildren(trafCrawlerSpan);
trafCrawlerSpan.appendChild(document.createTextNode(Math.round((trafficCrawlerValue) / 1024 / 10.24) / 100));
var wordCacheSize=getValue(getFirstChild(statusTag, "wordCacheSize"));
var wordCacheMaxSize=getValue(getFirstChild(statusTag, "wordCacheMaxSize"));
wordCacheNum=document.getElementById("wordcacheNum");
removeAllChildren(wordCacheNum);
wordCacheNum.appendChild(document.createTextNode(wordCacheSize+"/"+wordCacheMaxSize));
wordCacheSpan=document.getElementById("wordcacheSpan");
removeAllChildren(wordCacheSpan);
var img;
var percent=Math.round(wordCacheSize/wordCacheMaxSize*100);
for(i=0;i<percent*WORDCACHEBAR_LENGTH;i++){
img=document.createElement("img");
img.setAttribute("src", BAR_IMG2);
wordCacheSpan.appendChild(img);
}
for(i=0;i<(100-percent)*WORDCACHEBAR_LENGTH;i++){
img=document.createElement("img");
img.setAttribute("src", BAR_IMG1);
wordCacheSpan.appendChild(img);
}
statusLoaded=true;
}
function handleQueues(){
if(queuesRPC.readyState != 4){
return;
}
var queuesResponse = queuesRPC.responseXML;
//xml=getFirstChild(queuesResponse);
xml=getFirstChild(queuesResponse, "queues");
if(queuesResponse != null){
clearTable(document.getElementById("queueTable"), 1);
dbsize=getFirstChild(xml, "dbsize");
urlpublictextSize=getValue(getFirstChild(dbsize, "urlpublictext"));
rwipublictextSize=getValue(getFirstChild(dbsize, "rwipublictext"));
document.getElementById("urldbsize").firstChild.nodeValue=urlpublictextSize;
document.getElementById("rwidbsize").firstChild.nodeValue=rwipublictextSize;
loaderqueue=getFirstChild(xml, "loaderqueue");
updateTable(loaderqueue, "loader");
loaderqueue_size=getValue(getFirstChild(loaderqueue, "size"));
loaderqueue_max=getValue(getFirstChild(loaderqueue, "max"));
document.getElementById("loaderqueuesize").firstChild.nodeValue=loaderqueue_size;
document.getElementById("loaderqueuemax").firstChild.nodeValue=loaderqueue_max;
localcrawlerqueue=getFirstChild(xml, "localcrawlerqueue");
localcrawlerqueue_size=getValue(getFirstChild(localcrawlerqueue, "size"));
localcrawlerqueue_state=getValue(getFirstChild(localcrawlerqueue, "state"));
document.getElementById("localcrawlerqueuesize").firstChild.nodeValue=localcrawlerqueue_size;
putQueueState("localcrawler", localcrawlerqueue_state);
updateTable(localcrawlerqueue, "local crawler");
limitcrawlerqueue=getFirstChild(xml, "limitcrawlerqueue");
updateTable(limitcrawlerqueue, "limitCrawlerTable");
limitcrawlerqueue_size=getValue(getFirstChild(limitcrawlerqueue, "size"));
limitcrawlerqueue_state=getValue(getFirstChild(limitcrawlerqueue, "state"));
document.getElementById("limitcrawlerqueuesize").firstChild.nodeValue=limitcrawlerqueue_size;
putQueueState("limitcrawler", limitcrawlerqueue_state);
updateTable(limitcrawlerqueue, "limit crawler");
remotecrawlerqueue=getFirstChild(xml, "remotecrawlerqueue");
updateTable(remotecrawlerqueue, "remoteCrawlerTable");
remotecrawlerqueue_size=getValue(getFirstChild(remotecrawlerqueue, "size"));
remotecrawlerqueue_state=getValue(getFirstChild(remotecrawlerqueue, "state"));
document.getElementById("remotecrawlerqueuesize").firstChild.nodeValue=remotecrawlerqueue_size;
putQueueState("remotecrawler", remotecrawlerqueue_state);
updateTable(remotecrawlerqueue, "remote crawler");
}
queueLoaded=true;
}
function putQueueState(queue, state) {
a = document.getElementById(queue + "stateA");
img = document.getElementById(queue + "stateIMG");
if (state == "paused") {
a.href = "WatchCrawler_p.html?continue=" + queue;
a.title = "Continue this queue";
img.src = "/env/grafics/start.gif";
img.alt = "Continue this queue";
} else {
a.href = "WatchCrawler_p.html?pause=" + queue;
a.title = "Pause this queue";
img.src = "/env/grafics/stop.gif";
img.alt = "Pause this queue";
}
}
function updateTable(indexingqueue, tablename){
indexingTable=document.getElementById("queueTable");
entries=indexingqueue.getElementsByTagName("entry");
dark=false;
for(i=0;i<entries.length;i++){
profile=getValue(getFirstChild(entries[i], "profile"));
initiator=getValue(getFirstChild(entries[i], "initiator"));
depth=getValue(getFirstChild(entries[i], "depth"));
modified=getValue(getFirstChild(entries[i], "modified"));
anchor=getValue(getFirstChild(entries[i], "anchor"));
url=getValue(getFirstChild(entries[i], "url"));
size=getValue(getFirstChild(entries[i], "size"));
hash=getValue(getFirstChild(entries[i], "hash"));
inProcess=false;
if(getValue(getFirstChild(entries[i], "inProcess"))=="true"){
inProcess=true;
}
if (tablename=="indexingTable")
deletebutton=createLinkCol("IndexCreateIndexingQueue_p.html?deleteEntry="+hash, DELETE_STRING);
else
deletebutton=createCol("");
row=createIndexingRow(tablename, profile, initiator, depth, modified, anchor, url, size, deletebutton);
//create row
if(inProcess){
row.setAttribute("class", "TableCellActive");
}else if(dark){
row.setAttribute("class", "TableCellDark");
}else{
row.setAttribute("class", "TableCellLight");
}
getFirstChild(indexingTable, "tbody").appendChild(row);
dark=!dark;
}
}
function shortenURL(url) {
if (url.length > 80) {
return url.substr(0, 80) + "...";
} else {
return url;
}
}
function createIndexingRow(queue, profile, initiator, depth, modified, anchor, url, size, deletebutton){
row=document.createElement("tr");
row.setAttribute("height", 10);
row.appendChild(createCol(queue));
row.appendChild(createCol(profile));
row.appendChild(createCol(initiator));
row.appendChild(createCol(depth));
row.appendChild(createCol(modified));
row.appendChild(createCol(anchor));
row.appendChild(createLinkCol(url, shortenURL(url)));
row.appendChild(createCol(size));
row.appendChild(deletebutton);
return row;
}