diff --git a/source/de/anomic/plasma/plasmaSwitchboard.java b/source/de/anomic/plasma/plasmaSwitchboard.java index 87c86f10e..5a489ecd6 100644 --- a/source/de/anomic/plasma/plasmaSwitchboard.java +++ b/source/de/anomic/plasma/plasmaSwitchboard.java @@ -432,6 +432,9 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements ser (int) getConfigLong("wordCacheMaxCount", 20000)); setConfig("wordCacheMaxCount", Integer.toString(wordCacheMaxCount)); wordIndex.setMaxWordCount(wordCacheMaxCount); + + int wordInCacheMaxCount = (int) getConfigLong("indexDistribution.dhtReceiptLimit", 1000); + wordIndex.setInMaxWordCount(wordInCacheMaxCount); // start a cache manager log.logConfig("Starting HT Cache Manager"); diff --git a/source/de/anomic/plasma/plasmaWordIndex.java b/source/de/anomic/plasma/plasmaWordIndex.java index b3025698e..7009100f0 100644 --- a/source/de/anomic/plasma/plasmaWordIndex.java +++ b/source/de/anomic/plasma/plasmaWordIndex.java @@ -178,6 +178,10 @@ public final class plasmaWordIndex extends indexAbstractRI implements indexRI { dhtOutCache.setMaxWordCount(maxWords); } + public void setInMaxWordCount(int maxWords) { + dhtInCache.setMaxWordCount(maxWords); + } + public void setWordFlushDivisor(int idleDivisor, int busyDivisor) { this.idleDivisor = idleDivisor; this.busyDivisor = busyDivisor; @@ -229,9 +233,14 @@ public final class plasmaWordIndex extends indexAbstractRI implements indexRI { } private void flushCacheSome(indexRAMCacheRI ram, boolean busy) { - int flushCount = (busy) ? ram.size() / busyDivisor : ram.size() / idleDivisor; - if (flushCount > 100) flushCount = 100; - if (flushCount < 1) flushCount = Math.min(1, ram.size()); + int flushCount; + if (ram.size() > ram.getMaxWordCount()) { + flushCount = ram.size() + 100 - ram.getMaxWordCount(); + } else { + flushCount = (busy) ? ram.size() / busyDivisor : ram.size() / idleDivisor; + if (flushCount > 100) flushCount = 100; + if (flushCount < 1) flushCount = Math.min(1, ram.size()); + } flushCache(ram, flushCount); }