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,10 +95,14 @@ public class News {
}
yacyNewsRecord record;
try {
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();
}

@ -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;

@ -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;

Loading…
Cancel
Save