Skip to content

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

preparation for intermission feature (pausing all threads, i.e. for search requests)

orbiter6be19d76c976
diff --git a/source/de/anomic/server/serverAbstractSwitch.java b/source/de/anomic/server/serverAbstractSwitch.java
index ee6e48f10..6618037a2 100644
--- a/source/de/anomic/server/serverAbstractSwitch.java
+++ b/source/de/anomic/server/serverAbstractSwitch.java
@@ -292,6 +292,13 @@ public abstract class serverAbstractSwitch implements serverSwitch {
workerThreads.remove(threadName);
}
}
+
+ public void intermissionAllThreads(long pause) {
+ Iterator e = workerThreads.keySet().iterator();
+ while (e.hasNext()) {
+ ((serverThread) workerThreads.get((String) e.next())).intermission(pause);
+ }
+ }
public synchronized void terminateAllThreads(boolean waitFor) {
Iterator e = workerThreads.keySet().iterator();
diff --git a/source/de/anomic/server/serverAbstractThread.java b/source/de/anomic/server/serverAbstractThread.java
index d9235cbad..6cd6ee8a4 100644
--- a/source/de/anomic/server/serverAbstractThread.java
+++ b/source/de/anomic/server/serverAbstractThread.java
@@ -54,7 +54,7 @@ import de.anomic.server.logging.serverLog;
public abstract class serverAbstractThread extends Thread implements serverThread {
- private long startup = 0, idlePause = 0, busyPause = 0, blockPause = 0;
+ private long startup = 0, intermission = 0, idlePause = 0, busyPause = 0, blockPause = 0;
private boolean running = true;
private serverLog log = null;
private long idletime = 0, busytime = 0, memprereq = 0;
@@ -163,6 +163,10 @@ public abstract class serverAbstractThread extends Thread implements serverThrea
this.log = log;
}
+ public void intermission(long pause) {
+ this.intermission = System.currentTimeMillis() + pause;
+ }
+
public void terminate(boolean waitFor) {
// after calling this method, the thread shall terminate
this.running = false;
@@ -227,6 +231,12 @@ public abstract class serverAbstractThread extends Thread implements serverThrea
Runtime rt = Runtime.getRuntime();
while (running) {
+ if (this.intermission > 0) {
+ if (this.intermission > System.currentTimeMillis()) {
+ ratz(System.currentTimeMillis() - this.intermission);
+ }
+ this.intermission = 0;
+ }
if (rt.freeMemory() > memprereq) try {
// do job
timestamp = System.currentTimeMillis();
@@ -292,4 +302,4 @@ public abstract class serverAbstractThread extends Thread implements serverThrea
}
}
}
-}
\ No newline at end of file
+}
diff --git a/source/de/anomic/server/serverSwitch.java b/source/de/anomic/server/serverSwitch.java
index 8a24eba02..3b5b3ac78 100644
--- a/source/de/anomic/server/serverSwitch.java
+++ b/source/de/anomic/server/serverSwitch.java
@@ -79,7 +79,9 @@ public interface serverSwitch {
public serverThread getThread(String threadName);
public void setThreadPerformance(String threadName, long idleMillis, long busyMillis, long memprereq);
public void terminateThread(String threadName, boolean waitFor);
+ public void intermissionAllThreads(long pause);
public void terminateAllThreads(boolean waitFor);
+
public Iterator /*of serverThread-Names (String)*/ threadNames();
// the switchboard can be used to set and read properties
diff --git a/source/de/anomic/server/serverThread.java b/source/de/anomic/server/serverThread.java
index a02692f85..7f02df957 100644
--- a/source/de/anomic/server/serverThread.java
+++ b/source/de/anomic/server/serverThread.java
@@ -102,6 +102,10 @@ public interface serverThread {
public void jobExceptionHandler(Exception e);
// handles any action necessary during job execution
+ public void intermission(long pause);
+ // the thread is forced to pause for a specific time
+ // if the thread is busy meanwhile, the pause is ommitted
+
public void terminate(boolean waitFor);
// after calling this method, the thread shall terminate
// if waitFor is true, the method waits until the process has died