mirror of
https://github.com/yacy/yacy_search_server.git
synced 2025-07-17 08:26:08 -04:00
preparation for intermission feature (pausing all threads, i.e. for search requests)
git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@509 6c8d7289-2bf4-0310-a012-ef5d649a1542
This commit is contained in:
source/de/anomic/server
@ -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();
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Reference in New Issue
Block a user