Commit 81c1ef45 authored by Andre Freyssinet's avatar Andre Freyssinet

Enhancements in CheckServer handling.

parent 96b8c245
/* /*
* Copyright (C) 2001 - 2020 ScalAgent Distributed Technologies * Copyright (C) 2001 - 2021 ScalAgent Distributed Technologies
* Copyright (C) 2004 France Telecom R&D * Copyright (C) 2004 France Telecom R&D
* Copyright (C) 1996 - 2000 BULL * Copyright (C) 1996 - 2000 BULL
* Copyright (C) 1996 - 2000 INRIA * Copyright (C) 1996 - 2000 INRIA
...@@ -461,6 +461,12 @@ public final class AgentServer { ...@@ -461,6 +461,12 @@ public final class AgentServer {
checkServerTask.registerListener(listener); 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; static ThreadGroup tgroup = null;
public static ThreadGroup getThreadGroup() { public static ThreadGroup getThreadGroup() {
...@@ -1923,13 +1929,19 @@ class CheckServerTask extends TimerTask { ...@@ -1923,13 +1929,19 @@ class CheckServerTask extends TimerTask {
listeners = new Vector<CheckServerListener>(); listeners = new Vector<CheckServerListener>();
} }
public void registerListener(CheckServerListener listener) { public synchronized void registerListener(CheckServerListener listener) {
logmon.log(BasicLevel.INFO, logmon.log(BasicLevel.INFO,
AgentServer.getName() + " registers listener for CheckServer."); AgentServer.getName() + " registers listener for CheckServer.");
listeners.addElement(listener); 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) { for (CheckServerListener listener : listeners) {
logmon.log(BasicLevel.DEBUG, logmon.log(BasicLevel.DEBUG,
AgentServer.getName() + " calls listener for CheckServer."); AgentServer.getName() + " calls listener for CheckServer.");
...@@ -1974,8 +1986,8 @@ class CheckServerTask extends TimerTask { ...@@ -1974,8 +1986,8 @@ class CheckServerTask extends TimerTask {
if (! engine.isRunning()) { if (! engine.isRunning()) {
// The engine does not run, just log a warn if needed // The engine does not run, just log a warn if needed
if (((now - lastEngineChangeDate) > dtwarn) && ((now - lastEngineWarnDate) > dtwarn)) { if (((now - lastEngineChangeDate) > dtwarn) && ((now - lastEngineWarnDate) > dtwarn)) {
logmon.log(BasicLevel.DEBUG, logmon.log(BasicLevel.WARN,
AgentServer.getName() + ", engine is not started."); AgentServer.getName() + ", engine is not running.");
lastEngineWarnDate = now; lastEngineWarnDate = now;
} }
return false; 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