qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rgodf...@apache.org
Subject svn commit: r1332693 - in /qpid/branches/java-config-and-management/qpid/java: broker-plugins/management/src/main/java/org/apache/qpid/server/management/plugin/ broker-plugins/management/src/main/java/org/apache/qpid/server/management/plugin/servlet/re...
Date Tue, 01 May 2012 15:13:54 GMT
Author: rgodfrey
Date: Tue May  1 15:13:53 2012
New Revision: 1332693

URL: http://svn.apache.org/viewvc?rev=1332693&view=rev
Log:
NO-JIRA : [Java Config] add initial log viewing support, broker page

Added:
    qpid/branches/java-config-and-management/qpid/java/broker-plugins/management/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/LogRecordsServlet.java
      - copied, changed from r1332355, qpid/branches/java-config-and-management/qpid/java/broker-plugins/management/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/StructureServlet.java
    qpid/branches/java-config-and-management/qpid/java/broker-plugins/management/src/main/java/resources/js/addBinding.js
    qpid/branches/java-config-and-management/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/LogRecorder.java
Removed:
    qpid/branches/java-config-and-management/qpid/java/broker-plugins/management/src/main/java/resources/.broker.html.swp
Modified:
    qpid/branches/java-config-and-management/qpid/java/broker-plugins/management/src/main/java/org/apache/qpid/server/management/plugin/Management.java
    qpid/branches/java-config-and-management/qpid/java/broker-plugins/management/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/RestServlet.java
    qpid/branches/java-config-and-management/qpid/java/broker-plugins/management/src/main/java/resources/broker.html
    qpid/branches/java-config-and-management/qpid/java/broker-plugins/management/src/main/java/resources/css/broker.css
    qpid/branches/java-config-and-management/qpid/java/broker-plugins/management/src/main/java/resources/js/broker.js
    qpid/branches/java-config-and-management/qpid/java/broker/src/main/java/org/apache/qpid/server/Broker.java
    qpid/branches/java-config-and-management/qpid/java/broker/src/main/java/org/apache/qpid/server/model/Broker.java
    qpid/branches/java-config-and-management/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/BrokerAdapter.java
    qpid/branches/java-config-and-management/qpid/java/broker/src/main/java/org/apache/qpid/server/registry/ApplicationRegistry.java

Modified: qpid/branches/java-config-and-management/qpid/java/broker-plugins/management/src/main/java/org/apache/qpid/server/management/plugin/Management.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-config-and-management/qpid/java/broker-plugins/management/src/main/java/org/apache/qpid/server/management/plugin/Management.java?rev=1332693&r1=1332692&r2=1332693&view=diff
==============================================================================
--- qpid/branches/java-config-and-management/qpid/java/broker-plugins/management/src/main/java/org/apache/qpid/server/management/plugin/Management.java (original)
+++ qpid/branches/java-config-and-management/qpid/java/broker-plugins/management/src/main/java/org/apache/qpid/server/management/plugin/Management.java Tue May  1 15:13:53 2012
@@ -27,6 +27,7 @@ import org.apache.qpid.server.management
 import org.apache.qpid.server.management.plugin.servlet.FileServlet;
 import org.apache.qpid.server.management.plugin.servlet.api.ExchangesServlet;
 import org.apache.qpid.server.management.plugin.servlet.api.VhostsServlet;
+import org.apache.qpid.server.management.plugin.servlet.rest.LogRecordsServlet;
 import org.apache.qpid.server.management.plugin.servlet.rest.RestServlet;
 import org.apache.qpid.server.management.plugin.servlet.rest.SaslServlet;
 import org.apache.qpid.server.management.plugin.servlet.rest.StructureServlet;
@@ -55,7 +56,7 @@ public class Management
     private Broker _broker;
 
     private Collection<Server> _servers = new ArrayList<Server>();
-    
+
 
     public Management()
     {
@@ -76,7 +77,7 @@ public class Management
             }
         }
 
-        
+
     }
 
     private Server createServer(int port)
@@ -87,6 +88,7 @@ public class Management
         root.addServlet(new ServletHolder(new VhostsServlet(_broker)), "/api/vhosts/*");
         root.addServlet(new ServletHolder(new ExchangesServlet(_broker)), "/api/exchanges/*");
 
+        addRestServlet(root, "broker");
         addRestServlet(root, "virtualhost", VirtualHost.class);
         addRestServlet(root, "exchange", VirtualHost.class, Exchange.class);
         addRestServlet(root, "queue", VirtualHost.class, Queue.class);
@@ -97,6 +99,9 @@ public class Management
 
         root.addServlet(new ServletHolder(new StructureServlet(_broker)), "/rest/structure");
 
+        root.addServlet(new ServletHolder(new LogRecordsServlet(_broker)), "/rest/logrecords");
+
+
         root.addServlet(new ServletHolder(new SaslServlet(_broker)), "/rest/sasl");
 
         root.addServlet(new ServletHolder(new DefinedFileServlet("queue.html")),"/queue");
@@ -121,7 +126,7 @@ public class Management
 
         sessionManager.setMaxCookieAge(60 * 30);
         sessionManager.setMaxInactiveInterval(60 * 15);
-        
+
         return server;
     }
 

Copied: qpid/branches/java-config-and-management/qpid/java/broker-plugins/management/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/LogRecordsServlet.java (from r1332355, qpid/branches/java-config-and-management/qpid/java/broker-plugins/management/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/StructureServlet.java)
URL: http://svn.apache.org/viewvc/qpid/branches/java-config-and-management/qpid/java/broker-plugins/management/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/LogRecordsServlet.java?p2=qpid/branches/java-config-and-management/qpid/java/broker-plugins/management/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/LogRecordsServlet.java&p1=qpid/branches/java-config-and-management/qpid/java/broker-plugins/management/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/StructureServlet.java&r1=1332355&r2=1332693&rev=1332693&view=diff
==============================================================================
--- qpid/branches/java-config-and-management/qpid/java/broker-plugins/management/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/StructureServlet.java (original)
+++ qpid/branches/java-config-and-management/qpid/java/broker-plugins/management/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/LogRecordsServlet.java Tue May  1 15:13:53 2012
@@ -1,13 +1,13 @@
-/**
+/*
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements.  See the NOTICE file distributed with
  * this work for additional information regarding copyright ownership.
  * The ASF licenses this file to You under the Apache License, Version 2.0
  * (the "License"); you may not use this file except in compliance with
  * the License.  You may obtain a copy of the License at
- * <p/>
+ *
  * http://www.apache.org/licenses/LICENSE-2.0
- * <p/>
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -18,19 +18,22 @@ package org.apache.qpid.server.managemen
 
 import java.io.IOException;
 import java.io.PrintWriter;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
 import javax.servlet.ServletException;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
+import org.apache.qpid.server.logging.LogRecorder;
 import org.apache.qpid.server.model.Broker;
-import org.apache.qpid.server.model.ConfiguredObject;
-import org.apache.qpid.server.model.Model;
+import org.apache.qpid.server.registry.ApplicationRegistry;
 import org.codehaus.jackson.map.ObjectMapper;
 import org.codehaus.jackson.map.SerializationConfig;
 
-public class StructureServlet extends AbstractServlet
+public class LogRecordsServlet extends AbstractServlet
 {
-    public StructureServlet(Broker broker)
+    public LogRecordsServlet(Broker broker)
     {
         super(broker);
     }
@@ -45,42 +48,33 @@ public class StructureServlet extends Ab
         response.setHeader("Pragma","no-cache");
         response.setDateHeader ("Expires", 0);
 
-        Map<String,Object> structure = generateStructure(getBroker(), Broker.class);
+        ApplicationRegistry applicationRegistry = (ApplicationRegistry) ApplicationRegistry.getInstance();
+        List<Map<String,Object>> logRecords = new ArrayList<Map<String, Object>>();
+
+        for(LogRecorder.Record record : applicationRegistry.getLogRecorder())
+        {
+            logRecords.add(logRecordToObject(record));
+        }
 
         final PrintWriter writer = response.getWriter();
         ObjectMapper mapper = new ObjectMapper();
         mapper.configure(SerializationConfig.Feature.INDENT_OUTPUT, true);
-        mapper.writeValue(writer, structure);
+        mapper.writeValue(writer, logRecords);
 
         response.setStatus(HttpServletResponse.SC_OK);
 
     }
 
-    private Map<String, Object> generateStructure(ConfiguredObject object, Class<? extends ConfiguredObject> clazz)
+    private Map<String, Object> logRecordToObject(LogRecorder.Record record)
     {
-        Map<String, Object> structure = new LinkedHashMap<String, Object>();
-        structure.put("id", object.getId());
-        structure.put("name", object.getName());
-
-        for(Class<? extends ConfiguredObject> childClass : Model.getChildTypes(clazz))
-        {
-            Collection<? extends ConfiguredObject> children = object.getChildren(childClass);
-            if(children != null)
-            {
-                List<Map<String, Object>> childObjects = new ArrayList<Map<String, Object>>();
-
-                for(ConfiguredObject child : children)
-                {
-                    childObjects.add(generateStructure(child, childClass));
-                }
-
-                if(!childObjects.isEmpty())
-                {
-                    structure.put(childClass.getSimpleName().toLowerCase()+"s",childObjects);
-                }
-            }
-        }
-
-        return structure;
+        Map<String, Object> recordMap = new LinkedHashMap<String, Object>();
+        recordMap.put("id",record.getId());
+        recordMap.put("timestamp", record.getTimestamp());
+        recordMap.put("level", record.getLevel());
+        recordMap.put("thread", record.getThreadName());
+        recordMap.put("logger", record.getLogger());
+        recordMap.put("message", record.getMessage());
+        return recordMap;
     }
+
 }

Modified: qpid/branches/java-config-and-management/qpid/java/broker-plugins/management/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/RestServlet.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-config-and-management/qpid/java/broker-plugins/management/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/RestServlet.java?rev=1332693&r1=1332692&r2=1332693&view=diff
==============================================================================
--- qpid/branches/java-config-and-management/qpid/java/broker-plugins/management/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/RestServlet.java (original)
+++ qpid/branches/java-config-and-management/qpid/java/broker-plugins/management/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/RestServlet.java Tue May  1 15:13:53 2012
@@ -123,7 +123,7 @@ public class RestServlet extends Abstrac
                 for(Map.Entry<Class<? extends ConfiguredObject>, String> entry : filters.entrySet())
                 {
                     Collection<? extends ConfiguredObject> ancestors =
-                            getAncestors(_hierarchy[_hierarchy.length-1],entry.getKey(), o);
+                            getAncestors(getConfiguredClass(),entry.getKey(), o);
                     match = false;
                     for(ConfiguredObject ancestor : ancestors)
                     {
@@ -277,7 +277,7 @@ public class RestServlet extends Abstrac
 
         for(ConfiguredObject configuredObject : allObjects)
         {
-            output.add(convertObjectToMap(configuredObject, _hierarchy[_hierarchy.length-1],depth));
+            output.add(convertObjectToMap(configuredObject, getConfiguredClass(),depth));
         }
 
         final PrintWriter writer = response.getWriter();
@@ -290,6 +290,11 @@ public class RestServlet extends Abstrac
 
     }
 
+    private Class<? extends ConfiguredObject> getConfiguredClass()
+    {
+        return _hierarchy.length == 0 ? Broker.class : _hierarchy[_hierarchy.length-1];
+    }
+
     @Override
     protected void onPut(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
     {
@@ -361,7 +366,7 @@ public class RestServlet extends Abstrac
 
             }
             List<ConfiguredObject> parents = new ArrayList<ConfiguredObject>();
-            Class<? extends ConfiguredObject> objClass = _hierarchy[_hierarchy.length - 1];
+            Class<? extends ConfiguredObject> objClass = getConfiguredClass();
             Collection<Class<? extends ConfiguredObject>> parentClasses = Model.getParentTypes(objClass);
             for(int i = _hierarchy.length-2; i >=0 ; i--)
             {

Modified: qpid/branches/java-config-and-management/qpid/java/broker-plugins/management/src/main/java/resources/broker.html
URL: http://svn.apache.org/viewvc/qpid/branches/java-config-and-management/qpid/java/broker-plugins/management/src/main/java/resources/broker.html?rev=1332693&r1=1332692&r2=1332693&view=diff
==============================================================================
--- qpid/branches/java-config-and-management/qpid/java/broker-plugins/management/src/main/java/resources/broker.html (original)
+++ qpid/branches/java-config-and-management/qpid/java/broker-plugins/management/src/main/java/resources/broker.html Tue May  1 15:13:53 2012
@@ -19,7 +19,6 @@
  - under the License.
  -
  -->
-
 <html lang="en">
 	<head>
 		<meta charset="utf-8">
@@ -31,12 +30,12 @@
         <link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/dojo/1.7.1/dijit/themes/claro/claro.css">
         <link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/dojo/1.7.1/dojox/grid/resources/claroGrid.css">
 
-
         <link rel="stylesheet" href="../css/broker.css" media="screen">
 
-		<link rel="stylesheet" href="../css/common.css" media="screen">
+		<link rel="stylesheet" href="css/common.css" media="screen">
 
-        <!-- load dojo and provide config via data attribute -->
+        <!-- load dojo and provide config via data attribute
+         style="height: 800px"-->
 		<!--<script src="/dojo/1.7.2/dojo/dojo.js.uncompressed.js" data-dojo-config="async: true, parseOnLoad: true">
         </script>                                                                                 -->
 
@@ -44,21 +43,70 @@
                 data-dojo-config="async: true, parseOnLoad: true">
         </script>
 
-        <script src="/js/broker.js">
+            <script>
+                require(["dijit/layout/BorderContainer", "dijit/layout/TabContainer", "dijit/layout/ContentPane",
+                "dijit/TitlePane", "dojo/parser"]);
+
+
             </script>
+
+        <script src="/js/common.js">
+        </script>
+        <script src="/js/broker.js">
+        </script>
+        <script src="/js/sasl.js">
+        </script>
+        <script src="/js/header.js"></script>
+        <script src="/js/footer.js"></script>
+        <script src="/js/structure.js"></script>
+
+        <script>
+
+            require(["dojo/domReady!"],
+                    function(){
+                      new Header("Broker");
+                });
+        </script>
+
 	</head>
 	<body class="claro">
-		<h1>Broker</h1>
 
-		<br/>
-        <h2>Virtual Hosts</h2>
-		<div id="virtualHosts"></div>
-        <h2>Connections</h2>
-        <div id="connections"></div>
-        <h2>Exchanges</h2>
-        <div id="exchanges"></div>
-        <h2>Queues</h2>
-        <div id="queues"></div>
-	</body>
-</html>
 
+    <div id="pageLayout" data-dojo-type="dijit.layout.BorderContainer" data-dojo-props="design: 'headline', gutters: false">
+        <div data-dojo-type="dijit.layout.ContentPane" data-dojo-props="region:'top'"><div id="header" class="header"></div>
+        </div>
+        <div data-dojo-type="dijit.layout.ContentPane" data-dojo-props="region:'top'">
+            <div id="login"></div>
+        </div>
+        <div data-dojo-type="dijit.layout.ContentPane" data-dojo-props="region:'leading', splitter: true">
+                    <div id="structure"></div>
+        </div>
+        <div data-dojo-type="dijit.layout.ContentPane" data-dojo-props="region:'center'">
+            <span style="">Queue:</span><span id="name" style="position:absolute; left:6em"></span>
+            <br/>
+            <span style="">State:</span><span id="state" style="position:absolute; left:6em"></span>
+            <br/>
+            <span style="">Durable:</span><span id="durable" style="position:absolute; left:6em"></span>
+            <br/>
+            <span style="">Lifespan:</span><span style="position:absolute; left:6em" id="lifetimePolicy"></span>
+            <br/>
+            <br/>
+            <div data-dojo-type="dijit.TitlePane" data-dojo-props="title: 'Virtual Hosts'">
+                <div id="virtualhosts"></div>
+            </div>
+            <br/>
+            <div data-dojo-type="dijit.TitlePane" data-dojo-props="title: 'Ports'">
+                <div id="ports"></div>
+            </div>
+            <br/>
+
+            <div data-dojo-type="dijit.TitlePane" data-dojo-props="title: 'Log File'">
+                <div id="logfile"></div>
+            </div>
+            <br/>
+        </div>
+        <div data-dojo-type="dijit.layout.ContentPane" data-dojo-props="region:'bottom'"><div id="footer"></div></div>
+    </div>
+
+	</body>
+</html>
\ No newline at end of file

Modified: qpid/branches/java-config-and-management/qpid/java/broker-plugins/management/src/main/java/resources/css/broker.css
URL: http://svn.apache.org/viewvc/qpid/branches/java-config-and-management/qpid/java/broker-plugins/management/src/main/java/resources/css/broker.css?rev=1332693&r1=1332692&r2=1332693&view=diff
==============================================================================
--- qpid/branches/java-config-and-management/qpid/java/broker-plugins/management/src/main/java/resources/css/broker.css (original)
+++ qpid/branches/java-config-and-management/qpid/java/broker-plugins/management/src/main/java/resources/css/broker.css Tue May  1 15:13:53 2012
@@ -18,19 +18,19 @@
  * under the License.
  *
  */
-#virtualHosts {
-	width: 560px;
-	height: 110px;
+
+#virtualhosts {
+	width: 100%;
+	height: 100px;
 }
-#exchanges {
-	width: 560px;
-	height: 250px;
+
+#ports {
+	width: 100%;
+	height: 100px;
 }
-#queues {
-	width: 560px;
-	height: 200px;
-}
-#connections {
-	width: 560px;
-	height: 200px;
+
+#logfile {
+	width: 100%;
+	height: 100px;
 }
+

Added: qpid/branches/java-config-and-management/qpid/java/broker-plugins/management/src/main/java/resources/js/addBinding.js
URL: http://svn.apache.org/viewvc/qpid/branches/java-config-and-management/qpid/java/broker-plugins/management/src/main/java/resources/js/addBinding.js?rev=1332693&view=auto
==============================================================================
--- qpid/branches/java-config-and-management/qpid/java/broker-plugins/management/src/main/java/resources/js/addBinding.js (added)
+++ qpid/branches/java-config-and-management/qpid/java/broker-plugins/management/src/main/java/resources/js/addBinding.js Tue May  1 15:13:53 2012
@@ -0,0 +1,18 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+

Modified: qpid/branches/java-config-and-management/qpid/java/broker-plugins/management/src/main/java/resources/js/broker.js
URL: http://svn.apache.org/viewvc/qpid/branches/java-config-and-management/qpid/java/broker-plugins/management/src/main/java/resources/js/broker.js?rev=1332693&r1=1332692&r2=1332693&view=diff
==============================================================================
--- qpid/branches/java-config-and-management/qpid/java/broker-plugins/management/src/main/java/resources/js/broker.js (original)
+++ qpid/branches/java-config-and-management/qpid/java/broker-plugins/management/src/main/java/resources/js/broker.js Tue May  1 15:13:53 2012
@@ -18,156 +18,125 @@
  * under the License.
  *
  */
-var vhostGrid, dataStore, store, vhostStore;
-var exchangeGrid, exchangeStore, exchangeDataStore;
-var updateList = new Array();
-var vhostTuple, exchangesTuple;
-
-
 require(["dojo/store/JsonRest",
-				"dojo/store/Memory",
-				"dojo/store/Cache",
-				"dojox/grid/DataGrid",
-				"dojo/data/ObjectStore",
-				"dojo/query",
-				"dojo/store/Observable",
-                "dojo/_base/xhr",
-				"dojo/domReady!"],
-	     function(JsonRest, Memory, Cache, DataGrid, ObjectStore, query, Observable, xhr)
+         "dojo/json",
+         "dojo/store/Memory",
+         "dojo/store/Cache",
+         "dojox/grid/DataGrid",
+         "dojo/data/ObjectStore",
+         "dojo/query",
+         "dojo/store/Observable",
+         "dojo/_base/xhr",
+         "dojo/dom",
+         "dojo/domReady!"],
+	     function(JsonRest, json, Memory, Cache, DataGrid, ObjectStore, query, Observable, xhr, dom)
 	     {
 
+         function BrokerUpdater()
+         {
+            this.name = dom.byId("name");
+            this.state = dom.byId("state");
+            this.durable = dom.byId("durable");
+            this.lifetimePolicy = dom.byId("lifetimePolicy");
+
+            this.query = "/rest/broker";
+
+            var thisObj = this;
+
+            xhr.get({url: this.query, sync: useSyncGet, handleAs: "json"})
+                .then(function(data)
+                      {
+                        thisObj.brokerData = data[0];
+
+                        flattenStatistics( thisObj.brokerData );
+
+                        thisObj.updateHeader();
+                        thisObj.vhostsGrid =
+                            new UpdatableStore(Observable, Memory, ObjectStore, DataGrid,
+                                               thisObj.brokerData.vhosts, "virtualhosts",
+                                                         [ { name: "Virtual Host",    field: "name",      width: "100%"}
+                                                         ]);
+
+                        thisObj.portsGrid =
+                            new UpdatableStore(Observable, Memory, ObjectStore, DataGrid,
+                                               thisObj.brokerData.ports, "ports",
+                                                         [ { name: "Address",    field: "bindingAddress",      width: "70px"},
+                                                           { name: "Port", field: "port", width: "70px"},
+                                                           { name: "Transports", field: "transports", width: "150px"},
+                                                           { name: "Protocols", field: "protocols", width: "100%"}
+                                                         ]);
 
-         function UpdatableStore( query, divName, structure, func ) {
 
 
-             this.query = query;
+                             });
 
-             var thisObj = this;
+             xhr.get({url: "/rest/logrecords", sync: useSyncGet, handleAs: "json"})
+                 .then(function(data)
+                       {
+                            this.logData = data;
+
+                            thisObj.logfileGrid =
+                                         new UpdatableStore(Observable, Memory, ObjectStore, DataGrid,
+                                                            thisObj.logData, "logfile",
+                                                                     [   { name: "ID", field: "id", width: "30px"},
+                                                                         { name: "Level", field: "level", width: "60px"},
+                                                                         { name: "Logger", field: "logger", width: "100px"},
+                                                                         { name: "Thread", field: "thread", width: "60px"},
+                                                                         { name: "Log Message", field: "message", width: "100%"}
 
-             xhr.get({url: query, handleAs: "json"}).then(function(data)
-                             {
-                             thisObj.store = Observable(Memory({data: data, idProperty: "id"}));
-                             thisObj.dataStore = ObjectStore({objectStore: thisObj.store});
-                             thisObj.grid = new DataGrid({
-                                         store: thisObj.dataStore,
-                                         structure: structure,
-             					                }, divName);
-
-                             // since we created this grid programmatically, call startup to render it
-                             thisObj.grid.startup();
-
-                             updateList.push( thisObj );
-                             if( func )
-                             {
-                                 func(thisObj);
-                             }
-                             });
+                                                                     ]);
+                       });
+         }
 
+         BrokerUpdater.prototype.updateHeader = function()
+         {
+            this.name.innerHTML = this.brokerData[ "name" ];
+            this.state.innerHTML = this.brokerData[ "state" ];
+            this.durable.innerHTML = this.brokerData[ "durable" ];
+            this.lifetimePolicy.innerHTML = this.brokerData[ "lifetimePolicy" ];
 
          }
 
-         UpdatableStore.prototype.update = function() {
-             var store = this.store;
+         BrokerUpdater.prototype.update = function()
+         {
 
+            var thisObj = this;
 
-             xhr.get({url: this.query, handleAs: "json"}).then(function(data)
+            xhr.get({url: this.query, sync: useSyncGet, handleAs: "json"}).then(function(data)
                  {
-                     // handle deletes
-                     // iterate over existing store... if not in new data then remove
-                     store.query({ }).forEach(function(object)
-                         {
-                             for(var i=0; i < data.length; i++)
-                             {
-                                 if(data[i].id == object.id)
-                                 {
-                                     return;
-                                 }
-                             }
-                             store.remove(object.id);
-                             //store.notify(null, object.id);
-                         });
-
-                     // iterate over data...
-                     for(var i=0; i < data.length; i++)
-                     {
-                         if(item = store.get(data[i].id))
-                         {
-                             var modified;
-                             for(var propName in data[i])
-                             {
-                                 if(item[ propName ] != data[i][ propName ])
-                                 {
-                                     item[ propName ] = data[i][ propName ];
-                                     modified = true;
-                                 }
-                             }
-                             if(modified)
-                             {
-                                 // ... check attributes for updates
-                                 store.notify(item, data[i].id);
-                             }
-                         }
-                         else
-                         {
-                             // ,,, if not in the store then add
-                             store.put(data[i]);
-                             //store.notify(data[i], null);
-                         }
-                     }
+                    thisObj.brokerData = data[0];
+                    flattenStatistics( thisObj.brokerData )
+
+                    var virtualhosts = thisObj.brokerData[ "virtualhosts" ];
+                    var ports = thisObj.brokerData[ "ports" ];
+
+
+                    thisObj.updateHeader();
+
+
+                    // update alerting info
+                    var sampleTime = new Date();
+
+                    thisObj.vhostsGrid.update(thisObj.brokerData.virtualhosts);
+
+                    thisObj.portsGrid.update(thisObj.brokerData.ports);
+
+
                  });
+
+
+             xhr.get({url: "/rest/logrecords", sync: useSyncGet, handleAs: "json"})
+                 .then(function(data)
+                       {
+                           this.logData = data;
+                           thisObj.logfileGrid.update(this.logData);
+                       });
          };
 
-         exchangeTuple = new UpdatableStore("/rest/exchange", "exchanges",
-                                                     [ { name: "Name",        field: "name",          width: "190px"},
-                                                       { name: "Type",        field: "type",          width: "90px"},
-                                                       { name: "Durable",     field: "durable",       width: "80px"},
-                                                       { name: "Auto-Delete", field: "auto-delete",   width: "100px"},
-                                                       { name: "Bindings",    field: "binding-count", width: "80px"}
-                                                       ]);
-         queueTuple = new UpdatableStore("/rest/queue", "queues",
-                                            [ { name: "Name",        field: "name",          width: "240px"},
-                                              { name: "Durable",     field: "durable",       width: "100px"},
-                                              { name: "Auto-Delete", field: "auto-delete",   width: "100px"},
-                                              { name: "Bindings",    field: "binding-count", width: "100px"} ]);
-         connectionTuple = new UpdatableStore("/rest/connection", "connections",
-                                                     [ { name: "Name",        field: "name",          width: "160px"},
-                                                       { name: "Sessions",    field: "session-count", width: "80px"},
-                                                       { name: "Msgs In",     field: "msgs-in-total", width: "80px"},
-                                                       { name: "Msgs Out",    field: "msgs-out-total",width: "80px"},
-                                                       { name: "Bytes In",    field: "bytes-in-total", width: "80px"},
-                                                       { name: "Bytes Out",   field: "bytes-out-total",width: "80px"}]);
-
-         vhostTuple = new UpdatableStore("/rest/virtualhost", "virtualHosts",
-                                                 [ { name: "Name",        field: "name",             width: "180px"},
-                                                   { name: "Connections", field: "connection-count", width: "90px"},
-                                                   { name: "Queues",      field: "queue-count",      width: "90px"},
-                                                   { name: "Exchanges",   field: "exchange-count",   width: "90px"},
-                                                   { name: "Msgs In",     field: "msgs-in-total", width: "80px"},
-                                                   { name: "Msgs Out",    field: "msgs-out-total",width: "80px"},
-                                                   { name: "Bytes In",    field: "bytes-in-total", width: "80px"},
-                                                   { name: "Bytes Out",   field: "bytes-out-total",width: "80px"} ],
-                                        function(obj)
-                                        {
-                                            dojo.connect(obj.grid, "onRowClick", obj.grid, function(evt){
-                                                        					var idx = evt.rowIndex,
-                                                        				    item = this.getItem(idx);
-
-                                                                            exchangeTuple.query = "/rest/exchange/"+obj.dataStore.getValue(item, "name")+"/";
-                                                                            exchangeTuple.update();
-                                                                            queueTuple.query =  "/rest/queue/"+obj.dataStore.getValue(item, "name")+"/";
-                                                                            queueTuple.update();
-                                                                            connectionTuple.query = "/rest/connection/"+obj.dataStore.getValue(item, "name")+"/";
-                                                                            connectionTuple.update();
-
-                                                        				});
-                                        });
-
-
-                setInterval(function(){
-                   for(var i = 0; i < updateList.length; i++)
-                   {
-                       var obj = updateList[i];
-                       obj.update();
-                   }}, 5000); // every second
-		 });
+         brokerUpdater = new BrokerUpdater();
+
+         updateList.push( brokerUpdater );
+
+         brokerUpdater.update();
 
+     });

Modified: qpid/branches/java-config-and-management/qpid/java/broker/src/main/java/org/apache/qpid/server/Broker.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-config-and-management/qpid/java/broker/src/main/java/org/apache/qpid/server/Broker.java?rev=1332693&r1=1332692&r2=1332693&view=diff
==============================================================================
--- qpid/branches/java-config-and-management/qpid/java/broker/src/main/java/org/apache/qpid/server/Broker.java (original)
+++ qpid/branches/java-config-and-management/qpid/java/broker/src/main/java/org/apache/qpid/server/Broker.java Tue May  1 15:13:53 2012
@@ -20,21 +20,13 @@
  */
 package org.apache.qpid.server;
 
-import static org.apache.qpid.transport.ConnectionSettings.WILDCARD_ADDRESS;
-
 import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
 import java.net.InetAddress;
 import java.net.InetSocketAddress;
-import java.util.EnumSet;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Properties;
-import java.util.Set;
-
+import java.util.*;
 import javax.net.ssl.SSLContext;
-
 import org.apache.log4j.Logger;
 import org.apache.log4j.PropertyConfigurator;
 import org.apache.log4j.xml.QpidLog4JConfigurator;
@@ -56,6 +48,8 @@ import org.apache.qpid.transport.Network
 import org.apache.qpid.transport.network.IncomingNetworkTransport;
 import org.apache.qpid.transport.network.Transport;
 
+import static org.apache.qpid.transport.ConnectionSettings.WILDCARD_ADDRESS;
+
 public class Broker
 {
     private static final Logger LOGGER = Logger.getLogger(Broker.class);

Added: qpid/branches/java-config-and-management/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/LogRecorder.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-config-and-management/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/LogRecorder.java?rev=1332693&view=auto
==============================================================================
--- qpid/branches/java-config-and-management/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/LogRecorder.java (added)
+++ qpid/branches/java-config-and-management/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/LogRecorder.java Tue May  1 15:13:53 2012
@@ -0,0 +1,210 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.qpid.server.logging;
+
+import java.util.Iterator;
+import org.apache.log4j.Appender;
+import org.apache.log4j.Layout;
+import org.apache.log4j.Logger;
+import org.apache.log4j.spi.ErrorHandler;
+import org.apache.log4j.spi.Filter;
+import org.apache.log4j.spi.LoggingEvent;
+
+public class LogRecorder implements Appender, Iterable<LogRecorder.Record>
+{
+    private ErrorHandler _errorHandler;
+    private Filter _filter;
+    private String _name;
+    private long _recordId;
+
+    private final int _bufferSize = 4096;
+    private final int _mask = _bufferSize - 1;
+    private Record[] _records = new Record[_bufferSize];
+
+
+    public static class Record
+    {
+        private final long _id;
+        private final String _logger;
+        private final long _timestamp;
+        private final String _threadName;
+        private final String _level;
+        private final String _message;
+
+
+        public Record(long id, LoggingEvent event)
+        {
+            _id = id;
+            _logger = event.getLoggerName();
+            _timestamp = event.timeStamp;
+            _threadName = event.getThreadName();
+            _level = event.getLevel().toString();
+            _message = event.getRenderedMessage();
+        }
+
+        public long getId()
+        {
+            return _id;
+        }
+
+        public long getTimestamp()
+        {
+            return _timestamp;
+        }
+
+        public String getThreadName()
+        {
+            return _threadName;
+        }
+
+        public String getLevel()
+        {
+            return _level;
+        }
+
+        public String getMessage()
+        {
+            return _message;
+        }
+
+        public String getLogger()
+        {
+            return _logger;
+        }
+    }
+
+    public LogRecorder()
+    {
+
+        Logger.getRootLogger().addAppender(this);
+    }
+
+    @Override
+    public void addFilter(Filter filter)
+    {
+        _filter = filter;
+    }
+
+    @Override
+    public void clearFilters()
+    {
+        _filter = null;
+    }
+
+    @Override
+    public void close()
+    {
+        //TODO - Implement
+    }
+
+    @Override
+    public synchronized void doAppend(LoggingEvent loggingEvent)
+    {
+        _records[((int) (_recordId & _mask))] = new Record(_recordId, loggingEvent);
+        _recordId++;
+    }
+
+    @Override
+    public ErrorHandler getErrorHandler()
+    {
+        return _errorHandler;
+    }
+
+    @Override
+    public Filter getFilter()
+    {
+        return _filter;
+    }
+
+    @Override
+    public Layout getLayout()
+    {
+        return null;
+    }
+
+    @Override
+    public String getName()
+    {
+        return _name;
+    }
+
+    @Override
+    public boolean requiresLayout()
+    {
+        return false;
+    }
+
+    @Override
+    public void setErrorHandler(ErrorHandler errorHandler)
+    {
+        _errorHandler = errorHandler;
+    }
+
+    @Override
+    public void setLayout(Layout layout)
+    {
+
+    }
+
+    @Override
+    public void setName(String name)
+    {
+        _name = name;
+    }
+
+    @Override
+    public Iterator<Record> iterator()
+    {
+        return new RecordIterator(Math.max(_recordId-_bufferSize, 0l));
+    }
+
+    private class RecordIterator implements Iterator<Record>
+    {
+        private long _id;
+
+        public RecordIterator(long currentRecordId)
+        {
+            _id = currentRecordId;
+        }
+
+        @Override
+        public boolean hasNext()
+        {
+            return _id < _recordId;
+        }
+
+        @Override
+        public Record next()
+        {
+            Record record = _records[((int) (_id & _mask))];
+            while(_id < _recordId-_bufferSize)
+            {
+                _id = _recordId-_bufferSize;
+                record = _records[((int) (_id & _mask))];
+            }
+            _id++;
+            return record;
+        }
+
+        @Override
+        public void remove()
+        {
+            throw new UnsupportedOperationException();
+        }
+    }
+}

Modified: qpid/branches/java-config-and-management/qpid/java/broker/src/main/java/org/apache/qpid/server/model/Broker.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-config-and-management/qpid/java/broker/src/main/java/org/apache/qpid/server/model/Broker.java?rev=1332693&r1=1332692&r2=1332693&view=diff
==============================================================================
--- qpid/branches/java-config-and-management/qpid/java/broker/src/main/java/org/apache/qpid/server/model/Broker.java (original)
+++ qpid/branches/java-config-and-management/qpid/java/broker/src/main/java/org/apache/qpid/server/model/Broker.java Tue May  1 15:13:53 2012
@@ -21,13 +21,53 @@
 package org.apache.qpid.server.model;
 
 import java.security.AccessControlException;
+import java.util.Arrays;
 import java.util.Collection;
+import java.util.Collections;
 import java.util.Map;
 
 public interface Broker extends ConfiguredObject
 {
+
+    String BUILD_VERSION = "buildVersion";
+    String BYTES_RETAINED = "bytesRetained";
+    String OPERATING_SYSTEM = "operatingSystem";
+    String PLATFORM = "platform";
+    String PROCESS_PID = "processPid";
+    String PRODUCT_VERSION = "productVersion";
+    String STATISTICS_ENABLED = "statisticsEnabled";
+    String SUPPORTED_STORE_TYPES = "supportedStoreTypes";
+    String CREATED = "created";
+    String DURABLE = "durable";
+    String ID = "id";
+    String LIFETIME_POLICY = "lifetimePolicy";
+    String NAME = "name";
+    String STATE = "state";
+    String TIME_TO_LIVE = "timeToLive";
+    String UPDATED = "updated";
+
+    // Attributes
+    public static final Collection<String> AVAILABLE_ATTRIBUTES =
+            Collections.unmodifiableList(
+                Arrays.asList(BUILD_VERSION,
+                              BYTES_RETAINED,
+                              OPERATING_SYSTEM,
+                              PLATFORM,
+                              PROCESS_PID,
+                              PRODUCT_VERSION,
+                              STATISTICS_ENABLED,
+                              SUPPORTED_STORE_TYPES,
+                              CREATED,
+                              DURABLE,
+                              ID,
+                              LIFETIME_POLICY,
+                              NAME,
+                              STATE,
+                              TIME_TO_LIVE,
+                              UPDATED));
+
     //children
-    Collection<VirtualHost> getVirtualHosts();
+    Collection < VirtualHost > getVirtualHosts();
 
     Collection<Port> getPorts();
 

Modified: qpid/branches/java-config-and-management/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/BrokerAdapter.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-config-and-management/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/BrokerAdapter.java?rev=1332693&r1=1332692&r2=1332693&view=diff
==============================================================================
--- qpid/branches/java-config-and-management/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/BrokerAdapter.java (original)
+++ qpid/branches/java-config-and-management/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/BrokerAdapter.java Tue May  1 15:13:53 2012
@@ -27,6 +27,7 @@ import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
+import org.apache.qpid.common.QpidProperties;
 import org.apache.qpid.server.model.AuthenticationProvider;
 import org.apache.qpid.server.model.Broker;
 import org.apache.qpid.server.model.ConfiguredObject;
@@ -146,7 +147,7 @@ public class BrokerAdapter extends Abstr
     {
         return null;  //TODO
     }
-    
+
     public void deleteVirtualHost(final VirtualHost vhost)
         throws AccessControlException, IllegalStateException
     {
@@ -255,7 +256,7 @@ public class BrokerAdapter extends Abstr
         // TODO
         return null;
     }
-    
+
     private AuthenticationProvider createAuthenticationProvider(Map<String,Object> attributes)
     {
         // TODO
@@ -322,4 +323,91 @@ public class BrokerAdapter extends Abstr
             childRemoved(adapter);
         }
     }
+
+    @Override
+    public Collection<String> getAttributeNames()
+    {
+        return AVAILABLE_ATTRIBUTES;
+    }
+
+    @Override
+    public Object getAttribute(String name)
+    {
+        if(ID.equals(name))
+        {
+            return getId();
+        }
+        else if(NAME.equals(name))
+        {
+            return getName();
+        }
+        else if(STATE.equals(name))
+        {
+            return State.ACTIVE;
+        }
+        else if(DURABLE.equals(name))
+        {
+            return isDurable();
+        }
+        else if(LIFETIME_POLICY.equals(name))
+        {
+            return LifetimePolicy.PERMANENT;
+        }
+        else if(TIME_TO_LIVE.equals(name))
+        {
+            // TODO
+        }
+        else if(CREATED.equals(name))
+        {
+            // TODO
+        }
+        else if(UPDATED.equals(name))
+        {
+            // TODO
+        }
+        else if(BUILD_VERSION.equals(name))
+        {
+            return QpidProperties.getBuildVersion();
+        }
+        else if(BYTES_RETAINED.equals(name))
+        {
+            // TODO
+        }
+        else if(OPERATING_SYSTEM.equals(name))
+        {
+            return System.getProperty("os.name") + " "
+                   + System.getProperty("os.version") + " "
+                   + System.getProperty("os.arch");
+        }
+        else if(PLATFORM.equals(name))
+        {
+            return System.getProperty("java.vendor") + " "
+                   + System.getProperty("java.runtime.version", System.getProperty("java.version"));
+        }
+        else if(PROCESS_PID.equals(name))
+        {
+            // TODO
+        }
+        else if(PRODUCT_VERSION.equals(name))
+        {
+            return QpidProperties.getReleaseVersion();
+        }
+        else if(STATISTICS_ENABLED.equals(name))
+        {
+            // TODO
+        }
+        else if(SUPPORTED_STORE_TYPES.equals(name))
+        {
+            // TODO
+        }
+
+        return super.getAttribute(name);    //TODO - Implement.
+    }
+
+    @Override
+    public Object setAttribute(String name, Object expected, Object desired)
+            throws IllegalStateException, AccessControlException, IllegalArgumentException
+    {
+        return super.setAttribute(name, expected, desired);    //TODO - Implement.
+    }
 }

Modified: qpid/branches/java-config-and-management/qpid/java/broker/src/main/java/org/apache/qpid/server/registry/ApplicationRegistry.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-config-and-management/qpid/java/broker/src/main/java/org/apache/qpid/server/registry/ApplicationRegistry.java?rev=1332693&r1=1332692&r2=1332693&view=diff
==============================================================================
--- qpid/branches/java-config-and-management/qpid/java/broker/src/main/java/org/apache/qpid/server/registry/ApplicationRegistry.java (original)
+++ qpid/branches/java-config-and-management/qpid/java/broker/src/main/java/org/apache/qpid/server/registry/ApplicationRegistry.java Tue May  1 15:13:53 2012
@@ -22,6 +22,7 @@ package org.apache.qpid.server.registry;
 
 import org.apache.commons.configuration.ConfigurationException;
 import org.apache.log4j.Logger;
+import org.apache.qpid.server.logging.*;
 import org.osgi.framework.BundleContext;
 
 import org.apache.qpid.AMQException;
@@ -35,11 +36,6 @@ import org.apache.qpid.server.configurat
 import org.apache.qpid.server.configuration.SystemConfig;
 import org.apache.qpid.server.configuration.SystemConfigImpl;
 import org.apache.qpid.server.configuration.VirtualHostConfiguration;
-import org.apache.qpid.server.logging.CompositeStartupMessageLogger;
-import org.apache.qpid.server.logging.Log4jMessageLogger;
-import org.apache.qpid.server.logging.LogActor;
-import org.apache.qpid.server.logging.RootMessageLogger;
-import org.apache.qpid.server.logging.SystemOutMessageLogger;
 import org.apache.qpid.server.logging.actors.AbstractActor;
 import org.apache.qpid.server.logging.actors.BrokerActor;
 import org.apache.qpid.server.logging.actors.CurrentActor;
@@ -123,9 +119,11 @@ public abstract class ApplicationRegistr
     private BundleContext _bundleContext;
 
     private final List<PortBindingListener> _portBindingListeners = new ArrayList<PortBindingListener>();
-    
+
     private int _httpManagementPort = -1;
 
+    private LogRecorder _logRecorder;
+
     protected static Logger get_logger()
     {
         return _logger;
@@ -305,6 +303,7 @@ public abstract class ApplicationRegistr
 
     public void initialise() throws Exception
     {
+        _logRecorder = new LogRecorder();
         //Create the RootLogger to be used during broker operation
         _rootMessageLogger = new Log4jMessageLogger(_configuration);
 
@@ -795,4 +794,9 @@ public abstract class ApplicationRegistr
     {
         return _httpManagementPort;
     }
+
+    public LogRecorder getLogRecorder()
+    {
+        return _logRecorder;
+    }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


Mime
View raw message