001/** 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017 018package org.apache.activemq.broker.region; 019 020import org.apache.activemq.management.CountStatisticImpl; 021import org.apache.activemq.management.PollCountStatisticImpl; 022import org.apache.activemq.management.StatsImpl; 023import org.apache.activemq.management.*; 024 025/** 026 * The J2EE Statistics for the a Destination. 027 * 028 * 029 */ 030public class DestinationStatistics extends StatsImpl { 031 032 protected CountStatisticImpl enqueues; 033 protected CountStatisticImpl dequeues; 034 protected CountStatisticImpl forwards; 035 protected CountStatisticImpl consumers; 036 protected CountStatisticImpl producers; 037 protected CountStatisticImpl messages; 038 protected PollCountStatisticImpl messagesCached; 039 protected CountStatisticImpl dispatched; 040 protected CountStatisticImpl inflight; 041 protected CountStatisticImpl expired; 042 protected TimeStatisticImpl processTime; 043 protected CountStatisticImpl blockedSends; 044 protected TimeStatisticImpl blockedTime; 045 protected SizeStatisticImpl messageSize; 046 047 048 public DestinationStatistics() { 049 050 enqueues = new CountStatisticImpl("enqueues", "The number of messages that have been sent to the destination"); 051 dispatched = new CountStatisticImpl("dispatched", "The number of messages that have been dispatched from the destination"); 052 dequeues = new CountStatisticImpl("dequeues", "The number of messages that have been acknowledged from the destination"); 053 forwards = new CountStatisticImpl("forwards", "The number of messages that have been forwarded to a networked broker from the destination"); 054 inflight = new CountStatisticImpl("inflight", "The number of messages dispatched but awaiting acknowledgement"); 055 expired = new CountStatisticImpl("expired", "The number of messages that have expired"); 056 057 consumers = new CountStatisticImpl("consumers", "The number of consumers that that are subscribing to messages from the destination"); 058 consumers.setDoReset(false); 059 producers = new CountStatisticImpl("producers", "The number of producers that that are publishing messages to the destination"); 060 producers.setDoReset(false); 061 messages = new CountStatisticImpl("messages", "The number of messages that that are being held by the destination"); 062 messages.setDoReset(false); 063 messagesCached = new PollCountStatisticImpl("messagesCached", "The number of messages that are held in the destination's memory cache"); 064 processTime = new TimeStatisticImpl("processTime", "information around length of time messages are held by a destination"); 065 blockedSends = new CountStatisticImpl("blockedSends", "number of messages that have to wait for flow control"); 066 blockedTime = new TimeStatisticImpl("blockedTime","amount of time messages are blocked for flow control"); 067 messageSize = new SizeStatisticImpl("messageSize","Size of messages passing through the destination"); 068 addStatistic("enqueues", enqueues); 069 addStatistic("dispatched", dispatched); 070 addStatistic("dequeues", dequeues); 071 addStatistic("inflight", inflight); 072 addStatistic("expired", expired); 073 addStatistic("consumers", consumers); 074 addStatistic("producers", producers); 075 addStatistic("messages", messages); 076 addStatistic("messagesCached", messagesCached); 077 addStatistic("processTime", processTime); 078 addStatistic("blockedSends",blockedSends); 079 addStatistic("blockedTime",blockedTime); 080 addStatistic("messageSize",messageSize); 081 } 082 083 public CountStatisticImpl getEnqueues() { 084 return enqueues; 085 } 086 087 public CountStatisticImpl getDequeues() { 088 return dequeues; 089 } 090 091 public CountStatisticImpl getForwards() { 092 return forwards; 093 } 094 095 public CountStatisticImpl getInflight() { 096 return inflight; 097 } 098 099 public CountStatisticImpl getExpired() { 100 return expired; 101 } 102 103 public CountStatisticImpl getConsumers() { 104 return consumers; 105 } 106 107 public CountStatisticImpl getProducers() { 108 return producers; 109 } 110 111 public PollCountStatisticImpl getMessagesCached() { 112 return messagesCached; 113 } 114 115 public CountStatisticImpl getMessages() { 116 return messages; 117 } 118 119 public void setMessagesCached(PollCountStatisticImpl messagesCached) { 120 this.messagesCached = messagesCached; 121 } 122 123 public CountStatisticImpl getDispatched() { 124 return dispatched; 125 } 126 127 public TimeStatisticImpl getProcessTime() { 128 return this.processTime; 129 } 130 131 public CountStatisticImpl getBlockedSends(){ 132 return this.blockedSends; 133 } 134 public TimeStatisticImpl getBlockedTime(){ 135 return this.blockedTime; 136 } 137 public SizeStatisticImpl getMessageSize(){ 138 return this.messageSize; 139 } 140 141 public void reset() { 142 if (this.isDoReset()) { 143 super.reset(); 144 enqueues.reset(); 145 dequeues.reset(); 146 forwards.reset(); 147 dispatched.reset(); 148 inflight.reset(); 149 expired.reset(); 150 blockedSends.reset(); 151 blockedTime.reset(); 152 messageSize.reset(); 153 } 154 } 155 156 public void setEnabled(boolean enabled) { 157 super.setEnabled(enabled); 158 enqueues.setEnabled(enabled); 159 dispatched.setEnabled(enabled); 160 dequeues.setEnabled(enabled); 161 forwards.setEnabled(enabled); 162 inflight.setEnabled(enabled); 163 expired.setEnabled(true); 164 consumers.setEnabled(enabled); 165 producers.setEnabled(enabled); 166 messages.setEnabled(enabled); 167 messagesCached.setEnabled(enabled); 168 processTime.setEnabled(enabled); 169 blockedSends.setEnabled(enabled); 170 blockedTime.setEnabled(enabled); 171 messageSize.setEnabled(enabled); 172 173 } 174 175 public void setParent(DestinationStatistics parent) { 176 if (parent != null) { 177 enqueues.setParent(parent.enqueues); 178 dispatched.setParent(parent.dispatched); 179 dequeues.setParent(parent.dequeues); 180 forwards.setParent(parent.forwards); 181 inflight.setParent(parent.inflight); 182 expired.setParent(parent.expired); 183 consumers.setParent(parent.consumers); 184 producers.setParent(parent.producers); 185 messagesCached.setParent(parent.messagesCached); 186 messages.setParent(parent.messages); 187 processTime.setParent(parent.processTime); 188 blockedSends.setParent(parent.blockedSends); 189 blockedTime.setParent(parent.blockedTime); 190 messageSize.setParent(parent.messageSize); 191 } else { 192 enqueues.setParent(null); 193 dispatched.setParent(null); 194 dequeues.setParent(null); 195 forwards.setParent(null); 196 inflight.setParent(null); 197 expired.setParent(null); 198 consumers.setParent(null); 199 producers.setParent(null); 200 messagesCached.setParent(null); 201 messages.setParent(null); 202 processTime.setParent(null); 203 blockedSends.setParent(null); 204 blockedTime.setParent(null); 205 messageSize.setParent(null); 206 } 207 } 208 209}