Skip to content

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

fix for termination problem

orbiter5393f356aa47
diff --git a/source/de/anomic/index/indexRAMRI.java b/source/de/anomic/index/indexRAMRI.java
index b32763fe3..6e7ea8c69 100644
--- a/source/de/anomic/index/indexRAMRI.java
+++ b/source/de/anomic/index/indexRAMRI.java
@@ -256,7 +256,7 @@ public final class indexRAMRI implements indexRI, indexRIReader, Iterable<indexC
public synchronized indexContainer deleteContainer(final String wordHash) {
// returns the index that had been deleted
- if (wordHash == null) return null;
+ if (wordHash == null || heap == null) return null;
final indexContainer container = heap.deleteContainer(wordHash);
hashScore.deleteScore(wordHash);
hashDate.deleteScore(wordHash);
diff --git a/source/de/anomic/plasma/plasmaSwitchboard.java b/source/de/anomic/plasma/plasmaSwitchboard.java
index 53b492824..559d6f69f 100644
--- a/source/de/anomic/plasma/plasmaSwitchboard.java
+++ b/source/de/anomic/plasma/plasmaSwitchboard.java
@@ -1084,6 +1084,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch<IndexingStack.
terminateAllThreads(true);
log.logConfig("SWITCHBOARD SHUTDOWN STEP 2: sending termination signal to threaded indexing");
// closing all still running db importer jobs
+ dhtDispatcher.close();
indexingDocumentProcessor.announceShutdown();
indexingDocumentProcessor.awaitShutdown(12000);
crawlStacker.announceClose();
@@ -2110,6 +2111,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch<IndexingStack.
public boolean waitForShutdown() throws InterruptedException {
this.shutdownSync.P();
+ dhtDispatcher.close();
return this.terminate;
}
diff --git a/source/de/anomic/yacy/dht/Dispatcher.java b/source/de/anomic/yacy/dht/Dispatcher.java
index 61c1f7b46..adae0e6ed 100755
--- a/source/de/anomic/yacy/dht/Dispatcher.java
+++ b/source/de/anomic/yacy/dht/Dispatcher.java
@@ -358,7 +358,7 @@ public class Dispatcher {
if (chunk.canFinish()) {
try {
- this.indexingTransmissionProcessor.enQueue(chunk);
+ if (this.indexingTransmissionProcessor != null) this.indexingTransmissionProcessor.enQueue(chunk);
} catch (InterruptedException e) {
e.printStackTrace();
return null;
@@ -371,15 +371,21 @@ public class Dispatcher {
}
}
- public void close() throws IOException {
+ public void close() {
// removes all entries from the dispatcher and puts them back to a RAMRI
- this.indexingTransmissionProcessor.announceShutdown();
- for (Map.Entry<String, Transmission.Chunk> e : this.transmissionCloud.entrySet()) {
- for (indexContainer i : e.getValue()) this.backend.addEntries(i);
+ if (indexingTransmissionProcessor != null) this.indexingTransmissionProcessor.announceShutdown();
+ if (this.transmissionCloud != null) {
+ for (Map.Entry<String, Transmission.Chunk> e : this.transmissionCloud.entrySet()) {
+ for (indexContainer i : e.getValue()) try {this.backend.addEntries(i);} catch (IOException e1) {}
+ }
+ this.transmissionCloud.clear();
}
- this.transmissionCloud.clear();
this.transmissionCloud = null;
- this.indexingTransmissionProcessor.awaitShutdown(10000);
+ if (indexingTransmissionProcessor != null) {
+ this.indexingTransmissionProcessor.awaitShutdown(10000);
+ this.indexingTransmissionProcessor.clear();
+ }
+ this.indexingTransmissionProcessor = null;
}
}