1 17 package org.apache.servicemix.jbi.framework; 18 19 import javax.management.JMException ; 20 import javax.management.MBeanAttributeInfo ; 21 import javax.management.MBeanOperationInfo ; 22 23 import org.apache.servicemix.jbi.management.AttributeInfoHelper; 24 import org.apache.servicemix.jbi.management.BaseLifeCycle; 25 import org.apache.servicemix.jbi.management.OperationInfoHelper; 26 27 30 public class ComponentStats extends BaseLifeCycle implements ComponentStatsMBean { 31 32 private ComponentMBeanImpl component; 33 34 39 public ComponentStats(ComponentMBeanImpl component) { 40 this.component = component; 41 } 42 43 47 public String getType() { 48 return "Component"; 49 } 50 51 public String getSubType() { 52 return "Statistics"; 53 } 54 55 59 public String getName() { 60 return component.getName(); 61 } 62 63 67 public String getDescription() { 68 return "Statistics for " + component.getDescription(); 69 } 70 71 76 public long getInboundExchangeCount() { 77 return component.getMessagingStats().getInboundExchanges().getCount(); 78 } 79 80 85 public double getInboundExchangeRate() { 86 return component.getMessagingStats().getInboundExchangeRate().getAverageTime(); 87 } 88 89 94 public long getOutboundExchangeCount() { 95 return component.getMessagingStats().getOutboundExchanges().getCount(); 96 } 97 98 103 public double getOutboundExchangeRate() { 104 return component.getMessagingStats().getOutboundExchangeRate().getAverageTime(); 105 } 106 107 110 public int getInboundQueueSize() { 111 if (component.getDeliveryChannel() != null) { 112 return component.getDeliveryChannel().getQueueSize(); 113 } else { 114 return 0; 115 } 116 } 117 118 121 public void reset() { 122 component.getMessagingStats().reset(); 123 } 124 125 131 public MBeanAttributeInfo [] getAttributeInfos() throws JMException { 132 AttributeInfoHelper helper = new AttributeInfoHelper(); 133 helper.addAttribute(getObjectToManage(), "inboundQueueSize", "size of the inbound queue"); 134 helper.addAttribute(getObjectToManage(), "inboundExchangeCount", "count of inbound exchanges"); 135 helper.addAttribute(getObjectToManage(), "outboundExchangeCount", "count of outbound exchanges"); 136 helper.addAttribute(getObjectToManage(), "inboundExchangeRate", "rate of inbound exchanges/sec"); 137 helper.addAttribute(getObjectToManage(), "outboundExchangeRate", "rate of outbound exchanges/sec"); 138 return helper.getAttributeInfos(); 139 } 140 141 146 public MBeanOperationInfo [] getOperationInfos() { 147 OperationInfoHelper helper = new OperationInfoHelper(); 148 helper.addOperation(getObjectToManage(), "reset", "reset statistic counters"); 149 return helper.getOperationInfos(); 150 } 151 152 } 153 | Popular Tags |