[vlma-devel] commit: Webapp: display VLC version and logs. (Adrien Grand )

git version control git at videolan.org
Sun Nov 2 22:41:27 CET 2008


vlma | branch: master | Adrien Grand <jpountz at videolan.org> | Sun Nov  2 18:53:06 2008 +0100| [7257fdcc75e92077d7b4ecdf5cb9cf28b1428afe] | committer: Adrien Grand 

Webapp: display VLC version and logs.

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

 vlma-api/src/main/java/org/videolan/vlma/Data.java |   23 +++++++++++++++++++
 .../src/main/java/org/videolan/vlma/DataImpl.java  |   24 ++++++++++++++++++++
 vlma-daemon/src/main/resources/daemon.xml          |    4 +++
 .../vlma/web/server/ServerViewController.java      |   19 +++++++++++++++
 vlma-webapp/src/main/resources/messages.properties |    1 +
 .../src/main/resources/messages_fr.properties      |    1 +
 .../webapp/WEB-INF/jsp/server/serverview_right.jsp |    7 +++++
 7 files changed, 79 insertions(+), 0 deletions(-)

diff --git a/vlma-api/src/main/java/org/videolan/vlma/Data.java b/vlma-api/src/main/java/org/videolan/vlma/Data.java
index b4fedc0..dda2401 100644
--- a/vlma-api/src/main/java/org/videolan/vlma/Data.java
+++ b/vlma-api/src/main/java/org/videolan/vlma/Data.java
@@ -335,4 +335,27 @@ public interface Data extends Remote {
      */
     void startCheckAllVLCs() throws RemoteException;
 
+    /**
+     * Retrieve logs from VLC.
+     *
+     * @param server
+     * @return VLC logs
+     */
+    String getVlcLogTail(Server server) throws RemoteException, IOException;
+
+    /**
+     * Get the version of the running VLC.
+     *
+     * @param server the server VLC runs on
+     * @return VLC version
+     */
+    String getVlcVersion(Server server) throws RemoteException, IOException;
+
+    /**
+     * Restart VLC on the provided server.
+     *
+     * @param server the server VLC runs on
+     */
+    void restartVlc(Server server) throws RemoteException, IOException;
+
 }
diff --git a/vlma-core/src/main/java/org/videolan/vlma/DataImpl.java b/vlma-core/src/main/java/org/videolan/vlma/DataImpl.java
index ebadb87..121d6a8 100644
--- a/vlma-core/src/main/java/org/videolan/vlma/DataImpl.java
+++ b/vlma-core/src/main/java/org/videolan/vlma/DataImpl.java
@@ -22,6 +22,7 @@ package org.videolan.vlma;
 
 import java.io.IOException;
 import java.net.URL;
+import java.rmi.RemoteException;
 import java.util.ArrayList;
 import java.util.HashSet;
 import java.util.List;
@@ -52,6 +53,7 @@ import org.videolan.vlma.model.Server;
 import org.videolan.vlma.model.StreamChannel;
 import org.videolan.vlma.model.StreamingStrategy;
 import org.videolan.vlma.order.CommandLogger;
+import org.videolan.vlma.retriever.DataRetriever;
 
 /**
  * Implementation of the Data interface.
@@ -69,6 +71,7 @@ public class DataImpl implements Data {
     private ProgramFactory programFactory;
     private VLMaDao vlmaDao;
     private VLMaService vlmaService;
+    private DataRetriever dataRetriever;
 
     /*************************************************************************
      *
@@ -399,6 +402,18 @@ public class DataImpl implements Data {
         vlmaService.startCheckAllVLCs();
     }
 
+    public String getVlcLogTail(Server server) throws RemoteException, IOException {
+        return dataRetriever.getVlcLogTail(server);
+    }
+
+    public String getVlcVersion(Server server) throws RemoteException, IOException {
+        return dataRetriever.getVlcVersion(server);
+    }
+
+    public void restartVlc(Server server) throws RemoteException, IOException {
+        dataRetriever.restartVlc(server);
+    }
+
     /*************************************************************************
      *
      * Setters
@@ -468,4 +483,13 @@ public class DataImpl implements Data {
         this.vlmaService = vlmaService;
     }
 
+    /**
+     * Sets the data retriever.
+     *
+     * @param dataRetriever the dataRetriever to set
+     */
+    public void setDataRetriever(DataRetriever dataRetriever) {
+        this.dataRetriever = dataRetriever;
+    }
+
 }
diff --git a/vlma-daemon/src/main/resources/daemon.xml b/vlma-daemon/src/main/resources/daemon.xml
index 1d6bb9e..54a960e 100644
--- a/vlma-daemon/src/main/resources/daemon.xml
+++ b/vlma-daemon/src/main/resources/daemon.xml
@@ -71,6 +71,7 @@
         <property name="commandLogger" ref="commandLogger" />
         <property name="configuration" ref="configuration" />
         <property name="daemon" ref="daemon" />
+        <property name="dataRetriever" ref="dataRetriever" />
         <property name="ipBank" ref="ipBank" />
         <property name="programFactory" ref="programFactory" />
         <property name="vlmaDao" ref="vlmaDao" />
@@ -105,6 +106,7 @@
         <property name="configuration" ref="configuration" />
         <property name="snmpDataRetriever" ref="snmpDataRetriever" />
         <property name="httpDataRetriever" ref="httpDataRetriever" />
+        <property name="dummyDataRetriever" ref="dummyDataRetriever" />
     </bean>
 
     <bean id="snmpDataRetriever" class="org.videolan.vlma.retriever.SnmpDataRetriever">
@@ -115,6 +117,8 @@
         <property name="configuration" ref="configuration" />
     </bean>
 
+    <bean id="dummyDataRetriever" class="org.videolan.vlma.retriever.DataRetrieverMockImpl" />
+
 	<bean id="ipBank" class="org.videolan.vlma.IpBank">
 	    <property name="configuration" ref="configuration" />
 	    <property name="vlmaService" ref="vlmaService" />
diff --git a/vlma-webapp/src/main/java/org/videolan/vlma/web/server/ServerViewController.java b/vlma-webapp/src/main/java/org/videolan/vlma/web/server/ServerViewController.java
index fc2b0b3..26bd4ed 100644
--- a/vlma-webapp/src/main/java/org/videolan/vlma/web/server/ServerViewController.java
+++ b/vlma-webapp/src/main/java/org/videolan/vlma/web/server/ServerViewController.java
@@ -20,9 +20,12 @@
 
 package org.videolan.vlma.web.server;
 
+import java.io.IOException;
+
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
+import org.apache.log4j.Logger;
 import org.springframework.web.servlet.ModelAndView;
 import org.springframework.web.servlet.mvc.Controller;
 import org.videolan.vlma.Data;
@@ -30,12 +33,28 @@ import org.videolan.vlma.model.Server;
 
 public class ServerViewController implements Controller {
 
+    private static final Logger logger = Logger.getLogger(ServerViewController.class);
+
     public ModelAndView handleRequest(HttpServletRequest arg0,
             HttpServletResponse arg1) throws Exception {
         Server server = data.getServer(Integer.parseInt(arg0
                 .getParameter("server")));
         ModelAndView mav = new ModelAndView();
         mav.addObject("server", server);
+        try {
+            String vlcVersion = data.getVlcVersion(server);
+            mav.addObject("vlcVersion", vlcVersion);
+        } catch(IOException e) {
+            mav.addObject("vlcVersion", null);
+            logger.error("Cannot retrieve VLC version", e);
+        }
+        try {
+            String logs = data.getVlcLogTail(server);
+            mav.addObject("vlcLogs", logs);
+        } catch(IOException e) {
+            mav.addObject("vlcLogs", null);
+            logger.error("Cannot retrieve VLC logs", e);
+        }
         return mav;
     }
 
diff --git a/vlma-webapp/src/main/resources/messages.properties b/vlma-webapp/src/main/resources/messages.properties
index 361277d..0b141d2 100644
--- a/vlma-webapp/src/main/resources/messages.properties
+++ b/vlma-webapp/src/main/resources/messages.properties
@@ -135,6 +135,7 @@ servers.view.monitoring.traffic = Outing network rate:
 servers.view.monitoring.traffic-alt = Outing network rate
 servers.view.monitoring.resources = Consumed resources:
 servers.view.monitoring.resources-alt = Consumed resources
+servers.view.vlc.logs = Last logs of VLC
 servers.removing = Suppression of the server {0}
 servers.remove.text = Do you really want to remove the server {0}?
 servers.remove.run = Remove!
diff --git a/vlma-webapp/src/main/resources/messages_fr.properties b/vlma-webapp/src/main/resources/messages_fr.properties
index 8dc066f..adf506a 100644
--- a/vlma-webapp/src/main/resources/messages_fr.properties
+++ b/vlma-webapp/src/main/resources/messages_fr.properties
@@ -132,6 +132,7 @@ servers.view.monitoring.traffic = Débit réseau sortant :
 servers.view.monitoring.traffic-alt = Débit réseau sortant
 servers.view.monitoring.resources = Ressources consommées :
 servers.view.monitoring.resources-alt = Ressources consommées
+servers.view.vlc.logs = Derniers logs de VLC
 servers.removing = Suppression du serveur {0}
 servers.remove.text = Voulez-vous vraiment supprimer le serveur {0} ?
 servers.remove.run = Supprimer !
diff --git a/vlma-webapp/src/main/webapp/WEB-INF/jsp/server/serverview_right.jsp b/vlma-webapp/src/main/webapp/WEB-INF/jsp/server/serverview_right.jsp
index 61d167d..0b2f601 100644
--- a/vlma-webapp/src/main/webapp/WEB-INF/jsp/server/serverview_right.jsp
+++ b/vlma-webapp/src/main/webapp/WEB-INF/jsp/server/serverview_right.jsp
@@ -8,6 +8,9 @@
 
 <ul>
     <li><fmt:message key="servers.view.name" /> <b><c:out value="${server.name}" /></b></li>
+    <c:if test="${vlcVersion != null}">
+        <li><b><c:out value="${vlcVersion}" /></b></li>
+    </c:if>
     <li><fmt:message key="servers.view.address" /> <b><c:out value="${server.ip}" /></b></li>
     <li><fmt:message key="servers.view.adapters" />
         <table>
@@ -45,4 +48,8 @@
     <li><fmt:message key="servers.view.monitoring.resources" /><br />
         <img alt="<fmt:message key="servers.view.monitoring.resources-alt" />" src="<c:url value="/" />rrdgraph?server=<c:out value="${server.name}" />&what=vlc" />
     </li>
+    <c:if test="${vlcLogs != null}">
+        <li><b><fmt:message key="servers.view.vlc.logs" /></b><br />
+        <c:out escapeXml="false" value="${vlcLogs}" /></li>
+    </c:if>
 </ul>



More information about the vlma-devel mailing list