|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.cocoon.components.store.impl.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 | |
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? |
Fields inherited from interface org.apache.excalibur.store.StoreJanitor |
ROLE |
Constructor Summary | |
StoreJanitorImpl()
|
Method Summary | |
protected void |
checkMemory()
The "checker" thread checks if memory is running low in the jvm. |
void |
destroy()
|
Log |
getLogger()
|
void |
init()
Initialize the StoreJanitorImpl. |
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. |
protected long |
memoryInUse()
Calculate the JVM memory in use now. |
void |
register(Store store)
This method register the stores |
void |
run()
The "checker" thread loop. |
void |
setAdaptiveThreadInterval(boolean adaptiveThreadInterval)
Experimental adaptive algorithm for cleanup interval |
void |
setCleanupThreadInterval(int cleanupThreadInterval)
How often shall the cleanup thread check memory? If not specified, defaults to 10 seconds. |
void |
setFreeingAlgorithm(String algorithm)
|
void |
setFreeMemory(int freeMemory)
How much free memory shall be available in the jvm? If not specified, defaults to 1Mb. |
void |
setHeapSize(int heapSize)
How much memory at max jvm can consume? The default max heapsize for Sun's JVM is (almost) 64Mb, can be increased by specifying -Xmx command line parameter. |
void |
setInvokeGC(boolean invokeGC)
Shall garbage collector be invoked on low memory? If not specified, defaults to false. |
void |
setLogger(Log l)
|
void |
setPercentToFree(double percentToFree)
What percent of the store elements shall be dropped on low memory? If not specified, defaults to 10% |
void |
setThreadPriority(int threadPriority)
What should be the priority of the cleanup thread? This property is used only by older implementation of the janitor. |
void |
unregister(Store store)
This method unregister the stores |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected boolean invokeGC
protected long inUse
memoryInUse()
protected long interval
Constructor Detail |
public StoreJanitorImpl()
Method Detail |
public void setFreeMemory(int freeMemory)
freeMemory
- public void setHeapSize(int heapSize)
heapSize
- public void setCleanupThreadInterval(int cleanupThreadInterval)
cleanupThreadInterval
- public void setAdaptiveThreadInterval(boolean adaptiveThreadInterval)
adaptiveThreadInterval
- public void setPercentToFree(double percentToFree)
percentToFree
- public void setInvokeGC(boolean invokeGC)
invokeGC
- public void setThreadPriority(int threadPriority)
threadPriority
- public void setFreeingAlgorithm(String algorithm)
public Log getLogger()
public void setLogger(Log l)
public void init() throws Exception
Exception
public void destroy()
public void run()
run
in interface Runnable
protected void checkMemory()
protected long memoryInUse()
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 Iterator iterator()
iterator
in interface StoreJanitor
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |