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 /** 125 * @return the average time it takes to store a message on this destination (ms) 126 */ 127 public double getAverageEnqueueTime() { 128 return destination.getDestinationStatistics().getProcessTime().getAverageTime(); 129 } 130 131 /** 132 * @return the maximum time it takes to store a message on this destination (ms) 133 */ 134 public long getMaxEnqueueTime() { 135 return destination.getDestinationStatistics().getProcessTime().getMaxTime(); 136 } 137 138 /** 139 * @return the minimum time it takes to store a message on this destination (ms) 140 */ 141 142 public long getMinEnqueueTime() { 143 return destination.getDestinationStatistics().getProcessTime().getMinTime(); 144 } 145 146 /** 147 * @return the average size of a message (bytes) 148 */ 149 public double getAverageMessageSize() { 150 return destination.getDestinationStatistics().getMessageSize().getAverageSize(); 151 } 152 153 /** 154 * @return the max size of a message (bytes) 155 */ 156 public long getMaxMessageSize() { 157 return destination.getDestinationStatistics().getMessageSize().getMaxSize(); 158 } 159 160 /** 161 * @return the min size of a message (bytes) 162 */ 163 public long getMinMessageSize() { 164 return destination.getDestinationStatistics().getMessageSize().getMinSize(); 165 } 166 167 168 /** 169 * @return true if the destination is a Dead Letter Queue 170 */ 171 public boolean isDLQ() { 172 return destination.getActiveMQDestination().isDLQ(); 173 } 174 175 176 /** 177 * @return the number of messages blocked waiting for dispatch (indication of slow consumption if greater than zero) 178 */ 179 public long getBlockedSends() { 180 return destination.getDestinationStatistics().getBlockedSends().getCount(); 181 } 182 183 /** 184 * @return the average time(ms) messages are blocked waiting for dispatch (indication of slow consumption if greater than zero) 185 */ 186 187 public double getAverageBlockedTime() { 188 return destination.getDestinationStatistics().getBlockedTime().getAverageTime(); 189 } 190 191 /** 192 * @return the total time(ms) messages are blocked waiting for dispatch (indication of slow consumption if greater than zero) 193 */ 194 195 public long getTotalBlockedTime() { 196 return destination.getDestinationStatistics().getBlockedTime().getTotalTime(); 197 } 198}