org.apache.activemq.usage
Class MemoryUsage

java.lang.Object
  extended by org.apache.activemq.usage.Usage<MemoryUsage>
      extended by 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, usageMutex
 
Constructor Summary
MemoryUsage()
           
MemoryUsage(MemoryUsage parent)
          Create the memory manager linked to a parent.
MemoryUsage(MemoryUsage parent, String name)
           
MemoryUsage(MemoryUsage parent, String name, float portion)
           
MemoryUsage(String name)
           
 
Method Summary
 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 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, getParent, getPercentUsage, getPercentUsageMinDelta, getPollingTime, getUsagePortion, isFull, notifyCallbackWhenNotFull, onLimitChange, removeChild, removeUsageListener, setExecutor, setLimit, setLimiter, setName, setParent, setPercentUsage, setPercentUsageMinDelta, setPollingTime, setUsagePortion, start, stop, toString, waitForSpace
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

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 class Usage<MemoryUsage>
Throws:
InterruptedException

waitForSpace

public boolean waitForSpace(long timeout)
                     throws InterruptedException
Overrides:
waitForSpace in class Usage<MemoryUsage>
Parameters:
timeout -
Returns:
true if space
Throws:
InterruptedException

isFull

public boolean isFull()
Overrides:
isFull in class Usage<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 class Usage<MemoryUsage>

getUsage

public long getUsage()
Overrides:
getUsage in class Usage<MemoryUsage>

setUsage

public void setUsage(long usage)


Copyright © 2005-2012 The Apache Software Foundation. All Rights Reserved.