Class FauxMemoryMonitor
- java.lang.Object
-
- mondrian.util.FauxMemoryMonitor
-
- All Implemented Interfaces:
MemoryMonitor
public class FauxMemoryMonitor extends Object implements MemoryMonitor
TheFauxMemoryMonitor
implements theMemoryMonitor
interface but does nothing: all methods are empty.- Since:
- Feb 03 2007
- Author:
- Richard M. Emberson
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface mondrian.util.MemoryMonitor
MemoryMonitor.Listener, MemoryMonitor.Test
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
addListener(MemoryMonitor.Listener listener)
Adds aListener
using the default threshold percentage.boolean
addListener(MemoryMonitor.Listener listener, int thresholdPercentage)
Adds aListener
to theMemoryMonitor
with a given threshold percentage.long
getMaxMemory()
Returns the maximum memory usage.long
getUsedMemory()
Returns the current memory used.void
removeAllListener()
Clear out allListener
s and turnoff JVM memory notification.boolean
removeListener(MemoryMonitor.Listener listener)
Removes aListener
from theMemoryMonitor
.void
updateListenerThreshold(MemoryMonitor.Listener listener, int percentage)
Changes the threshold percentage of a givenListener
.
-
-
-
Method Detail
-
addListener
public boolean addListener(MemoryMonitor.Listener listener, int thresholdPercentage)
Description copied from interface:MemoryMonitor
Adds aListener
to theMemoryMonitor
with a given threshold percentage.If the threshold is below the Java5 memory managment system's threshold, then the Listener is notified from within this method.
- Specified by:
addListener
in interfaceMemoryMonitor
- Parameters:
listener
- theListener
to be added.thresholdPercentage
- the threshold percentage for thisListener
.- Returns:
true
if theListener
was added andfalse
otherwise.
-
addListener
public boolean addListener(MemoryMonitor.Listener listener)
Description copied from interface:MemoryMonitor
Adds aListener
using the default threshold percentage.If the threshold is below the Java5 memory managment system's threshold, then the Listener is notified from within this method.
- Specified by:
addListener
in interfaceMemoryMonitor
- Parameters:
listener
- theListener
to be added.- Returns:
true
if theListener
was added andfalse
otherwise.
-
updateListenerThreshold
public void updateListenerThreshold(MemoryMonitor.Listener listener, int percentage)
Description copied from interface:MemoryMonitor
Changes the threshold percentage of a givenListener
.If the new value is below the system's current value, then the
Listener
will have its notification callback called while in this method - so a client should always check if its notification method was called immediately after calling this method.This method can be used if, for example, an algorithm has different approaches that result in different memory usage profiles; one, large memory but fast and a second which is low-memory but slow. The algorithm starts with the large memory approach, receives a low memory notification, switches to the low memory approach and changes when it should be notified for this new approach. The first approach need to be notified at a lower percentage because it uses lots of memory, possibly quickly; while the second approach, possibly a file based algorithm, has smaller memory requirements and uses memory less quickly thus one can live with a higher notification threshold percentage.
- Specified by:
updateListenerThreshold
in interfaceMemoryMonitor
- Parameters:
listener
- theListener
being updated.percentage
- new percentage threshold.
-
removeListener
public boolean removeListener(MemoryMonitor.Listener listener)
Description copied from interface:MemoryMonitor
Removes aListener
from theMemoryMonitor
. Returnstrue
if listener was removed andfalse
otherwise.- Specified by:
removeListener
in interfaceMemoryMonitor
- Parameters:
listener
- the listener to be removed- Returns:
true
if listener was removed.
-
removeAllListener
public void removeAllListener()
Description copied from interface:MemoryMonitor
Clear out allListener
s and turnoff JVM memory notification.- Specified by:
removeAllListener
in interfaceMemoryMonitor
-
getMaxMemory
public long getMaxMemory()
Description copied from interface:MemoryMonitor
Returns the maximum memory usage.- Specified by:
getMaxMemory
in interfaceMemoryMonitor
- Returns:
- the maximum memory usage.
-
getUsedMemory
public long getUsedMemory()
Description copied from interface:MemoryMonitor
Returns the current memory used.- Specified by:
getUsedMemory
in interfaceMemoryMonitor
- Returns:
- the current memory used.
-
-