fix for termination problem

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@5589 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
orbiter 16 years ago
parent 6a876ecb88
commit 5393f356aa

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

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

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

Loading…
Cancel
Save