KickJava   Java API By Example, From Geeks To Geeks.

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


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 import org.apache.activemq.management.CountStatisticImpl;
21 import org.apache.activemq.management.PollCountStatisticImpl;
22 import org.apache.activemq.management.StatsImpl;
23
24 /**
25  * The J2EE Statistics for the a Destination.
26  *
27  * @version $Revision: 506415 $
28  */

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