activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dej...@apache.org
Subject svn commit: r1415159 - in /activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker: BrokerService.java jmx/ManagedRegionBroker.java jmx/OpenTypeSupport.java jmx/StatusEvent.java jmx/StatusView.java jmx/StatusViewMBean.java
Date Thu, 29 Nov 2012 13:28:38 GMT
Author: dejanb
Date: Thu Nov 29 13:28:37 2012
New Revision: 1415159

URL: http://svn.apache.org/viewvc?rev=1415159&view=rev
Log:
https://issues.apache.org/jira/browse/AMQ-4191 - prototype of the Status MBean

Added:
    activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/StatusEvent.java
    activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/StatusView.java
    activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/StatusViewMBean.java
Modified:
    activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/BrokerService.java
    activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/ManagedRegionBroker.java
    activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/OpenTypeSupport.java

Modified: activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/BrokerService.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/BrokerService.java?rev=1415159&r1=1415158&r2=1415159&view=diff
==============================================================================
--- activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/BrokerService.java
(original)
+++ activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/BrokerService.java
Thu Nov 29 13:28:37 2012
@@ -2064,6 +2064,19 @@ public class BrokerService implements Se
             }
             broker = sb;
         }
+        if (isUseJmx()) {
+            StatusViewMBean statusView = new StatusView((ManagedRegionBroker)getRegionBroker());
+            try {
+                ObjectName objectName = new ObjectName(getManagementContext().getJmxDomainName()
+ ":"
+                        + "BrokerName=" + JMXSupport.encodeObjectNamePart(getBrokerName())
+ ","
+                        + "Type=Status");
+
+                AnnotatedMBean.registerMBean(getManagementContext(), statusView, objectName);
+            } catch (Throwable e) {
+                throw IOExceptionSupport.create("Status MBean could not be registered in
JMX: "
+                        + e.getMessage(), e);
+            }
+        }
         if (isAdvisorySupport()) {
             broker = new AdvisoryBroker(broker);
         }

Modified: activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/ManagedRegionBroker.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/ManagedRegionBroker.java?rev=1415159&r1=1415158&r2=1415159&view=diff
==============================================================================
--- activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/ManagedRegionBroker.java
(original)
+++ activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/ManagedRegionBroker.java
Thu Nov 29 13:28:37 2012
@@ -809,4 +809,8 @@ public class ManagedRegionBroker extends
         }
         return sub;
     }
+
+    public Map<ObjectName, DestinationView> getQueueViews() {
+        return queues;
+    }
 }

Modified: activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/OpenTypeSupport.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/OpenTypeSupport.java?rev=1415159&r1=1415158&r2=1415159&view=diff
==============================================================================
--- activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/OpenTypeSupport.java
(original)
+++ activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/OpenTypeSupport.java
Thu Nov 29 13:28:37 2012
@@ -478,6 +478,29 @@ public final class OpenTypeSupport {
         }
     }
 
+    static class StatusEventOpenTypeFactory extends AbstractOpenTypeFactory {
+        @Override
+        protected String getTypeName() {
+            return StatusEvent.class.getName();
+        }
+
+        @Override
+        protected void init() throws OpenDataException {
+            super.init();
+            addItem("id", "event id", SimpleType.STRING);
+            addItem("resource", "event resource", SimpleType.STRING);
+        }
+
+        @Override
+        public Map<String, Object> getFields(Object o) throws OpenDataException {
+            StatusEvent event = (StatusEvent) o;
+            Map<String, Object> rc = super.getFields(o);
+            rc.put("id", event.getId());
+            rc.put("resource", event.getResource());
+            return rc;
+        }
+    }
+
     static {
         OPEN_TYPE_FACTORIES.put(ActiveMQMessage.class, new MessageOpenTypeFactory());
         OPEN_TYPE_FACTORIES.put(ActiveMQBytesMessage.class, new ByteMessageOpenTypeFactory());
@@ -488,6 +511,7 @@ public final class OpenTypeSupport {
         OPEN_TYPE_FACTORIES.put(Job.class, new JobOpenTypeFactory());
         OPEN_TYPE_FACTORIES.put(SlowConsumerEntry.class, new SlowConsumerEntryOpenTypeFactory());
         OPEN_TYPE_FACTORIES.put(ActiveMQBlobMessage.class, new ActiveMQBlobMessageOpenTypeFactory());
+        OPEN_TYPE_FACTORIES.put(StatusEvent.class, new StatusEventOpenTypeFactory());
     }
 
     private OpenTypeSupport() {

Added: activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/StatusEvent.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/StatusEvent.java?rev=1415159&view=auto
==============================================================================
--- activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/StatusEvent.java
(added)
+++ activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/StatusEvent.java
Thu Nov 29 13:28:37 2012
@@ -0,0 +1,46 @@
+/**
+ * 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.activemq.broker.jmx;
+
+import java.io.Serializable;
+
+public class StatusEvent implements Serializable {
+
+    protected String id;
+    protected String resource;
+
+    public StatusEvent(String id, String resource) {
+        this.id = id;
+        this.resource = resource;
+    }
+
+    public String getId() {
+        return id;
+    }
+
+    public void setId(String id) {
+        this.id = id;
+    }
+
+    public Object getResource() {
+        return resource;
+    }
+
+    public void setResource(String resource) {
+        this.resource = resource;
+    }
+}

Added: activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/StatusView.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/StatusView.java?rev=1415159&view=auto
==============================================================================
--- activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/StatusView.java
(added)
+++ activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/StatusView.java
Thu Nov 29 13:28:37 2012
@@ -0,0 +1,52 @@
+/**
+ * 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.activemq.broker.jmx;
+
+import javax.management.ObjectName;
+import javax.management.openmbean.CompositeDataSupport;
+import javax.management.openmbean.CompositeType;
+import javax.management.openmbean.TabularData;
+import javax.management.openmbean.TabularDataSupport;
+import javax.management.openmbean.TabularType;
+import java.util.Map;
+
+public class StatusView implements StatusViewMBean {
+
+    ManagedRegionBroker broker;
+
+    public StatusView(ManagedRegionBroker broker) {
+        this.broker = broker;
+    }
+
+    @Override
+    public TabularData status() throws Exception {
+        OpenTypeSupport.OpenTypeFactory factory = OpenTypeSupport.getFactory(StatusEvent.class);
+        CompositeType ct = factory.getCompositeType();
+        TabularType tt = new TabularType("Status", "Status", ct, new String[]{"id", "resource"});
+        TabularDataSupport rc = new TabularDataSupport(tt);
+
+        Map<ObjectName, DestinationView> queueViews = broker.getQueueViews();
+        for (Map.Entry<ObjectName, DestinationView> entry : queueViews.entrySet())
{
+            DestinationView queue = entry.getValue();
+            if (queue.getConsumerCount() == 0 && queue.getProducerCount() > 0)
{
+                rc.put(new CompositeDataSupport(ct, factory.getFields(new StatusEvent("AMQ-NoConsumer",
entry.getKey().toString()))));
+            }
+        }
+        return rc;
+    }
+
+}

Added: activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/StatusViewMBean.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/StatusViewMBean.java?rev=1415159&view=auto
==============================================================================
--- activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/StatusViewMBean.java
(added)
+++ activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/StatusViewMBean.java
Thu Nov 29 13:28:37 2012
@@ -0,0 +1,24 @@
+/**
+ * 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.activemq.broker.jmx;
+
+import javax.management.openmbean.TabularData;
+
+public interface StatusViewMBean {
+
+    public TabularData status() throws Exception;
+}



Mime
View raw message