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 duplicateFromStore;
041    protected CountStatisticImpl inflight;
042    protected CountStatisticImpl expired;
043    protected TimeStatisticImpl processTime;
044    protected CountStatisticImpl blockedSends;
045    protected TimeStatisticImpl blockedTime;
046    protected SizeStatisticImpl messageSize;
047
048
049    public DestinationStatistics() {
050
051        enqueues = new CountStatisticImpl("enqueues", "The number of messages that have been sent to the destination");
052        dispatched = new CountStatisticImpl("dispatched", "The number of messages that have been dispatched from the destination");
053        dequeues = new CountStatisticImpl("dequeues", "The number of messages that have been acknowledged from the destination");
054        duplicateFromStore = new CountStatisticImpl("duplicateFromStore", "The number of duplicate messages that have been paged-in from the store for this destination");
055        forwards = new CountStatisticImpl("forwards", "The number of messages that have been forwarded to a networked broker from the destination");
056        inflight = new CountStatisticImpl("inflight", "The number of messages dispatched but awaiting acknowledgement");
057        expired = new CountStatisticImpl("expired", "The number of messages that have expired");
058
059        consumers = new CountStatisticImpl("consumers", "The number of consumers that that are subscribing to messages from the destination");
060        consumers.setDoReset(false);
061        producers = new CountStatisticImpl("producers", "The number of producers that that are publishing messages to the destination");
062        producers.setDoReset(false);
063        messages = new CountStatisticImpl("messages", "The number of messages that that are being held by the destination");
064        messages.setDoReset(false);
065        messagesCached = new PollCountStatisticImpl("messagesCached", "The number of messages that are held in the destination's memory cache");
066        processTime = new TimeStatisticImpl("processTime", "information around length of time messages are held by a destination");
067        blockedSends = new CountStatisticImpl("blockedSends", "number of messages that have to wait for flow control");
068        blockedTime = new TimeStatisticImpl("blockedTime","amount of time messages are blocked for flow control");
069        messageSize = new SizeStatisticImpl("messageSize","Size of messages passing through the destination");
070        addStatistic("enqueues", enqueues);
071        addStatistic("dispatched", dispatched);
072        addStatistic("dequeues", dequeues);
073        addStatistic("duplicateFromStore", duplicateFromStore);
074        addStatistic("inflight", inflight);
075        addStatistic("expired", expired);
076        addStatistic("consumers", consumers);
077        addStatistic("producers", producers);
078        addStatistic("messages", messages);
079        addStatistic("messagesCached", messagesCached);
080        addStatistic("processTime", processTime);
081        addStatistic("blockedSends",blockedSends);
082        addStatistic("blockedTime",blockedTime);
083        addStatistic("messageSize",messageSize);
084    }
085
086    public CountStatisticImpl getEnqueues() {
087        return enqueues;
088    }
089
090    public CountStatisticImpl getDequeues() {
091        return dequeues;
092    }
093
094    public CountStatisticImpl getForwards() {
095        return forwards;
096    }
097
098    public CountStatisticImpl getInflight() {
099        return inflight;
100    }
101
102    public CountStatisticImpl getExpired() {
103        return expired;
104    }
105
106    public CountStatisticImpl getConsumers() {
107        return consumers;
108    }
109
110    public CountStatisticImpl getProducers() {
111        return producers;
112    }
113
114    public PollCountStatisticImpl getMessagesCached() {
115        return messagesCached;
116    }
117
118    public CountStatisticImpl getMessages() {
119        return messages;
120    }
121
122    public void setMessagesCached(PollCountStatisticImpl messagesCached) {
123        this.messagesCached = messagesCached;
124    }
125
126    public CountStatisticImpl getDispatched() {
127        return dispatched;
128    }
129
130    public CountStatisticImpl getDuplicateFromStore() {
131        return duplicateFromStore;
132    }
133
134    public TimeStatisticImpl getProcessTime() {
135        return this.processTime;
136    }
137
138    public CountStatisticImpl getBlockedSends(){
139        return this.blockedSends;
140    }
141    public TimeStatisticImpl getBlockedTime(){
142        return this.blockedTime;
143    }
144    public SizeStatisticImpl getMessageSize(){
145        return this.messageSize;
146    }
147
148    public void reset() {
149        if (this.isDoReset()) {
150            super.reset();
151            enqueues.reset();
152            dequeues.reset();
153            forwards.reset();
154            dispatched.reset();
155            duplicateFromStore.reset();
156            inflight.reset();
157            expired.reset();
158            blockedSends.reset();
159            blockedTime.reset();
160            messageSize.reset();
161        }
162    }
163
164    public void setEnabled(boolean enabled) {
165        super.setEnabled(enabled);
166        enqueues.setEnabled(enabled);
167        dispatched.setEnabled(enabled);
168        dequeues.setEnabled(enabled);
169        duplicateFromStore.setEnabled(enabled);
170        forwards.setEnabled(enabled);
171        inflight.setEnabled(enabled);
172        expired.setEnabled(true);
173        consumers.setEnabled(enabled);
174        producers.setEnabled(enabled);
175        messages.setEnabled(enabled);
176        messagesCached.setEnabled(enabled);
177        processTime.setEnabled(enabled);
178        blockedSends.setEnabled(enabled);
179        blockedTime.setEnabled(enabled);
180        messageSize.setEnabled(enabled);
181
182    }
183
184    public void setParent(DestinationStatistics parent) {
185        if (parent != null) {
186            enqueues.setParent(parent.enqueues);
187            dispatched.setParent(parent.dispatched);
188            dequeues.setParent(parent.dequeues);
189            duplicateFromStore.setParent(parent.duplicateFromStore);
190            forwards.setParent(parent.forwards);
191            inflight.setParent(parent.inflight);
192            expired.setParent(parent.expired);
193            consumers.setParent(parent.consumers);
194            producers.setParent(parent.producers);
195            messagesCached.setParent(parent.messagesCached);
196            messages.setParent(parent.messages);
197            processTime.setParent(parent.processTime);
198            blockedSends.setParent(parent.blockedSends);
199            blockedTime.setParent(parent.blockedTime);
200            messageSize.setParent(parent.messageSize);
201        } else {
202            enqueues.setParent(null);
203            dispatched.setParent(null);
204            dequeues.setParent(null);
205            duplicateFromStore.setParent(null);
206            forwards.setParent(null);
207            inflight.setParent(null);
208            expired.setParent(null);
209            consumers.setParent(null);
210            producers.setParent(null);
211            messagesCached.setParent(null);
212            messages.setParent(null);
213            processTime.setParent(null);
214            blockedSends.setParent(null);
215            blockedTime.setParent(null);
216            messageSize.setParent(null);
217        }
218    }
219
220}