fixed 100% CPU bug with news queue deletion

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@735 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
orbiter 19 years ago
parent f50d45678e
commit 50a9500035

@ -95,9 +95,13 @@ public class News {
} }
yacyNewsRecord record; yacyNewsRecord record;
try { try {
while (yacyCore.newsPool.size(tableID) > 0) { if ((tableID == 2) || (tableID == 4)) {
record = yacyCore.newsPool.get(tableID, 0); yacyCore.newsPool.clear(tableID);
yacyCore.newsPool.moveOff(tableID, record.id()); } else {
while (yacyCore.newsPool.size(tableID) > 0) {
record = yacyCore.newsPool.get(tableID, 0);
yacyCore.newsPool.moveOff(tableID, record.id());
}
} }
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();

@ -229,6 +229,17 @@ public class yacyNewsPool {
return null; 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 { 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 // 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 // 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 // the news is also removed from the news database
yacyNewsRecord record; yacyNewsRecord record;
synchronized (fromqueue) { synchronized (fromqueue) {
for (int i = fromqueue.size() - 1; i >= 0; i--) { while (fromqueue.size() > 0) {
record = fromqueue.top(i); record = fromqueue.top(0);
if ((record != null) && (record.id().equals(id))) { if ((record != null) && (record.id().equals(id))) {
fromqueue.pop(i); fromqueue.pop(0);
if (toqueue != null) toqueue.push(record); if (toqueue != null) toqueue.push(record);
//newsDB.remove(id); //newsDB.remove(id);
return true; return true;

@ -88,6 +88,10 @@ public class yacyNewsQueue {
queueStack = createStack(path); queueStack = createStack(path);
} }
public void clear() throws IOException {
resetDB();
}
public void close() { public void close() {
if (queueStack != null) try {queueStack.close();} catch (IOException e) {} if (queueStack != null) try {queueStack.close();} catch (IOException e) {}
queueStack = null; queueStack = null;

Loading…
Cancel
Save