Skip to content

Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance

fixed 100% CPU bug with news queue deletion

orbiter50a9500035e1
diff --git a/htroot/News.java b/htroot/News.java
index cedef06cd..bb15bc3d8 100644
--- a/htroot/News.java
+++ b/htroot/News.java
@@ -95,9 +95,13 @@ public class News {
}
yacyNewsRecord record;
try {
- while (yacyCore.newsPool.size(tableID) > 0) {
- record = yacyCore.newsPool.get(tableID, 0);
- yacyCore.newsPool.moveOff(tableID, record.id());
+ if ((tableID == 2) || (tableID == 4)) {
+ yacyCore.newsPool.clear(tableID);
+ } else {
+ while (yacyCore.newsPool.size(tableID) > 0) {
+ record = yacyCore.newsPool.get(tableID, 0);
+ yacyCore.newsPool.moveOff(tableID, record.id());
+ }
}
} catch (IOException e) {
e.printStackTrace();
diff --git a/source/de/anomic/yacy/yacyNewsPool.java b/source/de/anomic/yacy/yacyNewsPool.java
index b1828aeff..5f299761f 100644
--- a/source/de/anomic/yacy/yacyNewsPool.java
+++ b/source/de/anomic/yacy/yacyNewsPool.java
@@ -229,6 +229,17 @@ public class yacyNewsPool {
return null;
}
+ public void clear(int dbKey) throws IOException {
+ // this is called if a queue element shall be moved to another queue or off the queue
+ // it depends on the dbKey how the record is handled
+ switch (dbKey) {
+ case INCOMING_DB: incomingNews.clear(); break;
+ case PROCESSED_DB: processedNews.clear(); break;
+ case OUTGOING_DB: outgoingNews.clear(); break;
+ case PUBLISHED_DB: publishedNews.clear(); break;
+ }
+ }
+
public void moveOff(int dbKey, String id) throws IOException {
// this is called if a queue element shall be moved to another queue or off the queue
// it depends on the dbKey how the record is handled
@@ -245,10 +256,10 @@ public class yacyNewsPool {
// the news is also removed from the news database
yacyNewsRecord record;
synchronized (fromqueue) {
- for (int i = fromqueue.size() - 1; i >= 0; i--) {
- record = fromqueue.top(i);
+ while (fromqueue.size() > 0) {
+ record = fromqueue.top(0);
if ((record != null) && (record.id().equals(id))) {
- fromqueue.pop(i);
+ fromqueue.pop(0);
if (toqueue != null) toqueue.push(record);
//newsDB.remove(id);
return true;
diff --git a/source/de/anomic/yacy/yacyNewsQueue.java b/source/de/anomic/yacy/yacyNewsQueue.java
index 37d550e29..92765ee49 100644
--- a/source/de/anomic/yacy/yacyNewsQueue.java
+++ b/source/de/anomic/yacy/yacyNewsQueue.java
@@ -88,6 +88,10 @@ public class yacyNewsQueue {
queueStack = createStack(path);
}
+ public void clear() throws IOException {
+ resetDB();
+ }
+
public void close() {
if (queueStack != null) try {queueStack.close();} catch (IOException e) {}
queueStack = null;