From dc0a2d4c11916a24a9227add5c7d0382cb742adc Mon Sep 17 00:00:00 2001 From: theli Date: Fri, 2 Sep 2005 11:40:40 +0000 Subject: [PATCH] *) Bugfix for Loader Queue: Job count was not displayed correctly *) IndexingQueue: - now it's possible to delete single entries from the queue - now it's possible to clear the whole queue See: http://www.yacy-forum.de/viewtopic.php?t=995 git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@641 6c8d7289-2bf4-0310-a012-ef5d649a1542 --- htroot/IndexCreateIndexingQueue_p.html | 10 ++++- htroot/IndexCreateIndexingQueue_p.java | 43 +++++++++++++++---- htroot/IndexCreateLoaderQueue_p.java | 5 +-- .../anomic/plasma/plasmaSwitchboardQueue.java | 9 ++++ 4 files changed, 53 insertions(+), 14 deletions(-) diff --git a/htroot/IndexCreateIndexingQueue_p.html b/htroot/IndexCreateIndexingQueue_p.html index c7d58f101..9b4d86938 100644 --- a/htroot/IndexCreateIndexingQueue_p.html +++ b/htroot/IndexCreateIndexingQueue_p.html @@ -14,6 +14,10 @@ #(indexing-queue)# The indexing queue is empty
:: +
+ +
+
There are #[num]# entries in the indexing queue:
@@ -23,15 +27,17 @@ There are #[num]# entries in the indexing queue:
+ #{list}# - + - + + #{/list}#
Anchor Name URL SizeDelete
#[initiator]# #[depth]# #[modified]# #[anchor]# #[url]##[size]##[size]##(inProcess)#[Delete]::#(/inProcess)#
diff --git a/htroot/IndexCreateIndexingQueue_p.java b/htroot/IndexCreateIndexingQueue_p.java index 9e8e9d01f..d8cf2d867 100644 --- a/htroot/IndexCreateIndexingQueue_p.java +++ b/htroot/IndexCreateIndexingQueue_p.java @@ -77,18 +77,37 @@ public class IndexCreateIndexingQueue_p { if (post != null) { if (post.containsKey("clearRejected")) { switchboard.urlPool.errorURL.clearStack(); - } + } if (post.containsKey("moreRejected")) { showRejectedCount = Integer.parseInt(post.get("showRejected", "10")); } - if (post.containsKey("clearsbqueue")) { - //switchboard.sbQueue. + if (post.containsKey("clearIndexingQueue")) { + try { + synchronized (switchboard.sbQueue) { + switchboard.sbQueue.clear(); + } + } catch (Exception e) {} + } else if (post.containsKey("deleteEntry")) { + String urlHash = (String) post.get("deleteEntry"); + try { + synchronized (switchboard.sbQueue) { + ArrayList entries = switchboard.sbQueue.list(0); + for (int i=entries.size()-1; i >= 0; i--) { + plasmaSwitchboardQueue.Entry pcentry = (plasmaSwitchboardQueue.Entry) entries.get(i); + if (pcentry.urlHash().equals(urlHash)) { + switchboard.sbQueue.remove(i); + break; + } + } + } + } catch (Exception e) {} + prop.put("LOCATION",""); + return prop; } } yacySeed initiator; boolean dark; - int i=0; if ((switchboard.sbQueue.size() == 0) && (switchboard.indexingTasksInProcess.size() == 0)) { prop.put("indexing-queue", 0); //is empty @@ -97,29 +116,35 @@ public class IndexCreateIndexingQueue_p { dark = true; plasmaSwitchboardQueue.Entry pcentry; - int entryCount = 0; + int inProcessCount = 0, entryCount = 0; try { ArrayList entryList = new ArrayList(); // getting all entries that are currently in process synchronized (switchboard.indexingTasksInProcess) { + inProcessCount = switchboard.indexingTasksInProcess.size(); entryList.addAll(switchboard.indexingTasksInProcess.values()); } // getting all enqueued entries - entryList.addAll(switchboard.sbQueue.list(0)); + if ((switchboard.sbQueue.size() > 0)) { + entryList.addAll(switchboard.sbQueue.list(0)); + } - for (i = 0; i < entryList.size(); i++) { + for (int i = 0; i < entryList.size(); i++) { + boolean inProcess = i < inProcessCount; pcentry = (plasmaSwitchboardQueue.Entry) entryList.get(i); if ((pcentry != null)&&(pcentry.url() != null)) { initiator = yacyCore.seedDB.getConnected(pcentry.initiator()); - prop.put("indexing-queue_list_"+entryCount+"_dark", ((dark) ? 1 : 0)); + prop.put("indexing-queue_list_"+entryCount+"_dark", (inProcess)? 2: ((dark) ? 1 : 0)); prop.put("indexing-queue_list_"+entryCount+"_initiator", ((initiator == null) ? "proxy" : initiator.getName())); prop.put("indexing-queue_list_"+entryCount+"_depth", pcentry.depth()); prop.put("indexing-queue_list_"+entryCount+"_modified", (pcentry.responseHeader() == null) ? "" : daydate(pcentry.responseHeader().lastModified())); prop.put("indexing-queue_list_"+entryCount+"_anchor", (pcentry.anchorName()==null)?"":pcentry.anchorName()); prop.put("indexing-queue_list_"+entryCount+"_url", pcentry.normalizedURLString()); prop.put("indexing-queue_list_"+entryCount+"_size", Status.bytesToString(pcentry.size())); + prop.put("indexing-queue_list_"+entryCount+"_inProcess", (inProcess)?1:0); + prop.put("indexing-queue_list_"+entryCount+"_0_hash", pcentry.urlHash()); dark = !dark; entryCount++; } @@ -147,7 +172,7 @@ public class IndexCreateIndexingQueue_p { plasmaCrawlEURL.Entry entry; yacySeed initiatorSeed, executorSeed; int j=0; - for (i = switchboard.urlPool.errorURL.stackSize() - 1; i >= (switchboard.urlPool.errorURL.stackSize() - showRejectedCount); i--) { + for ( int i = switchboard.urlPool.errorURL.stackSize() - 1; i >= (switchboard.urlPool.errorURL.stackSize() - showRejectedCount); i--) { entry = (plasmaCrawlEURL.Entry) switchboard.urlPool.errorURL.getStack(i); initiatorHash = entry.initiator(); executorHash = entry.executor(); diff --git a/htroot/IndexCreateLoaderQueue_p.java b/htroot/IndexCreateLoaderQueue_p.java index 1e7eaebe0..1c9f285c5 100644 --- a/htroot/IndexCreateLoaderQueue_p.java +++ b/htroot/IndexCreateLoaderQueue_p.java @@ -73,11 +73,9 @@ public class IndexCreateLoaderQueue_p { prop.put("loader-set", 0); } else { prop.put("loader-set", 1); - prop.put("loader-set_num", switchboard.cacheLoader.size()); boolean dark = true; - ThreadGroup loaderThreads = switchboard.cacheLoader.threadStatus(); - + ThreadGroup loaderThreads = switchboard.cacheLoader.threadStatus(); int threadCount = loaderThreads.activeCount(); Thread[] threadList = new Thread[threadCount*2]; threadCount = loaderThreads.enumerate(threadList); @@ -96,6 +94,7 @@ public class IndexCreateLoaderQueue_p { dark = !dark; } prop.put("loader-set_list", i ); + prop.put("loader-set_num", i); } // return rewrite properties diff --git a/source/de/anomic/plasma/plasmaSwitchboardQueue.java b/source/de/anomic/plasma/plasmaSwitchboardQueue.java index 202bea467..5ae1b94eb 100644 --- a/source/de/anomic/plasma/plasmaSwitchboardQueue.java +++ b/source/de/anomic/plasma/plasmaSwitchboardQueue.java @@ -107,6 +107,11 @@ public class plasmaSwitchboardQueue { return new Entry(sbQueueStack.pot()); } + public Entry remove(int index) throws IOException { + if (sbQueueStack.size() == 0) return null; + return new Entry(sbQueueStack.pot(index)); + } + public Entry get(int index) throws IOException { if ((index < 0) || (index >= sbQueueStack.size())) throw new ArrayIndexOutOfBoundsException(); return new Entry(sbQueueStack.bot(index)); @@ -125,6 +130,10 @@ public class plasmaSwitchboardQueue { return list; } + public void clear() throws IOException { + sbQueueStack.clear(); + } + public void close() { if (sbQueueStack != null) try { sbQueueStack.close();