[vlma-devel] commit: Restart VLC when the telnet interface does not respond anymore. ( Adrien Grand )

git version control git at videolan.org
Fri Feb 27 04:26:08 CET 2009


vlma | branch: master | Adrien Grand <jpountz at videolan.org> | Fri Feb 27 04:24:03 2009 +0100| [1de158b21c0489bb29e80a775ccab9920bbf5ac3] | committer: Adrien Grand 

Restart VLC when the telnet interface does not respond anymore.

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

 .../videolan/vlma/monitor/ServerStateMonitor.java  |   21 ++++++++++++++++++++
 vlma-daemon/src/main/resources/daemon.xml          |    1 +
 2 files changed, 22 insertions(+), 0 deletions(-)

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 9bd46db..a7af415 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
@@ -20,6 +20,7 @@
 
 package org.videolan.vlma.monitor;
 
+import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -29,6 +30,7 @@ import org.videolan.vlma.dao.VLMaDao;
 import org.videolan.vlma.model.Server;
 import org.videolan.vlma.notifier.Notifier;
 import org.videolan.vlma.server.VlcChecker;
+import org.videolan.vlma.server.rpc.DataRetriever;
 
 /**
  * This class is the daemon which monitores the servers' state. It periodically
@@ -47,6 +49,7 @@ public class ServerStateMonitor extends Monitor {
     private Thread serverStateMonitor;
     private Runnable serverStateMonitorRunnable;
     private VlcChecker vlcChecker;
+    private DataRetriever dataRetriever;
 
     private volatile boolean shouldRun;
 
@@ -138,6 +141,15 @@ public class ServerStateMonitor extends Monitor {
         this.vlcChecker = vlcChecker;
     }
 
+    /**
+     * Sets VLC remote controller.
+     *
+     * @param dataRetriever the dataRetriever to set
+     */
+    public void setDataRetriever(DataRetriever dataRetriever) {
+        this.dataRetriever = dataRetriever;
+    }
+
     private class CheckThread extends Thread {
 
         private Server server;
@@ -153,6 +165,15 @@ public class ServerStateMonitor extends Monitor {
                 boolean newState = vlcChecker.checkVLC(server);
                 if (newState != formerState) {
                     Monitor.dispatch(newState ? Monitor.ServerEvent.UP : Monitor.ServerEvent.DOWN, server);
+                } else if (!newState) {
+                    // VLC's telnet interface is down for the second consecutive time
+                    // Try to restart VLC
+                    try {
+                        dataRetriever.restartVlc(server);
+                    } catch (IOException e) {
+                        // Fail, maybe the server is down :'(
+                        logger.debug("Could not restart VLC", e);
+                    }
                 }
             }
         }
diff --git a/vlma-daemon/src/main/resources/daemon.xml b/vlma-daemon/src/main/resources/daemon.xml
index 4794423..f0f7a71 100644
--- a/vlma-daemon/src/main/resources/daemon.xml
+++ b/vlma-daemon/src/main/resources/daemon.xml
@@ -162,6 +162,7 @@
         <property name="configuration" ref="configuration" />
         <property name="vlmaDao" ref="vlmaDao" />
         <property name="vlcChecker" ref="vlcChecker" />
+        <property name="dataRetriever" ref="dataRetriever" />
     </bean>
 
     <bean id="streamWatcher" class="org.videolan.vlma.order.watcher.StreamWatcherDispatcher">



More information about the vlma-devel mailing list