Skip to content

Commit

Permalink
*) adding support for delayed shutdown
Browse files Browse the repository at this point in the history
   - needed by Ismael to receive the Steering page properly on shutdown
   - now the steering page should always be displayed properly in the web browser

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@2129 6c8d7289-2bf4-0310-a012-ef5d649a1542
  • Loading branch information
theli committed May 22, 2006
1 parent 9739319 commit 61078b3
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion htroot/Steering.java
Expand Up @@ -69,7 +69,7 @@ public static serverObjects respond(httpHeader header, serverObjects post, serve

if (post.containsKey("shutdown")) {
ss.setConfig("restart", "false");
sb.terminate();
sb.terminate(3000);
prop.put("info", 3);
return prop;
}
Expand Down
23 changes: 23 additions & 0 deletions source/de/anomic/plasma/plasmaSwitchboard.java
Expand Up @@ -2219,6 +2219,11 @@ public boolean dhtTransferProcess(plasmaDHTChunk dhtChunk, int peerCount) {
}
}

public void terminate(long delay) {
if (delay <= 0) throw new IllegalArgumentException("The shutdown delay must be greater than 0.");
(new delayedShutdown(this,delay)).start();
}

public void terminate() {
this.terminate = true;
this.shutdownSync.V();
Expand All @@ -2233,3 +2238,21 @@ public boolean waitForShutdown() throws InterruptedException {
return this.terminate;
}
}

class delayedShutdown extends Thread {
private plasmaSwitchboard sb;
private long delay;
public delayedShutdown(plasmaSwitchboard sb, long delay) {
this.sb = sb;
this.delay = delay;
}

public void run() {
try {
Thread.sleep(delay);
} catch (InterruptedException e) {
e.printStackTrace();
}
this.sb.terminate();
}
}

0 comments on commit 61078b3

Please sign in to comment.