Package org.apache.activemq.usage
Class Usage<T extends Usage>
java.lang.Object
org.apache.activemq.usage.Usage<T>
- All Implemented Interfaces:
Service
- Direct Known Subclasses:
MemoryUsage
Used to keep track of how much of something is being used so that a productive working set usage can be controlled.
Main use case is manage memory usage.
-
Field Summary
Modifier and TypeFieldDescriptionprotected String
protected T
protected int
protected final ReentrantReadWriteLock
protected final Condition
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
void
addUsageListener
(UsageListener listener) protected int
long
getLimit()
getName()
int
int
int
int
long
getUsage()
float
boolean
isFull()
boolean
isFull
(int highWaterMark) boolean
boolean
notifyCallbackWhenNotFull
(Runnable callback) protected void
protected void
removeChild
(T child) void
removeUsageListener
(UsageListener listener) protected abstract long
void
setExecutor
(ThreadPoolExecutor executor) void
setLimit
(long limit) Sets the memory limit in bytes.void
setLimiter
(UsageCapacity limiter) void
void
protected void
setPercentUsage
(int value) void
setPercentUsageMinDelta
(int percentUsageMinDelta) Sets the minimum number of percentage points the usage has to change before a UsageListener event is fired by the manager.void
setPollingTime
(int pollingTime) void
setUsagePortion
(float usagePortion) void
start()
void
stop()
toString()
void
boolean
waitForSpace
(long timeout) boolean
waitForSpace
(long timeout, int highWaterMark)
-
Field Details
-
usageLock
-
waitForSpaceCondition
-
percentUsage
protected int percentUsage -
parent
-
name
-
-
Constructor Details
-
Usage
-
-
Method Details
-
retrieveUsage
protected abstract long retrieveUsage() -
waitForSpace
- Throws:
InterruptedException
-
waitForSpace
- Throws:
InterruptedException
-
waitForSpace
- Parameters:
timeout
-- Returns:
- true if space
- Throws:
InterruptedException
-
isFull
public boolean isFull() -
isFull
public boolean isFull(int highWaterMark) -
addUsageListener
-
removeUsageListener
-
getNumUsageListeners
public int getNumUsageListeners() -
getLimit
public long getLimit() -
setLimit
public void setLimit(long limit) Sets the memory limit in bytes. Setting the limit in bytes will set the usagePortion to 0 since the UsageManager is not going to be portion based off the parent. When set using Xbean, values of the form "20 Mb", "1024kb", and "1g" can be used -
onLimitChange
protected void onLimitChange() -
getUsagePortion
public float getUsagePortion() -
setUsagePortion
public void setUsagePortion(float usagePortion) -
getPercentUsage
public int getPercentUsage() -
getPercentUsageMinDelta
public int getPercentUsageMinDelta() -
setPercentUsageMinDelta
public void setPercentUsageMinDelta(int percentUsageMinDelta) Sets the minimum number of percentage points the usage has to change before a UsageListener event is fired by the manager.- Parameters:
percentUsageMinDelta
-
-
getUsage
public long getUsage() -
setPercentUsage
protected void setPercentUsage(int value) -
caclPercentUsage
protected int caclPercentUsage() -
getName
-
toString
-
start
public void start() -
stop
public void stop() -
addChild
-
removeChild
-
notifyCallbackWhenNotFull
- Parameters:
callback
-- Returns:
- true if the UsageManager was full. The callback will only be called if this method returns true.
-
getLimiter
- Returns:
- the limiter
-
setLimiter
- Parameters:
limiter
- the limiter to set
-
getPollingTime
public int getPollingTime()- Returns:
- the pollingTime
-
setPollingTime
public void setPollingTime(int pollingTime) - Parameters:
pollingTime
- the pollingTime to set
-
setName
-
getParent
-
setParent
-
setExecutor
-
getExecutor
-
isStarted
public boolean isStarted()
-