[vlma-devel] commit: Don't save data when the JVM shuts down. (Adrien Grand )
git version control
git at videolan.org
Mon Nov 10 18:45:46 CET 2008
vlma | branch: master | Adrien Grand <jpountz at videolan.org> | Mon Nov 10 18:37:36 2008 +0100| [4c8213b2698049ca8eef54a3db00a7eff80d9000] | committer: Adrien Grand
Don't save data when the JVM shuts down.
If the JVM shuts down because VLMa was not able to load data.xml, data
will be lost.
> http://git.videolan.org/gitweb.cgi/vlma.git/?a=commit;h=4c8213b2698049ca8eef54a3db00a7eff80d9000
---
.../main/java/org/videolan/vlma/daemon/Daemon.java | 3 --
.../org/videolan/vlma/monitor/ServerMonitor.java | 30 ++++++++++---------
.../videolan/vlma/monitor/ServerStateMonitor.java | 10 ++++--
3 files changed, 22 insertions(+), 21 deletions(-)
diff --git a/vlma-core/src/main/java/org/videolan/vlma/daemon/Daemon.java b/vlma-core/src/main/java/org/videolan/vlma/daemon/Daemon.java
index f80b63b..13bea7d 100644
--- a/vlma-core/src/main/java/org/videolan/vlma/daemon/Daemon.java
+++ b/vlma-core/src/main/java/org/videolan/vlma/daemon/Daemon.java
@@ -134,9 +134,6 @@ public class Daemon {
synchronized public void stop() {
running.set(false);
- // Save data
- vlmaDao.saveToDisk();
-
// Stop the monitors
logger.info("Stopping monitors...");
for (Monitor monitor : monitors) {
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 00f1a4c..a83b22a 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
@@ -68,17 +68,17 @@ public class ServerMonitor implements Monitor {
*/
Runnable snmpDataUpdater = new Runnable() {
public void run() {
- synchronized(ServerMonitor.this) {
- List<Thread> updateThreads = new ArrayList<Thread>();
- for (Server server : vlmaService.getServers()) {
- Thread updateThread = new UpdateThread(vlmaService, server);
- updateThreads.add(updateThread);
- updateThread.start();
- }
- for (Thread updateThread : updateThreads) {
- try {
- updateThread.join();
- } catch (InterruptedException e) { }
+ List<Thread> updateThreads = new ArrayList<Thread>();
+ for (Server server : vlmaService.getServers()) {
+ Thread updateThread = new UpdateThread(vlmaService, server);
+ updateThreads.add(updateThread);
+ updateThread.start();
+ }
+ for (Thread updateThread : updateThreads) {
+ try {
+ updateThread.join();
+ } catch (InterruptedException e) {
+ // Wait for the update to finish
}
}
}
@@ -107,10 +107,9 @@ public class ServerMonitor implements Monitor {
// Wait before looping
Thread.sleep(1000 * (TIME_INTERVAL - (Util.getTime() % TIME_INTERVAL)));
} catch (InterruptedException e) {
- // Do nothing
+ continue;
}
- if (shouldRun.get())
- startUpdateSNMPDataThread();
+ startUpdateSNMPDataThread();
}
logger.debug("ServerMonitor thread stopped.");
}
@@ -130,6 +129,9 @@ public class ServerMonitor implements Monitor {
logger.info("Stopping " + this.getClass().getSimpleName());
shouldRun.set(false);
serverMonitorDaemonThread.interrupt();
+ if(isUpdatingSNMPData()) {
+ logger.info("Please wait for the update of RRD graphs to finish");
+ }
}
/**
diff --git a/vlma-core/src/main/java/org/videolan/vlma/monitor/ServerStateMonitor.java b/vlma-core/src/main/java/org/videolan/vlma/monitor/ServerStateMonitor.java
index 18aebc7..ce6e164 100644
--- a/vlma-core/src/main/java/org/videolan/vlma/monitor/ServerStateMonitor.java
+++ b/vlma-core/src/main/java/org/videolan/vlma/monitor/ServerStateMonitor.java
@@ -75,7 +75,9 @@ public class ServerStateMonitor implements Monitor {
for(Thread checkThread : checkThreads) {
try {
checkThread.join();
- } catch (InterruptedException e) { }
+ } catch (InterruptedException e) {
+ break;
+ }
}
}
};
@@ -103,10 +105,9 @@ public class ServerStateMonitor implements Monitor {
// Wait before looping
Thread.sleep(1000L * configuration.getLong("vlma.monitor.server.interval"));
} catch (InterruptedException e) {
- //Do nothing
+ continue;
}
- if (shouldRun.get())
- startCheckVLCThread();
+ startCheckVLCThread();
}
logger.debug("ServerStateMonitor thread stopped.");
}
@@ -152,6 +153,7 @@ public class ServerStateMonitor implements Monitor {
private Server server;
public CheckThread(VLMaService vlmaService, Server server) {
+ this.setDaemon(true);
this.vlmaService = vlmaService;
this.server = server;
}
More information about the vlma-devel
mailing list