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 */
017package org.apache.activemq.broker.view;
018
019import org.apache.activemq.broker.region.Destination;
020
021public class BrokerDestinationView {
022    private final Destination destination;
023
024
025     BrokerDestinationView(Destination destination) {
026        this.destination = destination;
027    }
028
029
030    /**
031     * @return the name of the DestinationView
032     */
033    public String getName() {
034        return destination.getName();
035    }
036
037    /**
038     * @return the number of messages enqueued by this destination
039     */
040
041    public long getEnqueueCount() {
042        return destination.getDestinationStatistics().getEnqueues().getCount();
043    }
044
045    /**
046     * @return the number of messages dequeued (dispatched and removed) by this destination
047     */
048    public long getDequeueCount() {
049        return destination.getDestinationStatistics().getDequeues().getCount();
050    }
051
052    /**
053     * @return the number of messages dispatched by this destination
054     */
055    public long getDispatchCount() {
056        return destination.getDestinationStatistics().getDispatched().getCount();
057    }
058
059    /**
060     * @return the number of messages inflight (dispatched by not acknowledged) by this destination
061     */
062    public long getInFlightCount() {
063        return destination.getDestinationStatistics().getInflight().getCount();
064    }
065
066    /**
067     * @return the number of messages expired by this destination
068     */
069    public long getExpiredCount() {
070        return destination.getDestinationStatistics().getExpired().getCount();
071    }
072
073    /**
074     * @return the number of active consumers on this destination
075     */
076    public int getConsumerCount() {
077        return (int)destination.getDestinationStatistics().getConsumers().getCount();
078    }
079
080    /**
081     * @return the number of active consumers on this destination
082     */
083    public int getProducerCount() {
084        return (int)destination.getDestinationStatistics().getProducers().getCount();
085    }
086
087    /**
088     * @return the depth of the Destination
089     */
090    public long getQueueSize() {
091        return destination.getDestinationStatistics().getMessages().getCount();
092    }
093
094    /**
095     * @return the number of messages cached in memory by this destination
096     */
097    public long getMessagesCached() {
098        return destination.getDestinationStatistics().getMessagesCached().getCount();
099    }
100
101    /**
102     * @return the memory usage as a percentage for this Destination
103     */
104    public int getMemoryPercentUsage() {
105        return destination.getMemoryUsage().getPercentUsage();
106    }
107
108    /**
109     * @return the memory used by this destination in bytes
110     */
111    public long getMemoryUsageByteCount() {
112        return destination.getMemoryUsage().getUsage();
113    }
114
115
116    /**
117     * @return  the memory limit for this destination in bytes
118     */
119    public long getMemoryLimit() {
120        return destination.getMemoryUsage().getLimit();
121    }
122
123    /**
124     * Gets the temp usage as a percentage for this Destination.
125     *
126     * @return Gets the temp usage as a percentage for this Destination.
127     */
128    public int getTempPercentUsage() {
129        return destination.getTempUsage().getPercentUsage();
130    }
131
132    /**
133     * Gets the temp usage limit in bytes.
134     *
135     * @return the temp usage limit in bytes.
136     */
137    public long getTempUsageLimit() {
138        return destination.getTempUsage().getLimit();
139    }
140
141    /**
142     * @return the average time it takes to store a message on this destination (ms)
143     */
144    public double getAverageEnqueueTime() {
145        return destination.getDestinationStatistics().getProcessTime().getAverageTime();
146    }
147
148    /**
149     * @return the maximum time it takes to store a message on this destination (ms)
150     */
151    public long getMaxEnqueueTime() {
152        return destination.getDestinationStatistics().getProcessTime().getMaxTime();
153    }
154
155    /**
156     * @return the minimum time it takes to store a message on this destination (ms)
157     */
158
159    public long getMinEnqueueTime() {
160        return destination.getDestinationStatistics().getProcessTime().getMinTime();
161    }
162
163    /**
164     * @return the average size of a message (bytes)
165     */
166    public double getAverageMessageSize() {
167        return destination.getDestinationStatistics().getMessageSize().getAverageSize();
168    }
169
170    /**
171      * @return the max size of a message (bytes)
172    */
173    public long getMaxMessageSize() {
174        return destination.getDestinationStatistics().getMessageSize().getMaxSize();
175    }
176
177    /**
178     * @return the min size of a message (bytes)
179     */
180    public long getMinMessageSize() {
181        return destination.getDestinationStatistics().getMessageSize().getMinSize();
182    }
183
184
185    /**
186     * @return true if the destination is a Dead Letter Queue
187     */
188    public boolean isDLQ() {
189        return destination.getActiveMQDestination().isDLQ();
190    }
191
192
193    /**
194     * @return the number of messages blocked waiting for dispatch (indication of slow consumption if greater than zero)
195     */
196    public long getBlockedSends() {
197        return destination.getDestinationStatistics().getBlockedSends().getCount();
198    }
199
200    /**
201     * @return the average time(ms) messages are  blocked waiting for dispatch (indication of slow consumption if greater than zero)
202     */
203
204    public double getAverageBlockedTime() {
205        return destination.getDestinationStatistics().getBlockedTime().getAverageTime();
206    }
207
208    /**
209     * @return the total time(ms) messages are  blocked waiting for dispatch (indication of slow consumption if greater than zero)
210     */
211
212    public long getTotalBlockedTime() {
213        return destination.getDestinationStatistics().getBlockedTime().getTotalTime();
214    }
215}