activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jstrac...@apache.org
Subject svn commit: r1422953 - in /activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker: ./ jmx/
Date Mon, 17 Dec 2012 14:42:45 GMT
Author: jstrachan
Date: Mon Dec 17 14:42:44 2012
New Revision: 1422953

URL: http://svn.apache.org/viewvc?rev=1422953&view=rev
Log:
refactored mbean name and properties to more comply with https://github.com/hawtio/hawtio/blob/master/doc/HealthMBeans.md#health-mbeans
and make it a little more descriptive for users

Added:
    activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/HealthStatus.java
      - copied, changed from r1422851, 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/HealthView.java
      - copied, changed from r1422851, 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/HealthViewMBean.java
      - copied, changed from r1422851, activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/StatusViewMBean.java
Removed:
    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/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=1422953&r1=1422952&r2=1422953&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
Mon Dec 17 14:42:44 2012
@@ -58,6 +58,8 @@ import org.apache.activemq.broker.jmx.An
 import org.apache.activemq.broker.jmx.BrokerView;
 import org.apache.activemq.broker.jmx.ConnectorView;
 import org.apache.activemq.broker.jmx.ConnectorViewMBean;
+import org.apache.activemq.broker.jmx.HealthView;
+import org.apache.activemq.broker.jmx.HealthViewMBean;
 import org.apache.activemq.broker.jmx.JmsConnectorView;
 import org.apache.activemq.broker.jmx.JobSchedulerView;
 import org.apache.activemq.broker.jmx.JobSchedulerViewMBean;
@@ -66,8 +68,6 @@ import org.apache.activemq.broker.jmx.Ma
 import org.apache.activemq.broker.jmx.NetworkConnectorView;
 import org.apache.activemq.broker.jmx.NetworkConnectorViewMBean;
 import org.apache.activemq.broker.jmx.ProxyConnectorView;
-import org.apache.activemq.broker.jmx.StatusView;
-import org.apache.activemq.broker.jmx.StatusViewMBean;
 import org.apache.activemq.broker.region.CompositeDestinationInterceptor;
 import org.apache.activemq.broker.region.Destination;
 import org.apache.activemq.broker.region.DestinationFactory;
@@ -2187,7 +2187,7 @@ public class BrokerService implements Se
             broker = sb;
         }
         if (isUseJmx()) {
-            StatusViewMBean statusView = new StatusView((ManagedRegionBroker)getRegionBroker());
+            HealthViewMBean statusView = new HealthView((ManagedRegionBroker)getRegionBroker());
             try {
                 ObjectName objectName = new ObjectName(getManagementContext().getJmxDomainName()
+ ":"
                         + "BrokerName=" + JMXSupport.encodeObjectNamePart(getBrokerName())
+ ","

Copied: activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/HealthStatus.java
(from r1422851, 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/HealthStatus.java?p2=activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/HealthStatus.java&p1=activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/StatusEvent.java&r1=1422851&r2=1422953&rev=1422953&view=diff
==============================================================================
--- activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/StatusEvent.java
(original)
+++ activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/HealthStatus.java
Mon Dec 17 14:42:44 2012
@@ -18,29 +18,32 @@ 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;
+public class HealthStatus implements Serializable {
+    private final String healthId;
+    private final String level;
+    private final String message;
+    private final String resource;
+
+    public HealthStatus(String healthId, String level, String message, String resource) {
+        this.healthId = healthId;
+        this.level = level;
+        this.message = message;
         this.resource = resource;
     }
 
-    public String getId() {
-        return id;
+    public String getHealthId() {
+        return healthId;
     }
 
-    public void setId(String id) {
-        this.id = id;
+    public String getLevel() {
+        return level;
     }
 
-    public Object getResource() {
-        return resource;
+    public String getMessage() {
+        return message;
     }
 
-    public void setResource(String resource) {
-        this.resource = resource;
+    public String getResource() {
+        return resource;
     }
 }

Copied: activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/HealthView.java
(from r1422851, 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/HealthView.java?p2=activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/HealthView.java&p1=activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/StatusView.java&r1=1422851&r2=1422953&rev=1422953&view=diff
==============================================================================
--- activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/StatusView.java
(original)
+++ activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/HealthView.java
Mon Dec 17 14:42:44 2012
@@ -26,36 +26,38 @@ import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 
-public class StatusView implements StatusViewMBean {
+public class HealthView implements HealthViewMBean {
 
     ManagedRegionBroker broker;
 
-    public StatusView(ManagedRegionBroker broker) {
+    public HealthView(ManagedRegionBroker broker) {
         this.broker = broker;
     }
 
     @Override
     public TabularData health() throws Exception {
-        OpenTypeSupport.OpenTypeFactory factory = OpenTypeSupport.getFactory(StatusEvent.class);
+        OpenTypeSupport.OpenTypeFactory factory = OpenTypeSupport.getFactory(HealthStatus.class);
         CompositeType ct = factory.getCompositeType();
-        TabularType tt = new TabularType("Status", "Status", ct, new String[]{"id", "resource"});
+        TabularType tt = new TabularType("HealthStatus", "HealthStatus", ct, new String[]{"healthId",
"level", "message", "resource"});
         TabularDataSupport rc = new TabularDataSupport(tt);
 
-        List<StatusEvent> list = healthList();
-        for (StatusEvent statusEvent : list) {
-            rc.put(new CompositeDataSupport(ct, factory.getFields(statusEvent)));
+        List<HealthStatus> list = healthList();
+        for (HealthStatus healthStatus : list) {
+            rc.put(new CompositeDataSupport(ct, factory.getFields(healthStatus)));
         }
         return rc;
     }
 
     @Override
-    public List<StatusEvent> healthList() throws Exception {
-        List<StatusEvent> answer = new ArrayList<StatusEvent>();
+    public List<HealthStatus> healthList() throws Exception {
+        List<HealthStatus> answer = new ArrayList<HealthStatus>();
         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)
{
-                answer.add(new StatusEvent("AMQ-NoConsumer", entry.getKey().toString()));
+                ObjectName key = entry.getKey();
+                String message = "Queue " + queue.getName() + " has no consumers";
+                answer.add(new HealthStatus("org.apache.activemq.noConsumer", "WARNING",
message, key.toString()));
             }
         }
         return answer;

Copied: activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/HealthViewMBean.java
(from r1422851, 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/HealthViewMBean.java?p2=activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/HealthViewMBean.java&p1=activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/StatusViewMBean.java&r1=1422851&r2=1422953&rev=1422953&view=diff
==============================================================================
--- activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/StatusViewMBean.java
(original)
+++ activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/HealthViewMBean.java
Mon Dec 17 14:42:44 2012
@@ -22,16 +22,16 @@ import java.util.List;
 /**
  * Returns the status events of the broker to indicate any warnings.
  */
-public interface StatusViewMBean {
+public interface HealthViewMBean {
 
     public TabularData health() throws Exception;
 
     /**
      * Warning this method can only be invoked if you have the correct version
-     * of {@link StatusEvent} on your classpath or you use something
+     * of {@link HealthStatus} on your classpath or you use something
      * like <a href="http://jolokia.org/">jolokia</a> to access JMX.
      *
      * If in doubt, please use the {@link #status()} method instead!
      */
-    List<StatusEvent> healthList() throws Exception;
+    List<HealthStatus> healthList() throws Exception;
 }

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=1422953&r1=1422952&r2=1422953&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
Mon Dec 17 14:42:44 2012
@@ -478,24 +478,28 @@ public final class OpenTypeSupport {
         }
     }
 
-    static class StatusEventOpenTypeFactory extends AbstractOpenTypeFactory {
+    static class HealthStatusOpenTypeFactory extends AbstractOpenTypeFactory {
         @Override
         protected String getTypeName() {
-            return StatusEvent.class.getName();
+            return HealthStatus.class.getName();
         }
 
         @Override
         protected void init() throws OpenDataException {
             super.init();
-            addItem("id", "event id", SimpleType.STRING);
+            addItem("healthId", "health check id", SimpleType.STRING);
+            addItem("level", "severity", SimpleType.STRING);
+            addItem("message", "severity", SimpleType.STRING);
             addItem("resource", "event resource", SimpleType.STRING);
         }
 
         @Override
         public Map<String, Object> getFields(Object o) throws OpenDataException {
-            StatusEvent event = (StatusEvent) o;
+            HealthStatus event = (HealthStatus) o;
             Map<String, Object> rc = super.getFields(o);
-            rc.put("id", event.getId());
+            rc.put("healthId", event.getHealthId());
+            rc.put("level", event.getLevel());
+            rc.put("message", event.getMessage());
             rc.put("resource", event.getResource());
             return rc;
         }
@@ -511,7 +515,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());
+        OPEN_TYPE_FACTORIES.put(HealthStatus.class, new HealthStatusOpenTypeFactory());
     }
 
     private OpenTypeSupport() {



Mime
View raw message