Package org.apache.activemq.usage
Class MemoryUsage
- All Implemented Interfaces:
Service
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
Fields inherited from class org.apache.activemq.usage.Usage
name, parent, percentUsage, usageLock, waitForSpaceCondition -
Constructor Summary
ConstructorsConstructorDescriptionMemoryUsage(String name) MemoryUsage(MemoryUsage parent) Create the memory manager linked to a parent.MemoryUsage(MemoryUsage parent, String name) MemoryUsage(MemoryUsage parent, String name, float portion) -
Method Summary
Modifier and TypeMethodDescriptionvoiddecreaseUsage(long value) Decreases the usage by the value amount.voidenqueueUsage(long value) Tries to increase the usage by value amount but blocks if this object is currently full.longgetUsage()voidincreaseUsage(long value) Increases the usage by the value amount.booleanisFull()protected longvoidsetPercentOfJvmHeap(int percentOfJvmHeap) voidsetUsage(long usage) voidbooleanwaitForSpace(long timeout) Methods inherited from class org.apache.activemq.usage.Usage
addChild, addUsageListener, caclPercentUsage, getExecutor, getLimit, getLimiter, getName, getNumUsageListeners, getParent, getPercentUsage, getPercentUsageMinDelta, getPollingTime, getUsagePortion, isFull, isStarted, notifyCallbackWhenNotFull, onLimitChange, removeChild, removeUsageListener, setExecutor, setLimit, setLimiter, setName, setParent, setPercentUsage, setPercentUsageMinDelta, setPollingTime, setUsagePortion, start, stop, toString, waitForSpace
-
Constructor Details
-
MemoryUsage
public MemoryUsage() -
MemoryUsage
Create the memory manager linked to a parent. When the memory manager is linked to a parent then when usage increased or decreased, the parent's usage is also increased or decreased.- Parameters:
parent-
-
MemoryUsage
-
MemoryUsage
-
MemoryUsage
-
-
Method Details
-
waitForSpace
- Overrides:
waitForSpacein classUsage<MemoryUsage>- Throws:
InterruptedException
-
waitForSpace
- Overrides:
waitForSpacein classUsage<MemoryUsage>- Parameters:
timeout-- Returns:
- true if space
- Throws:
InterruptedException
-
isFull
public boolean isFull()- Overrides:
isFullin classUsage<MemoryUsage>
-
enqueueUsage
Tries to increase the usage by value amount but blocks if this object is currently full.- Parameters:
value-- Throws:
InterruptedException
-
increaseUsage
public void increaseUsage(long value) Increases the usage by the value amount.- Parameters:
value-
-
decreaseUsage
public void decreaseUsage(long value) Decreases the usage by the value amount.- Parameters:
value-
-
retrieveUsage
protected long retrieveUsage()- Specified by:
retrieveUsagein classUsage<MemoryUsage>
-
getUsage
public long getUsage()- Overrides:
getUsagein classUsage<MemoryUsage>
-
setUsage
public void setUsage(long usage) -
setPercentOfJvmHeap
public void setPercentOfJvmHeap(int percentOfJvmHeap)
-