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.StatsImpl; 022 023/** 024 * The J2EE Statistics for the Connection. 025 * 026 * 027 */ 028public class RegionStatistics extends StatsImpl { 029 030 private CountStatisticImpl advisoryDestinations; 031 private CountStatisticImpl destinations; 032 private CountStatisticImpl allDestinations; 033 034 public RegionStatistics() { 035 this(true); 036 } 037 038 public RegionStatistics(boolean enabled) { 039 040 advisoryDestinations = new CountStatisticImpl("advisoryTopics", "The number of advisory destinations in the region"); 041 destinations = new CountStatisticImpl("destinations", "The number of regular (non-adivsory) destinations in the region"); 042 allDestinations = new CountStatisticImpl("allDestinations", "The total number of destinations, including advisory destinations, in the region"); 043 044 addStatistic("advisoryDestinations", advisoryDestinations); 045 addStatistic("destinations", destinations); 046 addStatistic("allDestinations", allDestinations); 047 048 this.setEnabled(enabled); 049 } 050 051 public CountStatisticImpl getAdvisoryDestinations() { 052 return advisoryDestinations; 053 } 054 055 public CountStatisticImpl getDestinations() { 056 return destinations; 057 } 058 059 public CountStatisticImpl getAllDestinations() { 060 return allDestinations; 061 } 062 063 public void reset() { 064 super.reset(); 065 advisoryDestinations.reset(); 066 destinations.reset(); 067 allDestinations.reset(); 068 } 069 070 public void setEnabled(boolean enabled) { 071 super.setEnabled(enabled); 072 advisoryDestinations.setEnabled(enabled); 073 destinations.setEnabled(enabled); 074 allDestinations.setEnabled(enabled); 075 } 076 077 public void setParent(RegionStatistics parent) { 078 if (parent != null) { 079 advisoryDestinations.setParent(parent.getAdvisoryDestinations()); 080 destinations.setParent(parent.getDestinations()); 081 allDestinations.setParent(parent.getAllDestinations()); 082 } else { 083 advisoryDestinations.setParent(null); 084 destinations.setParent(null); 085 allDestinations.setParent(null); 086 } 087 } 088 089}