Package org.apache.activemq.usage
Class MemoryUsage
- java.lang.Object
-
- org.apache.activemq.usage.Usage<MemoryUsage>
-
- org.apache.activemq.usage.MemoryUsage
-
- All Implemented Interfaces:
Service
public class MemoryUsage extends Usage<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
-
Fields inherited from class org.apache.activemq.usage.Usage
name, parent, percentUsage, usageLock, waitForSpaceCondition
-
-
Constructor Summary
Constructors Constructor Description MemoryUsage()MemoryUsage(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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddecreaseUsage(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 longretrieveUsage()voidsetPercentOfJvmHeap(int percentOfJvmHeap)voidsetUsage(long usage)voidwaitForSpace()booleanwaitForSpace(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 Detail
-
MemoryUsage
public MemoryUsage()
-
MemoryUsage
public MemoryUsage(MemoryUsage parent)
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
public MemoryUsage(String name)
-
MemoryUsage
public MemoryUsage(MemoryUsage parent, String name)
-
MemoryUsage
public MemoryUsage(MemoryUsage parent, String name, float portion)
-
-
Method Detail
-
waitForSpace
public void waitForSpace() throws InterruptedException- Overrides:
waitForSpacein classUsage<MemoryUsage>- Throws:
InterruptedException
-
waitForSpace
public boolean waitForSpace(long timeout) throws InterruptedException- Overrides:
waitForSpacein classUsage<MemoryUsage>- Parameters:
timeout-- Returns:
- true if space
- Throws:
InterruptedException
-
isFull
public boolean isFull()
- Overrides:
isFullin classUsage<MemoryUsage>
-
enqueueUsage
public void enqueueUsage(long value) throws InterruptedExceptionTries 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)
-
-