mirror of https://github.com/apache/activemq.git
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
git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1422953 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
757a2f1d32
commit
973909ab44
|
@ -58,6 +58,8 @@ import org.apache.activemq.broker.jmx.AnnotatedMBean;
|
|||
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.ManagementContext;
|
|||
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 Service {
|
|||
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()) + ","
|
||||
|
|
|
@ -18,29 +18,32 @@ package org.apache.activemq.broker.jmx;
|
|||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class StatusEvent implements Serializable {
|
||||
public class HealthStatus implements Serializable {
|
||||
private final String healthId;
|
||||
private final String level;
|
||||
private final String message;
|
||||
private final String resource;
|
||||
|
||||
protected String id;
|
||||
protected String resource;
|
||||
|
||||
public StatusEvent(String id, String resource) {
|
||||
this.id = id;
|
||||
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() {
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public String getResource() {
|
||||
return resource;
|
||||
}
|
||||
|
||||
public void setResource(String resource) {
|
||||
this.resource = resource;
|
||||
}
|
||||
}
|
|
@ -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;
|
|
@ -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;
|
||||
}
|
|
@ -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() {
|
||||
|
|
Loading…
Reference in New Issue