|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectmondrian.util.AbstractMemoryMonitor
public abstract class AbstractMemoryMonitor
Abstract implementation of MemoryMonitor. Base class
for different memory monitoring strategies.
| Nested Class Summary | |
|---|---|
(package private) static class |
AbstractMemoryMonitor.Entry
Class used to associate Listener and threshold. |
| Nested classes/interfaces inherited from interface mondrian.util.MemoryMonitor |
|---|
MemoryMonitor.Listener, MemoryMonitor.Test |
| Constructor Summary | |
|---|---|
protected |
AbstractMemoryMonitor()
Constructor of this base class. |
| Method Summary | |
|---|---|
boolean |
addListener(MemoryMonitor.Listener listener)
Adds a Listener using the default threshold percentage. |
boolean |
addListener(MemoryMonitor.Listener listener,
int percentage)
Adds a Listener to the MemoryMonitor with
a given threshold percentage. |
protected long |
convertPercentageToThreshold(int percentage)
Converts a percentage threshold to its corresponding memory value, (percentage * maximum-memory / 100). |
protected int |
convertThresholdToPercentage(long threshold)
Converts a memory value to its percentage. |
protected long |
generateLowThreshold()
Returns the lowest threshold from the list of Listeners. |
int |
getDefaultThresholdPercentage()
Returns the default memory notification percentage. |
protected abstract org.apache.log4j.Logger |
getLogger()
Returns the Logger. |
protected long |
getLowThreshold()
Returns the current lowest threshold of all registered Listeners. |
protected void |
notifyListeners(long usedMemory,
long maxMemory)
Notifies all Listeners that memory is running short. |
protected void |
notifyNewLowThreshold(long newLowThreshold)
Derived classes implement this method if they wish to be notified when there is a new lowest threshold. |
void |
removeAllListener()
Clear out all Listeners and turnoff JVM
memory notification. |
boolean |
removeListener(MemoryMonitor.Listener listener)
Removes a Listener from the MemoryMonitor. |
void |
resetFromTest()
This should only be called when one is switching from a test MemoryMonitor back to the default system
MemoryMonitor. |
void |
updateListenerThreshold(MemoryMonitor.Listener listener,
int percentage)
Changes the threshold percentage of a given Listener. |
protected int |
usagePercentage()
Returns how much memory is currently being used as a percentage. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface mondrian.util.MemoryMonitor |
|---|
getMaxMemory, getUsedMemory |
| Constructor Detail |
|---|
protected AbstractMemoryMonitor()
| Method Detail |
|---|
protected abstract org.apache.log4j.Logger getLogger()
Logger.
Logger.protected long getLowThreshold()
Listeners.
public int getDefaultThresholdPercentage()
This is the value of the Mondrian
MondrianProperties.MemoryMonitorThreshold property.
public boolean addListener(MemoryMonitor.Listener listener)
MemoryMonitorListener 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.
addListener in interface MemoryMonitorlistener - the Listener to be added.
true if the Listener was
added and false otherwise.
public boolean addListener(MemoryMonitor.Listener listener,
int percentage)
MemoryMonitorListener to the MemoryMonitor 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.
addListener in interface MemoryMonitorlistener - the Listener to be added.percentage - the threshold percentage for this
Listener.
true if the Listener was
added and false otherwise.
public void updateListenerThreshold(MemoryMonitor.Listener listener,
int percentage)
MemoryMonitorListener.
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.
updateListenerThreshold in interface MemoryMonitorlistener - the Listener being updated.percentage - new percentage threshold.public boolean removeListener(MemoryMonitor.Listener listener)
MemoryMonitorListener from the MemoryMonitor.
Returns true if listener was removed and
false otherwise.
removeListener in interface MemoryMonitorlistener - the listener to be removed
true if listener was removed.public void removeAllListener()
MemoryMonitorListeners and turnoff JVM
memory notification.
removeAllListener in interface MemoryMonitorprotected long generateLowThreshold()
Listeners.
If there are no Listeners, then return the maximum
memory usage. Returns Long.MAX_VALUE if there
are no Listeners
Long.MAX_VALUE
protected void notifyListeners(long usedMemory,
long maxMemory)
Listeners that memory is running short.
usedMemory - the current memory used.maxMemory - the maximum memory.protected void notifyNewLowThreshold(long newLowThreshold)
newLowThreshold - the new low threshold.protected long convertPercentageToThreshold(int percentage)
percentage - the threshold.
protected int convertThresholdToPercentage(long threshold)
threshold - the memory value.
protected int usagePercentage()
public void resetFromTest()
MemoryMonitor.TestMemoryMonitor back to the default system
MemoryMonitor. In particular, look at
the MemoryMonitorFactory's
clearThreadLocalClassName() method for its
usage.
resetFromTest in interface MemoryMonitor.Test
|
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||