001 /** 002 * 003 * Copyright 2004 Protique Ltd 004 * 005 * Licensed under the Apache License, Version 2.0 (the "License"); 006 * you may not use this file except in compliance with the License. 007 * 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 019 020 package org.activemq.capacity; 021 /** 022 * Fires CapacityChangedEvents 023 * 024 * @version $Revision: 1.1.1.1 $ 025 */ 026 public interface CapacityMonitor { 027 028 /** 029 * 030 * A CapacityMonitor holds percentage values 031 * for some resource that has a capacity - 032 * e.g. a MemoryBoundedQueue 033 * @version $Revision: 1.1.1.1 $ 034 */ 035 public class BasicCapacityMonitor{ 036 037 } 038 /** 039 * Get the name of the CapacityMonitor 040 * @return the name 041 */ 042 public String getName(); 043 044 /** 045 * Set the name of the CapacityMonitor 046 * @param newName 047 */ 048 public void setName(String newName); 049 050 /** 051 * Get the rounding factor - default is 10 052 * @return the rounding factor 053 */ 054 public int getRoundingFactor(); 055 056 /** 057 * Set the rounding factor (between 1-100) 058 * @param newRoundingFactor 059 */ 060 public void setRoundingFactor(int newRoundingFactor); 061 062 /** 063 * Add a CapacityMonitorEventListener 064 * 065 * @param l 066 */ 067 public void addCapacityEventListener(CapacityMonitorEventListener l); 068 069 /** 070 * Remove a CapacityMonitorEventListener 071 * 072 * @param l 073 */ 074 public void removeCapacityEventListener(CapacityMonitorEventListener l); 075 076 /** 077 * Get the current capacity of the service as a percentage 078 * 079 * @return 080 */ 081 public int getCurrentCapacity(); 082 083 /** 084 * Calculates the capacity rounded down to the rounding factor 085 * @return 086 */ 087 public int getRoundedCapacity(); 088 089 /** 090 * Get the current value of the CapacityMonitor 091 * 092 * @return 093 */ 094 public long getCurrentValue(); 095 096 /** 097 * set the current value of the capacity 098 * 099 * @param newCurrentValue 100 */ 101 public void setCurrentValue(long newCurrentValue); 102 103 /** 104 * @return The upper limit of the value of the CapacityMonitor 105 */ 106 public long getValueLimit(); 107 108 /** 109 * set a new value limit for the CapacityMonitor 110 * 111 * @param newValueLimit 112 */ 113 public void setValueLimit(long newValueLimit); 114 115 /** 116 * @return a CapacityMontorEvent for the currentCapacity 117 */ 118 public CapacityMonitorEvent generateCapacityMonitorEvent(); 119 }