From 53cbcc6d6ee99ac4f649663e8c0fa66bf9b42c32 Mon Sep 17 00:00:00 2001 From: hermens Date: Tue, 27 Jun 2006 11:14:30 +0000 Subject: [PATCH] Implement emergency break in index receive when the limit of the ramCache is exceeded by more than cacheLimit See: http://www.yacy-forum.de/viewtopic.php?p=22911#22911 git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@2248 6c8d7289-2bf4-0310-a012-ef5d649a1542 --- htroot/yacy/transferRWI.java | 8 +++++++- source/de/anomic/plasma/plasmaWordIndex.java | 4 ++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/htroot/yacy/transferRWI.java b/htroot/yacy/transferRWI.java index fb7346da0..52cbe032f 100644 --- a/htroot/yacy/transferRWI.java +++ b/htroot/yacy/transferRWI.java @@ -99,6 +99,12 @@ public final class transferRWI { granted = false; // don't accept more words if there are too many words to flush result = "busy"; pause = 60000; + } else if (checkLimit && sb.wordIndex.wSize() > (sb.wordIndex.getMaxWordCount() + cachelimit)) { + // we are too busy flushing the ramCache to receive indexes + sb.getLog().logInfo("Rejecting RWIs from peer " + otherPeerName + ". We are too busy (wordcachesize=" + sb.wordIndex.wSize() + ")."); + granted = false; // don't accept more words if there are too many words to flush + result = "busy"; + pause = 300000; } else { // we want and can receive indexes // log value status (currently added to find outOfMemory error @@ -186,4 +192,4 @@ public final class transferRWI { // return rewrite properties return prop; } -} \ No newline at end of file +} diff --git a/source/de/anomic/plasma/plasmaWordIndex.java b/source/de/anomic/plasma/plasmaWordIndex.java index 927fb7264..909b78c98 100644 --- a/source/de/anomic/plasma/plasmaWordIndex.java +++ b/source/de/anomic/plasma/plasmaWordIndex.java @@ -149,6 +149,10 @@ public final class plasmaWordIndex extends indexAbstractRI implements indexRI { ramCache.setMaxWordCount(maxWords); } + public int getMaxWordCount() { + return ramCache.getMaxWordCount(); + } + public void flushControl() { // check for forced flush synchronized (this) { ramCache.shiftK2W(); }