KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > activemq > broker > region > DestinationStatistics


1 /**
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one or more
4  * contributor license agreements. See the NOTICE file distributed with
5  * this work for additional information regarding copyright ownership.
6  * The ASF licenses this file to You under the Apache License, Version 2.0
7  * (the "License"); you may not use this file except in compliance with
8  * the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */

18
19 package org.apache.activemq.broker.region;
20
21 import org.apache.activemq.command.Message;
22 import org.apache.activemq.management.CountStatisticImpl;
23 import org.apache.activemq.management.PollCountStatisticImpl;
24 import org.apache.activemq.management.StatsImpl;
25
26 /**
27  * The J2EE Statistics for the a Destination.
28  *
29  * @version $Revision$
30  */

31 public class DestinationStatistics extends StatsImpl {
32
33     protected CountStatisticImpl enqueues;
34     protected CountStatisticImpl dequeues;
35     protected CountStatisticImpl consumers;
36     protected CountStatisticImpl messages;
37     protected PollCountStatisticImpl messagesCached;
38     protected CountStatisticImpl dispatched;
39
40     public DestinationStatistics() {
41
42         enqueues = new CountStatisticImpl("enqueues", "The number of messages that have been sent to the destination");
43         dispatched = new CountStatisticImpl("dispatched", "The number of messages that have been dispatched from the destination");
44         dequeues = new CountStatisticImpl("dequeues", "The number of messages that have been acknowledged from the destination");
45         consumers = new CountStatisticImpl("consumers", "The number of consumers that that are subscribing to messages from the destination");
46         messages = new CountStatisticImpl("messages", "The number of messages that that are being held by the destination");
47         messagesCached = new PollCountStatisticImpl("messagesCached", "The number of messages that are held in the destination's memory cache");
48
49         addStatistic("enqueues", enqueues);
50         addStatistic("dispatched", dispatched);
51         addStatistic("dequeues", dequeues);
52         addStatistic("consumers", consumers);
53         addStatistic("messages", messages);
54         addStatistic("messagesCached", messagesCached);
55     }
56
57     public CountStatisticImpl getEnqueues() {
58         return enqueues;
59     }
60
61     public CountStatisticImpl getDequeues() {
62         return dequeues;
63     }
64
65     public CountStatisticImpl getConsumers() {
66         return consumers;
67     }
68
69     public PollCountStatisticImpl getMessagesCached() {
70         return messagesCached;
71     }
72
73     public CountStatisticImpl getMessages() {
74         return messages;
75     }
76
77     public void reset() {
78         super.reset();
79         enqueues.reset();
80         dequeues.reset();
81         dispatched.reset();
82     }
83     
84     public void setEnabled(boolean enabled) {
85         super.setEnabled(enabled);
86         enqueues.setEnabled(enabled);
87         dispatched.setEnabled(enabled);
88         dequeues.setEnabled(enabled);
89         consumers.setEnabled(enabled);
90         messages.setEnabled(enabled);
91         messagesCached.setEnabled(enabled);
92
93     }
94
95     public void setParent(DestinationStatistics parent) {
96         if (parent != null) {
97             enqueues.setParent(parent.enqueues);
98             dispatched.setParent(parent.dispatched);
99             dequeues.setParent(parent.dequeues);
100             consumers.setParent(parent.consumers);
101             messagesCached.setParent(parent.messagesCached);
102             messages.setParent(parent.messages);
103         }
104         else {
105             enqueues.setParent(null);
106             dispatched.setParent(null);
107             dequeues.setParent(null);
108             consumers.setParent(null);
109             messagesCached.setParent(null);
110             messages.setParent(null);
111         }
112     }
113
114     public void setMessagesCached(PollCountStatisticImpl messagesCached) {
115         this.messagesCached = messagesCached;
116     }
117
118     public CountStatisticImpl getDispatched() {
119     return dispatched;
120     }
121 }
122
Popular Tags