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
018 package org.apache.activemq.broker.region;
019
020 import org.apache.activemq.management.CountStatisticImpl;
021 import org.apache.activemq.management.PollCountStatisticImpl;
022 import org.apache.activemq.management.StatsImpl;
023 import org.apache.activemq.management.TimeStatisticImpl;
024
025 /**
026 * The J2EE Statistics for the a Destination.
027 *
028 *
029 */
030 public class DestinationStatistics extends StatsImpl {
031
032 protected CountStatisticImpl enqueues;
033 protected CountStatisticImpl dequeues;
034 protected CountStatisticImpl consumers;
035 protected CountStatisticImpl producers;
036 protected CountStatisticImpl messages;
037 protected PollCountStatisticImpl messagesCached;
038 protected CountStatisticImpl dispatched;
039 protected CountStatisticImpl inflight;
040 protected CountStatisticImpl expired;
041 protected TimeStatisticImpl processTime;
042
043 public DestinationStatistics() {
044
045 enqueues = new CountStatisticImpl("enqueues", "The number of messages that have been sent to the destination");
046 dispatched = new CountStatisticImpl("dispatched", "The number of messages that have been dispatched from the destination");
047 dequeues = new CountStatisticImpl("dequeues", "The number of messages that have been acknowledged from the destination");
048 inflight = new CountStatisticImpl("inflight", "The number of messages dispatched but awaiting acknowledgement");
049 expired = new CountStatisticImpl("expired", "The number of messages that have expired");
050
051 consumers = new CountStatisticImpl("consumers", "The number of consumers that that are subscribing to messages from the destination");
052 consumers.setDoReset(false);
053 producers = new CountStatisticImpl("producers", "The number of producers that that are publishing messages to the destination");
054 producers.setDoReset(false);
055 messages = new CountStatisticImpl("messages", "The number of messages that that are being held by the destination");
056 messagesCached = new PollCountStatisticImpl("messagesCached", "The number of messages that are held in the destination's memory cache");
057 processTime = new TimeStatisticImpl("processTime", "information around length of time messages are held by a destination");
058 addStatistic("enqueues", enqueues);
059 addStatistic("dispatched", dispatched);
060 addStatistic("dequeues", dequeues);
061 addStatistic("inflight", inflight);
062 addStatistic("expired", expired);
063 addStatistic("consumers", consumers);
064 addStatistic("producers", producers);
065 addStatistic("messages", messages);
066 addStatistic("messagesCached", messagesCached);
067 addStatistic("processTime", processTime);
068 }
069
070 public CountStatisticImpl getEnqueues() {
071 return enqueues;
072 }
073
074 public CountStatisticImpl getDequeues() {
075 return dequeues;
076 }
077
078 public CountStatisticImpl getInflight() {
079 return inflight;
080 }
081
082 public CountStatisticImpl getExpired() {
083 return expired;
084 }
085
086 public CountStatisticImpl getConsumers() {
087 return consumers;
088 }
089
090 public CountStatisticImpl getProducers() {
091 return producers;
092 }
093
094 public PollCountStatisticImpl getMessagesCached() {
095 return messagesCached;
096 }
097
098 public CountStatisticImpl getMessages() {
099 return messages;
100 }
101
102 public void setMessagesCached(PollCountStatisticImpl messagesCached) {
103 this.messagesCached = messagesCached;
104 }
105
106 public CountStatisticImpl getDispatched() {
107 return dispatched;
108 }
109
110 public TimeStatisticImpl getProcessTime() {
111 return this.processTime;
112 }
113
114 public void reset() {
115 if (this.isDoReset()) {
116 super.reset();
117 enqueues.reset();
118 dequeues.reset();
119 dispatched.reset();
120 inflight.reset();
121 expired.reset();
122 }
123 }
124
125 public void setEnabled(boolean enabled) {
126 super.setEnabled(enabled);
127 enqueues.setEnabled(enabled);
128 dispatched.setEnabled(enabled);
129 dequeues.setEnabled(enabled);
130 inflight.setEnabled(enabled);
131 expired.setEnabled(true);
132 consumers.setEnabled(enabled);
133 producers.setEnabled(enabled);
134 messages.setEnabled(enabled);
135 messagesCached.setEnabled(enabled);
136 processTime.setEnabled(enabled);
137
138 }
139
140 public void setParent(DestinationStatistics parent) {
141 if (parent != null) {
142 enqueues.setParent(parent.enqueues);
143 dispatched.setParent(parent.dispatched);
144 dequeues.setParent(parent.dequeues);
145 inflight.setParent(parent.inflight);
146 expired.setParent(parent.expired);
147 consumers.setParent(parent.consumers);
148 producers.setParent(parent.producers);
149 messagesCached.setParent(parent.messagesCached);
150 messages.setParent(parent.messages);
151 processTime.setParent(parent.processTime);
152 } else {
153 enqueues.setParent(null);
154 dispatched.setParent(null);
155 dequeues.setParent(null);
156 inflight.setParent(null);
157 expired.setParent(null);
158 consumers.setParent(null);
159 producers.setParent(null);
160 messagesCached.setParent(null);
161 messages.setParent(null);
162 processTime.setParent(null);
163 }
164 }
165
166 }