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
024 /**
025 * The J2EE Statistics for the a Destination.
026 *
027 *
028 */
029 public class ConnectorStatistics extends StatsImpl {
030
031 protected CountStatisticImpl enqueues;
032 protected CountStatisticImpl dequeues;
033 protected CountStatisticImpl consumers;
034 protected CountStatisticImpl messages;
035 protected PollCountStatisticImpl messagesCached;
036
037 public ConnectorStatistics() {
038
039 enqueues = new CountStatisticImpl("enqueues", "The number of messages that have been sent to the destination");
040 dequeues = new CountStatisticImpl("dequeues", "The number of messages that have been dispatched from the destination");
041 consumers = new CountStatisticImpl("consumers", "The number of consumers that that are subscribing to messages from the destination");
042 messages = new CountStatisticImpl("messages", "The number of messages that that are being held by the destination");
043 messagesCached = new PollCountStatisticImpl("messagesCached", "The number of messages that are held in the destination's memory cache");
044
045 addStatistic("enqueues", enqueues);
046 addStatistic("dequeues", dequeues);
047 addStatistic("consumers", consumers);
048 addStatistic("messages", messages);
049 addStatistic("messagesCached", messagesCached);
050 }
051
052 public CountStatisticImpl getEnqueues() {
053 return enqueues;
054 }
055
056 public CountStatisticImpl getDequeues() {
057 return dequeues;
058 }
059
060 public CountStatisticImpl getConsumers() {
061 return consumers;
062 }
063
064 public PollCountStatisticImpl getMessagesCached() {
065 return messagesCached;
066 }
067
068 public CountStatisticImpl getMessages() {
069 return messages;
070 }
071
072 public void reset() {
073 super.reset();
074 enqueues.reset();
075 dequeues.reset();
076 }
077
078 public void setEnabled(boolean enabled) {
079 super.setEnabled(enabled);
080 enqueues.setEnabled(enabled);
081 dequeues.setEnabled(enabled);
082 consumers.setEnabled(enabled);
083 messages.setEnabled(enabled);
084 messagesCached.setEnabled(enabled);
085 }
086
087 public void setParent(ConnectorStatistics parent) {
088 if (parent != null) {
089 enqueues.setParent(parent.enqueues);
090 dequeues.setParent(parent.dequeues);
091 consumers.setParent(parent.consumers);
092 messagesCached.setParent(parent.messagesCached);
093 messages.setParent(parent.messages);
094 } else {
095 enqueues.setParent(null);
096 dequeues.setParent(null);
097 consumers.setParent(null);
098 messagesCached.setParent(null);
099 messages.setParent(null);
100 }
101 }
102
103 public void setMessagesCached(PollCountStatisticImpl messagesCached) {
104 this.messagesCached = messagesCached;
105 }
106 }