| org.jboss.mq.server.MessageCache
All known Subclasses: org.jboss.mq.kernel.MessageCache,
MessageCache | public class MessageCache extends ServiceMBeanSupport implements MessageCacheMBean,MBeanRegistration,Runnable(Code) | | This class implements a Message cache so that larger amounts of messages
can be processed without running out of memory. When memory starts getting tight
it starts moving messages out of memory and into a file so that they can be recovered
later.
The locks should be obtained in the following order:
mr, the relevent message we are working with
lruCache, when maintaining the usage order
author: Hiram Chirino author: David Maplesden author: Peter Antman author: Adrian Brock version: $Revision: 57198 $ |
Inner Class :class LRUCache | |
Inner Class :static class Node | |
Method Summary | |
public MessageReference | add(SpyMessage message, BasicQueue queue, int stored) Adds a message to the cache. | public MessageReference | add(SpyMessage message, BasicQueue queue, int stored, DurableSubscriptionID id) Adds a message to the cache. | public MessageReference | addInternal(SpyMessage message, BasicQueue queue, int stored, DurableSubscriptionID id) Adds a message to the cache. | public long | getCacheHits() | public long | getCacheMisses() | public ObjectName | getCacheStore() | public long | getCurrentMemoryUsage() | public int | getHardRefCacheSize() | public long | getHighMemoryMark() | public MessageCache | getInstance() | public boolean | getMakeSoftReferences() | public long | getMaxMemoryMark() | public int | getMaximumHard() | public int | getMinimumHard() | public String | getName() | public int | getSoftRefCacheSize() | public long | getSoftenAtLeastEveryMillis() | public long | getSoftenNoMoreOftenThanMillis() | public long | getSoftenWaitMillis() | public long | getSoftenedSize() | public int | getTotalCacheSize() | SpyMessage | loadFromStorage(MessageReference mh) | void | messageReferenceUsedEvent(MessageReference mh, boolean wasHard) This gets called when a MessageReference is de-referenced. | public void | remove(MessageReference mr) | public void | removeDelayed(MessageReference mr) | void | removeFromStorage(MessageReference mh) | protected void | removeInternal(MessageReference mr, boolean clear, boolean reset) | public void | run() The strategy is that we keep the most recently used messages as
Hard references. | void | saveToStorage(MessageReference mh, SpyMessage message) | public void | setCacheStore(ObjectName cacheStoreName) | public void | setHighMemoryMark(long highMemoryMark) | public void | setMakeSoftReferences(boolean makeSoftReferences) | public void | setMaxMemoryMark(long maxMemoryMark) | public void | setMaximumHard(int maximumHard) | public void | setMinimumHard(int minimumHard) | public void | setSoftenAtLeastEveryMillis(long millis) | public void | setSoftenNoMoreOftenThanMillis(long millis) | public void | setSoftenWaitMillis(long millis) | protected void | setupCacheStore() | void | soften(MessageReference mr) | protected void | startService() This gets called to start the cache service. | protected void | stopService() This gets called to stop the cache service. | boolean | validateSoftReferenceDepth() This method is in charge of determining if it time to convert some
hard references over to soft references. |
DEFAULT_HIGH_MEMORY_MARK | final public static long DEFAULT_HIGH_MEMORY_MARK(Code) | | |
DEFAULT_MAX_MEMORY_MARK | final public static long DEFAULT_MAX_MEMORY_MARK(Code) | | |
ONE_MEGABYTE | final public static long ONE_MEGABYTE(Code) | | |
cacheHits | long cacheHits(Code) | | |
cacheMisses | long cacheMisses(Code) | | |
checkSoftReferenceDepth | boolean checkSoftReferenceDepth(Code) | | |
softRefCacheSize | int softRefCacheSize(Code) | | |
softenedSize | long softenedSize(Code) | | |
totalCacheSize | int totalCacheSize(Code) | | |
getCacheHits | public long getCacheHits()(Code) | | Gets the cacheHits
Returns a long |
getCacheMisses | public long getCacheMisses()(Code) | | Gets the cacheMisses
Returns a int |
getCacheStore | public ObjectName getCacheStore()(Code) | | The getCacheStore method
an ObjectName value |
getCurrentMemoryUsage | public long getCurrentMemoryUsage()(Code) | | Gets the CurrentMemoryUsage
Returns a long |
getHardRefCacheSize | public int getHardRefCacheSize()(Code) | | Gets the hardRefCacheSize
Returns a int |
getHighMemoryMark | public long getHighMemoryMark()(Code) | | Gets the highMemoryMark
Returns a long |
getInstance | public MessageCache getInstance()(Code) | | The getInstance method
a MessageCache value |
getMakeSoftReferences | public boolean getMakeSoftReferences()(Code) | | Gets whether to make soft references
true when making soft references |
getMaxMemoryMark | public long getMaxMemoryMark()(Code) | | Gets the maxMemoryMark
Returns a long |
getMaximumHard | public int getMaximumHard()(Code) | | Gets the maximum number of hard messages
the minimum number of hard messages |
getMinimumHard | public int getMinimumHard()(Code) | | Gets the minimum number of hard messages
the minimum number of hard messages |
getName | public String getName()(Code) | | See Also: ServiceMBeanSupport.getName |
getSoftRefCacheSize | public int getSoftRefCacheSize()(Code) | | Gets the softRefCacheSize
Returns a int |
getSoftenAtLeastEveryMillis | public long getSoftenAtLeastEveryMillis()(Code) | | Gets the maximum length between softening checks
the time |
getSoftenNoMoreOftenThanMillis | public long getSoftenNoMoreOftenThanMillis()(Code) | | Gets the minimum length between softening checks
the time to wait |
getSoftenWaitMillis | public long getSoftenWaitMillis()(Code) | | Gets the length of time to wait before checking whether we should soften
the time to wait |
getSoftenedSize | public long getSoftenedSize()(Code) | | The getSoftenedSize method
a long value |
getTotalCacheSize | public int getTotalCacheSize()(Code) | | Gets the totalCacheSize
Returns a int |
messageReferenceUsedEvent | void messageReferenceUsedEvent(MessageReference mh, boolean wasHard) throws JMSException(Code) | | This gets called when a MessageReference is de-referenced.
We will pop it to the top of the RLU
|
removeDelayed | public void removeDelayed(MessageReference mr) throws JMSException(Code) | | removes a message from the cache without returning it to the pool
used in two phase removes for joint cache/persistence
|
removeInternal | protected void removeInternal(MessageReference mr, boolean clear, boolean reset) throws JMSException(Code) | | removes a message from the cache
|
run | public void run()(Code) | | The strategy is that we keep the most recently used messages as
Hard references. Then we make the older ones soft references. Making
something a soft reference stores it to disk so we need to avoid making
soft references if we can avoid it. But once it is made a soft reference does
not mean that it is removed from memory. Depending on how agressive the JVM's
GC is, it may stay around long enough for it to be used by a client doing a read,
saving us read from the file system. If memory gets tight the GC will remove
the soft references. What we want to do is make sure there are at least some
soft references available so that the GC can reclaim memory.
See Also: Runnable.run |
setHighMemoryMark | public void setHighMemoryMark(long highMemoryMark)(Code) | | Sets the highMemoryMark
Parameters: highMemoryMark - The highMemoryMark to set |
setMakeSoftReferences | public void setMakeSoftReferences(boolean makeSoftReferences)(Code) | | Sets whether to make soft references
true to make soft references |
setMaxMemoryMark | public void setMaxMemoryMark(long maxMemoryMark)(Code) | | Sets the maxMemoryMark
Parameters: maxMemoryMark - The maxMemoryMark to set |
setMaximumHard | public void setMaximumHard(int maximumHard)(Code) | | Sets the maximum number of hard messages
Parameters: maximumHard - the maximum number of hard messages |
setMinimumHard | public void setMinimumHard(int minimumHard)(Code) | | Sets the minimum number of hard messages
Parameters: minimumHard - the minimum number of hard messages |
setSoftenAtLeastEveryMillis | public void setSoftenAtLeastEveryMillis(long millis)(Code) | | Sets the minimum length between softening checks
Parameters: wait - the time between checks |
setSoftenNoMoreOftenThanMillis | public void setSoftenNoMoreOftenThanMillis(long millis)(Code) | | Sets the minimum length between softening checks
Parameters: wait - the time between checks |
setSoftenWaitMillis | public void setSoftenWaitMillis(long millis)(Code) | | Sets the length of time to wait before checking whether we should soften
Parameters: millis - the time to wait in millis |
soften | void soften(MessageReference mr) throws JMSException(Code) | | removes a message from the cache but does not clear it,
used in softening
|
startService | protected void startService() throws Exception(Code) | | This gets called to start the cache service. Synch. by start
|
stopService | protected void stopService()(Code) | | This gets called to stop the cache service.
|
validateSoftReferenceDepth | boolean validateSoftReferenceDepth() throws JMSException(Code) | | This method is in charge of determining if it time to convert some
hard references over to soft references.
|
|
|