[vlma-devel] commit: Ability to stop a monitor. (Adrien Grand )
git version control
git at videolan.org
Tue Jul 8 01:04:55 CEST 2008
vlma | branch: master | Adrien Grand <jpountz at videolan.org> | Mon Jul 7 16:37:59 2008 +0200| [91f05c1e47d37b85508595c79941410a68c4ab3d]
Ability to stop a monitor.
> http://git.videolan.org/gitweb.cgi/vlma.git/?a=commit;h=91f05c1e47d37b85508595c79941410a68c4ab3d
---
.../java/org/videolan/vlma/monitor/Monitor.java | 10 +++++++++-
.../org/videolan/vlma/monitor/OrderMonitor.java | 11 +++++++++--
.../org/videolan/vlma/monitor/ServerMonitor.java | 10 ++++++++--
3 files changed, 26 insertions(+), 5 deletions(-)
diff --git a/vlma-core/src/main/java/org/videolan/vlma/monitor/Monitor.java b/vlma-core/src/main/java/org/videolan/vlma/monitor/Monitor.java
index f704a02..734ce9f 100644
--- a/vlma-core/src/main/java/org/videolan/vlma/monitor/Monitor.java
+++ b/vlma-core/src/main/java/org/videolan/vlma/monitor/Monitor.java
@@ -27,6 +27,14 @@ package org.videolan.vlma.monitor;
*/
public interface Monitor {
- void startDaemon();
+ /**
+ * Starts the monitor.
+ */
+ void start();
+
+ /**
+ * Stops the monitor.
+ */
+ void stop();
}
diff --git a/vlma-core/src/main/java/org/videolan/vlma/monitor/OrderMonitor.java b/vlma-core/src/main/java/org/videolan/vlma/monitor/OrderMonitor.java
index ed3c232..5eb9d1c 100644
--- a/vlma-core/src/main/java/org/videolan/vlma/monitor/OrderMonitor.java
+++ b/vlma-core/src/main/java/org/videolan/vlma/monitor/OrderMonitor.java
@@ -50,6 +50,8 @@ public class OrderMonitor implements Monitor {
private Thread orderMonitorDaemonThread;
+ private boolean shouldRun;
+
public boolean isMonitoring() {
return (orderMonitorThread != null) && (orderMonitorThread.isAlive());
};
@@ -150,7 +152,8 @@ public class OrderMonitor implements Monitor {
private Runnable orderMonitorDaemon = new Runnable() {
public void run() {
- while (true) {
+ shouldRun = true;
+ while (shouldRun) {
startOrderMonitoringThread();
// Wait before looping
try {
@@ -163,7 +166,7 @@ public class OrderMonitor implements Monitor {
};
- public synchronized void startDaemon() {
+ public synchronized void start() {
if (!isDaemonMonitoring()) {
orderMonitorDaemonThread = new Thread(orderMonitorDaemon);
orderMonitorDaemonThread.setName("OrderMonitorDaemonThread");
@@ -171,6 +174,10 @@ public class OrderMonitor implements Monitor {
}
}
+ public synchronized void stop() {
+ shouldRun = false;
+ }
+
/**
* Sets the VLMa service.
*
diff --git a/vlma-core/src/main/java/org/videolan/vlma/monitor/ServerMonitor.java b/vlma-core/src/main/java/org/videolan/vlma/monitor/ServerMonitor.java
index 530b2ba..1314966 100644
--- a/vlma-core/src/main/java/org/videolan/vlma/monitor/ServerMonitor.java
+++ b/vlma-core/src/main/java/org/videolan/vlma/monitor/ServerMonitor.java
@@ -49,6 +49,8 @@ public class ServerMonitor implements Monitor {
private Thread serverMonitorDaemonThread;
+ private boolean shouldRun;
+
public boolean isCheckingVLC() {
return (checkVLCThread != null) && (checkVLCThread.isAlive());
}
@@ -120,7 +122,8 @@ public class ServerMonitor implements Monitor {
*/
Runnable serverMonitorDaemon = new Runnable() {
public void run() {
- while (true) {
+ shouldRun = true;
+ while (shouldRun) {
startCheckVLCThread(); //The VLC thread checker is launched
startUpdateSNMPDataThread(); //The SNMP Data updater thread checker is launched
try { //Then we wait before looping
@@ -133,7 +136,7 @@ public class ServerMonitor implements Monitor {
};
- public synchronized void startDaemon() {
+ public synchronized void start() {
if (!isDaemonMonitoring()) {
serverMonitorDaemonThread = new Thread(serverMonitorDaemon);
serverMonitorDaemonThread.setName("serverMonitorThread");
@@ -141,6 +144,9 @@ public class ServerMonitor implements Monitor {
}
}
+ public synchronized void stop() {
+ shouldRun = false;
+ }
/**
* Sets the VLMa service.
More information about the vlma-devel
mailing list