geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dwo...@apache.org
Subject svn commit: r672342 - in /geronimo/server/trunk/plugins/activemq/activemq-portlets/src/main: java/org/apache/geronimo/console/jmsmanager/ java/org/apache/geronimo/console/jmsmanager/helper/ java/org/apache/geronimo/console/jmsmanager/wizard/ resources/...
Date Fri, 27 Jun 2008 17:44:28 GMT
Author: dwoods
Date: Fri Jun 27 10:44:28 2008
New Revision: 672342

URL: http://svn.apache.org/viewvc?rev=672342&view=rev
Log:
GERONIMO-3983 Update JMS Resource portlet to show the Destination statistics.  Thanks Anish
for the patch.

Added:
    geronimo/server/trunk/plugins/activemq/activemq-portlets/src/main/java/org/apache/geronimo/console/jmsmanager/DestinationStatistics.java
  (with props)
Modified:
    geronimo/server/trunk/plugins/activemq/activemq-portlets/src/main/java/org/apache/geronimo/console/jmsmanager/helper/AmqJMSMessageHelper.java
    geronimo/server/trunk/plugins/activemq/activemq-portlets/src/main/java/org/apache/geronimo/console/jmsmanager/helper/JMSMessageHelper.java
    geronimo/server/trunk/plugins/activemq/activemq-portlets/src/main/java/org/apache/geronimo/console/jmsmanager/helper/JMSMessageHelperFactory.java
    geronimo/server/trunk/plugins/activemq/activemq-portlets/src/main/java/org/apache/geronimo/console/jmsmanager/wizard/ListScreenHandler.java
    geronimo/server/trunk/plugins/activemq/activemq-portlets/src/main/resources/activemq.properties
    geronimo/server/trunk/plugins/activemq/activemq-portlets/src/main/webapp/WEB-INF/view/jmswizard/list.jsp

Added: geronimo/server/trunk/plugins/activemq/activemq-portlets/src/main/java/org/apache/geronimo/console/jmsmanager/DestinationStatistics.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/activemq/activemq-portlets/src/main/java/org/apache/geronimo/console/jmsmanager/DestinationStatistics.java?rev=672342&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/activemq/activemq-portlets/src/main/java/org/apache/geronimo/console/jmsmanager/DestinationStatistics.java
(added)
+++ geronimo/server/trunk/plugins/activemq/activemq-portlets/src/main/java/org/apache/geronimo/console/jmsmanager/DestinationStatistics.java
Fri Jun 27 10:44:28 2008
@@ -0,0 +1,56 @@
+/**
+ *  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.geronimo.console.jmsmanager;
+
+/**
+ * 
+ *
+ * @version $Rev$ $Date$
+ */
+public class DestinationStatistics {
+    private long enqueueCount;
+    private long dequeueCount;
+    private long consumerCount;
+    private long queueSize;
+    
+    public long getQueueSize() {
+        return queueSize;
+    }
+    public void setQueueSize(long queueSize) {
+        this.queueSize = queueSize;
+    }
+    public long getConsumerCount() {
+        return consumerCount;
+    }
+    public void setConsumerCount(long consumerCount) {
+        this.consumerCount = consumerCount;
+    }
+    public long getDequeueCount() {
+        return dequeueCount;
+    }
+    public void setDequeueCount(long dequeueCount) {
+        this.dequeueCount = dequeueCount;
+    }
+    public long getEnqueueCount() {
+        return enqueueCount;
+    }
+    public void setEnqueueCount(long enqueueCount) {
+        this.enqueueCount = enqueueCount;
+    }
+    
+    
+}

Propchange: geronimo/server/trunk/plugins/activemq/activemq-portlets/src/main/java/org/apache/geronimo/console/jmsmanager/DestinationStatistics.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: geronimo/server/trunk/plugins/activemq/activemq-portlets/src/main/java/org/apache/geronimo/console/jmsmanager/helper/AmqJMSMessageHelper.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/activemq/activemq-portlets/src/main/java/org/apache/geronimo/console/jmsmanager/helper/AmqJMSMessageHelper.java?rev=672342&r1=672341&r2=672342&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/activemq/activemq-portlets/src/main/java/org/apache/geronimo/console/jmsmanager/helper/AmqJMSMessageHelper.java
(original)
+++ geronimo/server/trunk/plugins/activemq/activemq-portlets/src/main/java/org/apache/geronimo/console/jmsmanager/helper/AmqJMSMessageHelper.java
Fri Jun 27 10:44:28 2008
@@ -27,9 +27,11 @@
 import javax.portlet.PortletRequest;
 
 import org.apache.geronimo.activemq.BrokerServiceGBeanImpl;
+import org.apache.geronimo.console.jmsmanager.DestinationStatistics;
 import org.apache.geronimo.console.util.PortletManager;
 import org.apache.geronimo.system.jmx.MBeanServerReference;
 import org.apache.activemq.broker.jmx.BrokerViewMBean;
+import org.apache.activemq.broker.jmx.DestinationViewMBean;
 import org.apache.activemq.broker.jmx.QueueViewMBean;
 import org.apache.activemq.broker.jmx.TopicViewMBean;
 import org.slf4j.Logger;
@@ -83,6 +85,52 @@
          */
         return null;
     }
+    public  DestinationStatistics getDestinationStatistics(String destType,String physicalName){
+        DestinationStatistics stat = new DestinationStatistics();
+        try {
+            MBeanServer server = getMBeanServer();
+            String brokerName = getBrokerName();
+            ObjectName objName = new ObjectName("org.apache.activemq" + ":BrokerName=" +
brokerName + ",Type=" + destType + ",Destination=" + physicalName);
+            DestinationViewMBean proxy = null;
+            if ("Queue".equals(destType)) {
+                if (!server.isRegistered(objName)) {
+                    // mbean is not yet registered.Adding the destination to activemq broker.
+                    ObjectName brokerObj = new ObjectName("org.apache.activemq" + ":BrokerName="
+ brokerName + ",Type=Broker");
+                    Set set = server.queryMBeans(brokerObj, null);
+                    Iterator it = set.iterator();
+                    if (it.hasNext()) {
+                        ObjectInstance instance = (ObjectInstance) it.next();
+                        brokerObj = instance.getObjectName();
+                    }
+                    BrokerViewMBean brokerMBean = (BrokerViewMBean) MBeanServerInvocationHandler.newProxyInstance(server,
brokerObj, BrokerViewMBean.class, true);
+                    brokerMBean.addQueue(physicalName);
+                }
+                proxy = (DestinationViewMBean) MBeanServerInvocationHandler.newProxyInstance(server,
objName, QueueViewMBean.class, true);
+            }else{
+                if (!server.isRegistered(objName)) {
+                    // mbean is not yet registered.Adding the destination to activemq broker.
+                    ObjectName brokerObj = new ObjectName("org.apache.activemq" + ":BrokerName="
+ brokerName + ",Type=Broker");
+                    Set set = server.queryMBeans(brokerObj, null);
+                    Iterator it = set.iterator();
+                    if (it.hasNext()) {
+                        ObjectInstance instance = (ObjectInstance) it.next();
+                        brokerObj = instance.getObjectName();
+                    }
+                    BrokerViewMBean brokerMBean = (BrokerViewMBean) MBeanServerInvocationHandler.newProxyInstance(server,
brokerObj, BrokerViewMBean.class, true);
+                    brokerMBean.addTopic(physicalName);
+                }
+                proxy = (DestinationViewMBean) MBeanServerInvocationHandler.newProxyInstance(server,
objName, TopicViewMBean.class, true);
+            }
+            stat.setConsumerCount(proxy.getConsumerCount());
+            stat.setEnqueueCount(proxy.getEnqueueCount());
+            stat.setDequeueCount(proxy.getDequeueCount());
+            stat.setQueueSize(proxy.getQueueSize());
+        } catch (Exception ex) {
+            // ignoring the exception
+            log.error(ex);
+        }
+        return stat;
+    }
 
     private MBeanServer getMBeanServer() throws Exception {
         MBeanServerReference ref = (MBeanServerReference) kernel.getGBean(MBeanServerReference.class);

Modified: geronimo/server/trunk/plugins/activemq/activemq-portlets/src/main/java/org/apache/geronimo/console/jmsmanager/helper/JMSMessageHelper.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/activemq/activemq-portlets/src/main/java/org/apache/geronimo/console/jmsmanager/helper/JMSMessageHelper.java?rev=672342&r1=672341&r2=672342&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/activemq/activemq-portlets/src/main/java/org/apache/geronimo/console/jmsmanager/helper/JMSMessageHelper.java
(original)
+++ geronimo/server/trunk/plugins/activemq/activemq-portlets/src/main/java/org/apache/geronimo/console/jmsmanager/helper/JMSMessageHelper.java
Fri Jun 27 10:44:28 2008
@@ -43,6 +43,7 @@
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.apache.geronimo.console.core.jms.TopicBrowserGBean;
+import org.apache.geronimo.console.jmsmanager.DestinationStatistics;
 import org.apache.geronimo.console.jmsmanager.JMSMessageInfo;
 import org.apache.geronimo.console.util.PortletManager;
 import org.apache.geronimo.gbean.AbstractName;
@@ -274,5 +275,7 @@
     protected abstract List getMessagesFromTopic(String type, String physicalQName) throws
Exception;
 
     public abstract void purge(PortletRequest renderRequest, String type, String physicalQName);
+    
+    public abstract DestinationStatistics getDestinationStatistics(String destType,String
physicalName);
 
 }

Modified: geronimo/server/trunk/plugins/activemq/activemq-portlets/src/main/java/org/apache/geronimo/console/jmsmanager/helper/JMSMessageHelperFactory.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/activemq/activemq-portlets/src/main/java/org/apache/geronimo/console/jmsmanager/helper/JMSMessageHelperFactory.java?rev=672342&r1=672341&r2=672342&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/activemq/activemq-portlets/src/main/java/org/apache/geronimo/console/jmsmanager/helper/JMSMessageHelperFactory.java
(original)
+++ geronimo/server/trunk/plugins/activemq/activemq-portlets/src/main/java/org/apache/geronimo/console/jmsmanager/helper/JMSMessageHelperFactory.java
Fri Jun 27 10:44:28 2008
@@ -22,6 +22,7 @@
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.apache.geronimo.console.jmsmanager.DestinationStatistics;
 import org.apache.geronimo.console.util.PortletManager;
 import org.apache.geronimo.management.geronimo.ResourceAdapterModule;
 
@@ -33,42 +34,49 @@
 
     public static JMSMessageHelper getMessageHelper(PortletRequest renderRequest, String
raName) {
         JMSMessageHelper messageHelper = null;
-        try {
-            ResourceAdapterModule[] modules = PortletManager.getOutboundRAModules(renderRequest,
new String[] {
-                    "javax.jms.ConnectionFactory", "javax.jms.QueueConnectionFactory",
-                    "javax.jms.TopicConnectionFactory", });
-            for (int i = 0; i < modules.length; i++) {
-                ResourceAdapterModule module = modules[i];
-                String objectNameTemp = module.getObjectName();
-                if (raName != null && raName.equals(objectNameTemp)) {
-                    String vendorName = module.getVendorName();
-                    if ("activemq.org".equals(vendorName)) {
-                        Class class_ = Class
-                                .forName("org.apache.geronimo.console.jmsmanager.helper.AmqJMSMessageHelper");
-                        messageHelper = (JMSMessageHelper) class_.newInstance();
-                    }
-                }
+        ResourceAdapterModule[] modules = PortletManager.getOutboundRAModules(renderRequest,
new String[] {
+                "javax.jms.ConnectionFactory", "javax.jms.QueueConnectionFactory",
+                "javax.jms.TopicConnectionFactory", });
+        String vendorName = null;
+        for (int i = 0; i < modules.length; i++) {
+            ResourceAdapterModule module = modules[i];
+            String objectNameTemp = module.getObjectName();
+            if (raName != null && raName.equals(objectNameTemp)) {
+                vendorName = module.getVendorName();
             }
-            if (messageHelper == null) {
-                messageHelper = new JMSMessageHelper() {
-                    public List getMessagesFromTopic(String type, String physicalQName) {
-                        return null;
-                    }
+        }
+        return getJMSMessageHelper(vendorName);
+    }
 
-                    public void purge(PortletRequest renderRequest, String type, String physicalQName)
{
-                        return;
-                    }
-                };
+    public static JMSMessageHelper getJMSMessageHelper(String vendorName){
+        JMSMessageHelper messageHelper = null;
+        if ("activemq.org".equals(vendorName)) {
+            try{
+                Class class_ = Class
+                    .forName("org.apache.geronimo.console.jmsmanager.helper.AmqJMSMessageHelper");
+                messageHelper = (JMSMessageHelper) class_.newInstance();
+            } catch (IllegalAccessException e) {
+                log.error(e);
+            } catch (InstantiationException e) {
+                log.error(e);
+            } catch (ClassNotFoundException e) {
+                log.error(e);
             }
-            return messageHelper;
-
-        } catch (IllegalAccessException e) {
-            log.error(e.toString(), e);
-        } catch (InstantiationException e) {
-            log.error(e.toString(), e);
-        } catch (ClassNotFoundException e) {
-            log.error(e.toString(), e);
         }
-        return messageHelper;
-    }
+        if(messageHelper == null){
+            messageHelper = new JMSMessageHelper() {
+                public List getMessagesFromTopic(String type, String physicalQName) {
+                    return null;
+                }
+ 
+                public void purge(PortletRequest renderRequest, String type, String physicalQName)
{
+                    return;
+                }
+                public  DestinationStatistics getDestinationStatistics(String destType,String
physicalName){
+                    return null;
+                }
+            };
+         }
+         return messageHelper;
+     }
 }

Modified: geronimo/server/trunk/plugins/activemq/activemq-portlets/src/main/java/org/apache/geronimo/console/jmsmanager/wizard/ListScreenHandler.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/activemq/activemq-portlets/src/main/java/org/apache/geronimo/console/jmsmanager/wizard/ListScreenHandler.java?rev=672342&r1=672341&r2=672342&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/activemq/activemq-portlets/src/main/java/org/apache/geronimo/console/jmsmanager/wizard/ListScreenHandler.java
(original)
+++ geronimo/server/trunk/plugins/activemq/activemq-portlets/src/main/java/org/apache/geronimo/console/jmsmanager/wizard/ListScreenHandler.java
Fri Jun 27 10:44:28 2008
@@ -31,6 +31,7 @@
 import javax.portlet.RenderResponse;
 
 import org.apache.geronimo.console.MultiPageModel;
+import org.apache.geronimo.console.jmsmanager.DestinationStatistics;
 import org.apache.geronimo.console.jmsmanager.helper.JMSMessageHelper;
 import org.apache.geronimo.console.jmsmanager.helper.JMSMessageHelperFactory;
 import org.apache.geronimo.console.util.PortletManager;
@@ -185,10 +186,12 @@
                         log.warn("PhysicalName undefined, using queueName as PhysicalName",
e);
                         physicalName = queueName;
                     }
+                    String destType = admins[j].getAdminObjectInterface().indexOf("Queue")
> -1 ? "Queue" : "Topic";
+                    String vendorName = module.getVendorName();
+                    DestinationStatistics destinationStat = JMSMessageHelperFactory.getJMSMessageHelper(vendorName).getDestinationStatistics(destType,
physicalName);
                     target.getAdminObjects().add(
-                            new AdminObjectSummary(bean.getObjectName(), queueName, physicalName,
admins[j]
-                                    .getAdminObjectInterface().indexOf("Queue") > -1 ?
"Queue" : "Topic", bean
-                                    .getState()));
+                            new AdminObjectSummary(bean.getObjectName(), queueName, physicalName,destType
, bean
+                                    .getState(),destinationStat));
                 }
             }
         } catch (MalformedObjectNameException e) {
@@ -327,15 +330,20 @@
         private final String type;
         private final int state;
         private final String physicalName;
- 
-        public AdminObjectSummary(String adminObjectName, String name, String physicalName,
String type, int state) {
+        private final DestinationStatistics destinationStat;
+        
+        public AdminObjectSummary(String adminObjectName, String name, String physicalName,
String type, int state,DestinationStatistics destinationStat) {
             this.adminObjectName = adminObjectName;
             this.name = name;
             this.physicalName = physicalName;
             this.type = type;
             this.state = state;
+            this.destinationStat = destinationStat;
+        }
+        
+        public DestinationStatistics getdestinationStat(){
+            return this.destinationStat;
         }
-
         public String getAdminObjectName() {
             return adminObjectName;
         }

Modified: geronimo/server/trunk/plugins/activemq/activemq-portlets/src/main/resources/activemq.properties
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/activemq/activemq-portlets/src/main/resources/activemq.properties?rev=672342&r1=672341&r2=672342&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/activemq/activemq-portlets/src/main/resources/activemq.properties
(original)
+++ geronimo/server/trunk/plugins/activemq/activemq-portlets/src/main/resources/activemq.properties
Fri Jun 27 10:44:28 2008
@@ -161,6 +161,8 @@
 jmswizard.common.Browse                                 = Browse
 jmswizard.common.Send                                   = Send
 jmswizard.common.Purge                                  = Purge
+jmswizard.common.consumerCount                          = Consumer Count
+jmswizard.common.queueSize                              = Queue Size
 jmswizard.destination.destinationConfSettings           = Destination Configuration Settings
 jmswizard.destination.messageDestinationName            = Message Destination Name
 jmswizard.destination.title                             = <b>JMS Resource Group</b>
-- Configure Destination

Modified: geronimo/server/trunk/plugins/activemq/activemq-portlets/src/main/webapp/WEB-INF/view/jmswizard/list.jsp
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/activemq/activemq-portlets/src/main/webapp/WEB-INF/view/jmswizard/list.jsp?rev=672342&r1=672341&r2=672342&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/activemq/activemq-portlets/src/main/webapp/WEB-INF/view/jmswizard/list.jsp
(original)
+++ geronimo/server/trunk/plugins/activemq/activemq-portlets/src/main/webapp/WEB-INF/view/jmswizard/list.jsp
Fri Jun 27 10:44:28 2008
@@ -39,6 +39,8 @@
           <th class="DarkBackground"><fmt:message key="jmswizard.common.name"/></th>
           <th class="DarkBackground" align="center"><fmt:message key="jmswizard.common.deployedAs"/></th>
           <th class="DarkBackground" align="center"><fmt:message key="jmswizard.common.state"/></th>
+          <th class="DarkBackground" align="center"><fmt:message key="jmswizard.common.consumerCount"/></th>
+          <th class="DarkBackground" align="center"><fmt:message key="jmswizard.common.queueSize"/></th>
           <th class="DarkBackground" align="center"><fmt:message key="jmswizard.common.actions"/></th>
         </tr>
         <c:set var="backgroundClass" value='MediumBackground'/>
@@ -107,6 +109,16 @@
               </td>
               <td class="${backgroundClass}">${admin.stateName}</td>
               <td class="${backgroundClass}">
+              <c:if test="${admin.destinationStat != null}">
+              	${admin.destinationStat.consumerCount}
+              </c:if>
+              </td>
+              <td class="${backgroundClass}">
+              <c:if test="${admin.destinationStat != null}">
+              	${admin.destinationStat.queueSize}
+              </c:if>
+              </td>
+              <td class="${backgroundClass}">
               <c:if test="${ admin.type == 'Queue'}">
                  <a href="<portlet:actionURL portletMode="view">
 	                  <portlet:param name="mode" value="viewMessages-before" />



Mime
View raw message