Make Peers more receptible to transferred indexes

- Set MaxWordCount for dhtInCache to indexDistribution.dhtReceiptLimit
  so that the inCache gets flushed when the limit is passed
- Modify flushCacheSome to flush enough words to get below MaxWordCount immediately



git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@2649 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
hermens 19 years ago
parent 740696f6c3
commit 3f5a4153a0

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

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

Loading…
Cancel
Save