|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.avalon.framework.logger.AbstractLogEnabled
org.apache.excalibur.store.impl.StoreJanitorImpl
public class StoreJanitorImpl
This class is a implentation of a StoreJanitor. Store classes can register to the StoreJanitor. When memory is too low, the StoreJanitor frees the registered caches until memory is normal.
A few parameters can be used:
cleanupthreadinterval
defines the maximum
cleanup interval. Cleanup interval then is determined based on the
memory fill rate: the faster memory is filled in, and the less free
memory is left, the shorter is the cleanup time.
Field Summary | |
---|---|
private boolean |
adaptiveThreadInterval
|
private boolean |
doRun
|
private boolean |
firstRun
Flag to ignore memory bursts during startup (1st janitor run) |
private double |
fraction
|
private int |
index
|
protected long |
interval
The calculated delay for the next checker run in ms |
protected long |
inUse
Amount of memory in use before sleep(). |
protected boolean |
invokeGC
Should the gc be called on low memory? |
private java.lang.Runtime |
jvm
|
private int |
maxHeapSize
|
private long |
maxRateOfChange
Used memory change rate in bytes per second |
private int |
minFreeMemory
|
private int |
minThreadInterval
|
private int |
priority
|
private boolean |
secondRun
Flag to ignore memory bursts during startup (2nd janitor run) |
private java.util.ArrayList |
storelist
|
private int |
threadInterval
|
Fields inherited from interface org.apache.excalibur.store.StoreJanitor |
---|
ROLE |
Constructor Summary | |
---|---|
StoreJanitorImpl()
|
Method Summary | |
---|---|
private int |
calcToFree(Store store)
This method claculates the number of Elements to be freememory out of the Cache. |
protected void |
checkMemory()
The "checker" thread checks if memory is running low in the jvm. |
private void |
freeMemory()
Round Robin alghorithm for freeing the registered caches. |
private void |
freePhysicalMemory()
This method forces the garbage collector |
private boolean |
getAdaptiveThreadInterval()
|
private int |
getIndex()
|
private java.lang.Runtime |
getJVM()
|
private int |
getMaxHeapSize()
|
private int |
getMinFreeMemory()
|
private int |
getPriority()
|
private java.util.ArrayList |
getStoreList()
|
private int |
getThreadInterval()
|
java.util.Iterator |
iterator()
This method return a java.util.Iterator of every registered stores The iterators returned is fail-fast: if list is structurally modified at any time after the iterator is created, in any way, the iterator will throw a ConcurrentModificationException. |
private long |
longDiv(long top,
long bottom)
|
protected long |
memoryInUse()
Calculate the JVM memory in use now. |
private boolean |
memoryLow()
Method to check if memory is running low in the JVM. |
private long |
minTimeToFill(long rate)
Calculate amount of time needed to fill all free memory with given fill rate. |
void |
parameterize(org.apache.avalon.framework.parameters.Parameters params)
Parameterize the StoreJanitorImpl. |
void |
register(Store store)
This method register the stores |
void |
run()
The "checker" thread loop. |
private void |
setIndex(int _index)
|
void |
start()
|
void |
stop()
|
void |
unregister(Store store)
This method unregister the stores |
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled |
---|
enableLogging, getLogger, setupLogger, setupLogger, setupLogger |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private int minFreeMemory
private int maxHeapSize
private int threadInterval
private int minThreadInterval
private boolean adaptiveThreadInterval
private int priority
private double fraction
protected boolean invokeGC
private java.lang.Runtime jvm
private java.util.ArrayList storelist
private int index
private boolean doRun
protected long inUse
memoryInUse()
private boolean firstRun
private boolean secondRun
protected long interval
private long maxRateOfChange
Constructor Detail |
---|
public StoreJanitorImpl()
Method Detail |
---|
public void parameterize(org.apache.avalon.framework.parameters.Parameters params) throws org.apache.avalon.framework.parameters.ParameterException
parameterize
in interface org.apache.avalon.framework.parameters.Parameterizable
params
- the Configuration of the application
org.apache.avalon.framework.parameters.ParameterException
public void start()
start
in interface org.apache.avalon.framework.activity.Startable
public void stop()
stop
in interface org.apache.avalon.framework.activity.Startable
public void run()
run
in interface java.lang.Runnable
protected void checkMemory()
private boolean memoryLow()
protected long memoryInUse()
private long minTimeToFill(long rate)
rate
- memory fill rate in time per bytes
private long longDiv(long top, long bottom)
public void register(Store store)
register
in interface StoreJanitor
store
- the store to be registeredpublic void unregister(Store store)
unregister
in interface StoreJanitor
store
- the store to be unregisteredpublic java.util.Iterator iterator()
iterator
in interface StoreJanitor
private void freeMemory()
private int calcToFree(Store store)
store
- the Store which was selected as victim
private void freePhysicalMemory()
private int getMinFreeMemory()
private int getMaxHeapSize()
private int getPriority()
private int getThreadInterval()
private boolean getAdaptiveThreadInterval()
private java.lang.Runtime getJVM()
private java.util.ArrayList getStoreList()
private void setIndex(int _index)
private int getIndex()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |