[vlma-devel] commit: Fix calls to Notifier.sendNotification. (Adrien Grand )

git version control git at videolan.org
Fri Jul 25 22:21:27 CEST 2008


vlma | branch: master | Adrien Grand <jpountz at videolan.org> | Fri Jul 25 22:12:46 2008 +0200| [0007405d26e297fb4407771639736ee34be27a05]

Fix calls to Notifier.sendNotification.

Notifier.sendNotification was not called every time a server's state changed,
especially when this change was triggered by OrderGiver.

> http://git.videolan.org/gitweb.cgi/vlma.git/?a=commit;h=0007405d26e297fb4407771639736ee34be27a05
---

 .../java/org/videolan/vlma/OrderGiverImpl.java     |    5 ++++-
 .../java/org/videolan/vlma/VLMaServiceImpl.java    |    4 ++++
 .../org/videolan/vlma/monitor/ServerMonitor.java   |    5 +----
 3 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/vlma-core/src/main/java/org/videolan/vlma/OrderGiverImpl.java b/vlma-core/src/main/java/org/videolan/vlma/OrderGiverImpl.java
index 064cd3c..49b9669 100644
--- a/vlma-core/src/main/java/org/videolan/vlma/OrderGiverImpl.java
+++ b/vlma-core/src/main/java/org/videolan/vlma/OrderGiverImpl.java
@@ -272,7 +272,10 @@ public class OrderGiverImpl implements OrderGiver {
                         try {
                             orderSender.start(o);
                         } catch (IOException e) {
-                            a.getServer().setUp(false);
+                            /* There was a problem while sending the order to the server
+                             * so let's check its state.
+                             */
+                            vlmaService.checkVLC(a.getServer());
                         }
                         orders.get(c).add(o);
                     }
diff --git a/vlma-core/src/main/java/org/videolan/vlma/VLMaServiceImpl.java b/vlma-core/src/main/java/org/videolan/vlma/VLMaServiceImpl.java
index ab527bc..4ee413b 100644
--- a/vlma-core/src/main/java/org/videolan/vlma/VLMaServiceImpl.java
+++ b/vlma-core/src/main/java/org/videolan/vlma/VLMaServiceImpl.java
@@ -908,6 +908,7 @@ public class VLMaServiceImpl implements VLMaService {
     }
 
     public boolean checkVLC(Server server) {
+        boolean formerState = server.isUp();
         try {
             Socket socket = new Socket(server.getIp(), configuration.getInt("vlc.telnet.port"));
             socket.close();
@@ -917,6 +918,9 @@ public class VLMaServiceImpl implements VLMaService {
             logger.error("Unable to contact VLC server of " + server.getName() + " through telnet interface", e);
             server.setUp(false);
         }
+        boolean newState = server.isUp();
+        if (newState != formerState)
+            sendNotification(server.getName() + " is " + (newState ? "up" : "down"));
         return server.isUp();
     }
 
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 db4e2a7..d73a6b7 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
@@ -71,10 +71,7 @@ public class ServerMonitor implements Monitor {
     private Runnable vLCchecker = new Runnable() {
         public void run() {
             for (Server server : vlmaService.getServers()) {
-                boolean formerState = server.isUp();
-                boolean newState = vlmaService.checkVLC(server);
-                if (newState != formerState)
-                    vlmaService.sendNotification(server.getName() + " is " + (newState ? "up" : "down"));
+                vlmaService.checkVLC(server);
             }
         }
     };



More information about the vlma-devel mailing list