Commit 3d7ab86a authored by Andre Freyssinet's avatar Andre Freyssinet

Adds synchronisation.

parent e496772a
......@@ -467,6 +467,12 @@ public final class AgentServer {
checkServerTask.registerListener(listener);
}
public static void unregisterCheckServerListener(CheckServerListener listener) {
if (checkServerTask == null)
logmon.log(BasicLevel.ERROR, getName() + " cannot unregister CheckServerListener.");
checkServerTask.unregisterListener(listener);
}
static ThreadGroup tgroup = null;
public static ThreadGroup getThreadGroup() {
......@@ -1931,13 +1937,19 @@ class CheckServerTask extends TimerTask {
listeners = new Vector<CheckServerListener>();
}
public void registerListener(CheckServerListener listener) {
public synchronized void registerListener(CheckServerListener listener) {
logmon.log(BasicLevel.INFO,
AgentServer.getName() + " registers listener for CheckServer.");
listeners.addElement(listener);
}
private void throwListeners() {
public synchronized void unregisterListener(CheckServerListener listener) {
logmon.log(BasicLevel.INFO,
AgentServer.getName() + " unregisters listener for CheckServer.");
listeners.removeElement(listener);
}
private synchronized void throwListeners() {
for (CheckServerListener listener : listeners) {
logmon.log(BasicLevel.DEBUG,
AgentServer.getName() + " calls listener for CheckServer.");
......@@ -1982,8 +1994,8 @@ class CheckServerTask extends TimerTask {
if (! engine.isRunning()) {
// The engine does not run, just log a warn if needed
if (((now - lastEngineChangeDate) > dtwarn) && ((now - lastEngineWarnDate) > dtwarn)) {
logmon.log(BasicLevel.DEBUG,
AgentServer.getName() + ", engine is not started.");
logmon.log(BasicLevel.WARN,
AgentServer.getName() + ", engine is not running.");
lastEngineWarnDate = now;
}
return false;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment