Skip to content

Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance

better control of index flush

orbiterf58283def24f
diff --git a/htroot/yacy/transferRWI.java b/htroot/yacy/transferRWI.java
index d98a43427..72c8cd151 100644
--- a/htroot/yacy/transferRWI.java
+++ b/htroot/yacy/transferRWI.java
@@ -89,7 +89,12 @@ public final class transferRWI {
String result = "ok";
StringBuffer unknownURLs = new StringBuffer();
int pause = 0;
-
+
+ if ((granted) && (sb.wordIndex.busyCacheFlush)) {
+ // wait a little bit, maybe we got into a short flush slot
+ for (int i = 0; i < 20; i++) if (sb.wordIndex.busyCacheFlush) try {Thread.sleep(100);} catch (InterruptedException e) {}
+ }
+
if (!granted) {
// we dont want to receive indexes
sb.getLog().logInfo("Rejecting RWIs from peer " + otherPeerName + ". Not granted.");
diff --git a/source/de/anomic/plasma/plasmaWordIndex.java b/source/de/anomic/plasma/plasmaWordIndex.java
index ea90b6045..f29970ec3 100644
--- a/source/de/anomic/plasma/plasmaWordIndex.java
+++ b/source/de/anomic/plasma/plasmaWordIndex.java
@@ -198,14 +198,15 @@ public final class plasmaWordIndex extends indexAbstractRI implements indexRI {
synchronized (this) { ramCache.shiftK2W(); }
System.out.println("DEBUG-B");
int flushCount = ramCache.wSize() / 500;
- if (flushCount > 70) flushCount = 70;
- if (flushCount < 5) flushCount = 5;
+ if (flushCount > 80) flushCount = 80;
+ if (flushCount < 10) flushCount = Math.min(10, ramCache.wSize());
System.out.println("DEBUG-C");
flushCache(flushCount);
System.out.println("DEBUG-D");
}
public void flushCache(int count) {
+ if (count <= 0) return;
synchronized (ramCache) {
busyCacheFlush = true;
for (int i = 0; i < count; i++) {