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 import org.apache.tools.ant.taskdefs.condition.IsReference;
025
026 /**
027 * The J2EE Statistics for the a Destination.
028 *
029 * @version $Revision$
030 */
031 public class DestinationStatistics extends StatsImpl {
032
033 protected CountStatisticImpl enqueues;
034 protected CountStatisticImpl dequeues;
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 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 consumers = new CountStatisticImpl("consumers", "The number of consumers that that are subscribing to messages from the destination");
050 consumers.setDoReset(false);
051 producers = new CountStatisticImpl("producers", "The number of producers that that are publishing messages to the destination");
052 producers.setDoReset(false);
053 messages = new CountStatisticImpl("messages", "The number of messages that that are being held by the destination");
054 messagesCached = new PollCountStatisticImpl("messagesCached", "The number of messages that are held in the destination's memory cache");
055 processTime = new TimeStatisticImpl("processTime", "information around length of time messages are held by a destination");
056 addStatistic("enqueues", enqueues);
057 addStatistic("dispatched", dispatched);
058 addStatistic("dequeues", dequeues);
059 addStatistic("inflight", inflight);
060 addStatistic("consumers", consumers);
061 addStatistic("producers", producers);
062 addStatistic("messages", messages);
063 addStatistic("messagesCached", messagesCached);
064 addStatistic("processTime", processTime);
065 }
066
067 public CountStatisticImpl getEnqueues() {
068 return enqueues;
069 }
070
071 public CountStatisticImpl getDequeues() {
072 return dequeues;
073 }
074
075 public CountStatisticImpl getInflight() {
076 return inflight;
077 }
078
079 public CountStatisticImpl getConsumers() {
080 return consumers;
081 }
082
083 public CountStatisticImpl getProducers() {
084 return producers;
085 }
086
087 public PollCountStatisticImpl getMessagesCached() {
088 return messagesCached;
089 }
090
091 public CountStatisticImpl getMessages() {
092 return messages;
093 }
094
095 public void setMessagesCached(PollCountStatisticImpl messagesCached) {
096 this.messagesCached = messagesCached;
097 }
098
099 public CountStatisticImpl getDispatched() {
100 return dispatched;
101 }
102
103 public TimeStatisticImpl getProcessTime() {
104 return this.processTime;
105 }
106
107 public void reset() {
108 if (this.isDoReset()) {
109 super.reset();
110 enqueues.reset();
111 dequeues.reset();
112 dispatched.reset();
113 inflight.reset();
114 }
115 }
116
117 public void setEnabled(boolean enabled) {
118 super.setEnabled(enabled);
119 enqueues.setEnabled(enabled);
120 dispatched.setEnabled(enabled);
121 dequeues.setEnabled(enabled);
122 inflight.setEnabled(enabled);
123 consumers.setEnabled(enabled);
124 producers.setEnabled(enabled);
125 messages.setEnabled(enabled);
126 messagesCached.setEnabled(enabled);
127 processTime.setEnabled(enabled);
128
129 }
130
131 public void setParent(DestinationStatistics parent) {
132 if (parent != null) {
133 enqueues.setParent(parent.enqueues);
134 dispatched.setParent(parent.dispatched);
135 dequeues.setParent(parent.dequeues);
136 inflight.setParent(parent.inflight);
137 consumers.setParent(parent.consumers);
138 producers.setParent(parent.producers);
139 messagesCached.setParent(parent.messagesCached);
140 messages.setParent(parent.messages);
141 processTime.setParent(parent.processTime);
142 } else {
143 enqueues.setParent(null);
144 dispatched.setParent(null);
145 dequeues.setParent(null);
146 inflight.setParent(null);
147 consumers.setParent(null);
148 producers.setParent(null);
149 messagesCached.setParent(null);
150 messages.setParent(null);
151 processTime.setParent(null);
152 }
153 }
154
155 }