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 void
decreaseUsage(long value)
Decreases the usage by the value amount.void
enqueueUsage(long value)
Tries to increase the usage by value amount but blocks if this object is currently full.long
getUsage()
void
increaseUsage(long value)
Increases the usage by the value amount.boolean
isFull()
protected long
retrieveUsage()
void
setPercentOfJvmHeap(int percentOfJvmHeap)
void
setUsage(long usage)
void
waitForSpace()
boolean
waitForSpace(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:
waitForSpace
in classUsage<MemoryUsage>
- Throws:
InterruptedException
-
waitForSpace
public boolean waitForSpace(long timeout) throws InterruptedException
- Overrides:
waitForSpace
in classUsage<MemoryUsage>
- Parameters:
timeout
-- Returns:
- true if space
- Throws:
InterruptedException
-
isFull
public boolean isFull()
- Overrides:
isFull
in classUsage<MemoryUsage>
-
enqueueUsage
public void enqueueUsage(long value) throws InterruptedException
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:
retrieveUsage
in classUsage<MemoryUsage>
-
getUsage
public long getUsage()
- Overrides:
getUsage
in classUsage<MemoryUsage>
-
setUsage
public void setUsage(long usage)
-
setPercentOfJvmHeap
public void setPercentOfJvmHeap(int percentOfJvmHeap)
-
-