|
xmlBlaster 2.2.0 API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.xmlBlaster.engine.msgstore.cache.PersistenceCachePlugin
public class PersistenceCachePlugin
Implements a random access message storage.
The implementation uses internally a RAM and a JDBC map and handles the caching between those two.
I_MapTest
Field Summary | |
---|---|
private ContextNode |
contextNode
|
private ServerScope |
glob
|
private boolean |
isConnected
|
(package private) boolean |
isDown
|
private static java.util.logging.Logger |
log
|
private java.lang.Object |
mbeanHandle
My JMX registration |
private java.lang.String |
ME
|
private I_Map |
persistentStore
|
private PluginInfo |
pluginInfo
|
private QueuePropertyBase |
property
|
private StorageId |
storageId
|
private StorageSizeListenerHelper |
storageSizeListenerHelper
|
private I_Map |
transientStore
|
Fields inherited from interface org.xmlBlaster.util.queue.I_StorageProblemListener |
---|
AVAILABLE, UNAVAILABLE, UNDEF |
Constructor Summary | |
---|---|
PersistenceCachePlugin()
|
Method Summary | |
---|---|
void |
addStorageSizeListener(I_StorageSizeListener listener)
Adds a storage size listener to the storage. |
private void |
assureTransientSpace(I_MapEntry mapEntry)
Swap an entry away to hard disk. |
I_MapEntry |
change(I_MapEntry oldEntry,
I_ChangeCallback callback)
|
I_MapEntry |
change(long uniqueId,
I_ChangeCallback callback)
This method is threadsafe because it makes a lookup for the updated entry within the synchronization point. |
java.lang.String |
checkConsistency(java.lang.String fixIt,
java.lang.String reportFileName)
Check if all messages in the storage are referenced by queue entries (history and callback queue). |
long |
clear()
Clears everything and removes the queue (i.e. |
private QueuePropertyBase |
createRamCopy(QueuePropertyBase queuePropertyBase)
We set the cache props to the real props for RAM queue running under a cacheQueue |
void |
destroy()
destroys all the resources associated to this queue. |
java.lang.String |
dumpEmbeddedObjectsToFile(java.lang.String fileName)
Dump all entries of this map to a file. |
long |
embeddedObjectsToXml(java.io.OutputStream out,
java.util.Properties props)
Dump all entries of this map to the given output stream. |
I_MapEntry |
get(long uniqueId)
Lookup entry without removing. |
I_MapEntry[] |
getAll(I_EntryFilter entryFilter)
Access all entries. |
PluginInfo |
getInfo()
Enforced by I_StoragePlugin |
long |
getMaxNumOfBytes()
returns the capacity (maximum bytes) for this queue |
long |
getMaxNumOfBytesCache()
returns the cache capacity (maximum bytes) for this storage |
long |
getMaxNumOfEntries()
returns the maximum number of elements for this store |
long |
getMaxNumOfEntriesCache()
returns the maximum number of cached elements for this store |
long |
getNumOfBytes()
Returns the amount of bytes currently in the storage If the implementation of this interface is not able to return the correct number of entries (for example if the implementation must make a remote call to a DB which is temporarly not available) it will return -1. |
long |
getNumOfCachedBytes()
Returns the amount of bytes currently in the RAM part of the storage |
long |
getNumOfCachedEntries()
Returns the number of elements in the RAM part of this storage. |
long |
getNumOfEntries()
It returns the size of the queue. |
long |
getNumOfPersistentBytes()
Returns the amount of bytes used by the persistent entries in the queue If the implementation of this interface is not able to return the correct number of entries (for example if the implementation must make a remote call to a DB which is temporarly not available) it will return -1. |
long |
getNumOfPersistentEntries()
It returns the size of persistent entries in the queue. |
java.lang.Object |
getProperties()
Access the current queue configuration |
java.lang.String |
getPropertyStr()
Access the current queue configuration. |
java.lang.String |
getQueueName()
Returns the unique ID of this queue as found in the database XB_ENTRIES.queueName column. |
StorageId |
getStorageId()
Returns the unique ID of this queue |
I_StorageSizeListener[] |
getStorageSizeListeners()
|
java.lang.String |
getType()
Enforced by I_Plugin |
java.lang.String |
getUsageUrl()
|
java.lang.String |
getVersion()
Enforced by I_Plugin |
boolean |
hasStorageSizeListener(I_StorageSizeListener listener)
Checks wether the specified listener is registered. |
void |
init(Global glob,
PluginInfo pluginInfo)
Enforced by I_Plugin |
void |
initialize(StorageId uniqueQueueId,
java.lang.Object userData)
Is called after the instance is created. |
boolean |
isShutdown()
Is the storage available? |
boolean |
isTransient()
|
private long |
numSwapped()
|
int |
put(I_MapEntry mapEntry)
All entries are stored into the transient queue. |
boolean |
registerStorageProblemListener(I_StorageProblemListener listener)
registers a new listener to be notified. |
int |
remove(I_MapEntry mapEntry)
|
int |
remove(long uniqueId)
|
int |
removeById(long uniqueId)
Remove the specified storage entry. |
private int |
removeNoNotify(I_MapEntry mapEntry)
|
I_MapEntry |
removeOldest()
Remove the oldest entry. |
java.lang.String |
removeOldestEntry()
Remove the oldest storage entry from cache. |
void |
removeStorageSizeListener(I_StorageSizeListener listener)
Removes the specified listener from the queue. |
int |
removeTransient()
|
int |
removeTransientEntries()
Removes all the transient entries (the ones which have the flag 'persistent' set to false. |
private java.lang.String |
setMaxNum(boolean setBytes,
boolean setCache,
long max)
|
java.lang.String |
setMaxNumOfBytes(long max)
Increase the max number of bytes persistently. |
java.lang.String |
setMaxNumOfBytesCache(long max)
Increase the max number of bytes of the cached part persistently. |
java.lang.String |
setMaxNumOfEntries(long max)
Increase the max number of entries persistently. |
java.lang.String |
setMaxNumOfEntriesCache(long max)
Increase the max number of entries of the cached part persistently. |
void |
setProperties(java.lang.Object userData)
Allows to overwrite properties which where passed on initialize() The properties which support hot configuration are depending on the used implementation |
void |
setUsageUrl(java.lang.String url)
|
void |
shutdown()
Shutdown the implementation, sync with data store |
private boolean |
spaceLeft(I_MapEntry mapEntry,
I_Map map)
Check is storage is big enough for entry |
private XmlBlasterException |
spaceLeftException(I_MapEntry mapEntry,
I_Map map)
Check is storage is big enough for entry |
void |
storageAvailable(int oldStatus)
Triggered by persistent store (JDBC) on reconnection |
void |
storageUnavailable(int oldStatus)
Triggered by persistent store (JDBC) on lost connection |
java.lang.String |
toXml(java.lang.String extraOffset)
|
boolean |
unRegisterStorageProblemListener(I_StorageProblemListener listener)
unregisters a listener. |
void |
updateCounters(I_MapEntry entry)
|
java.lang.String |
usage()
JMX help |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private java.lang.String ME
private ContextNode contextNode
private ServerScope glob
private static java.util.logging.Logger log
private QueuePropertyBase property
boolean isDown
private StorageId storageId
private I_Map transientStore
private I_Map persistentStore
private boolean isConnected
private PluginInfo pluginInfo
private java.lang.Object mbeanHandle
private StorageSizeListenerHelper storageSizeListenerHelper
Constructor Detail |
---|
public PersistenceCachePlugin()
Method Detail |
---|
public void storageUnavailable(int oldStatus)
storageUnavailable
in interface I_StorageProblemListener
oldStatus
- the status before the storage became unavailable.I_ConnectionListener.disconnected()
public boolean isTransient()
isTransient
in interface I_Storage
public void storageAvailable(int oldStatus)
storageAvailable
in interface I_StorageProblemListener
I_StorageProblemListener.storageAvailable(int)
public void initialize(StorageId uniqueQueueId, java.lang.Object userData) throws XmlBlasterException
initialize
in interface I_Map
uniqueQueueId
- A unique name, allowing to create a unique name for a persistent store (e.g. file name)userData
- For example a Properties object or a String[] args object passing the configuration data
XmlBlasterException
I_Map.initialize(StorageId, Object)
public java.lang.String getQueueName()
I_AdminMap
getQueueName
in interface I_AdminMap
public int removeById(long uniqueId) throws java.lang.Exception
I_AdminMap
removeById
in interface I_AdminMap
uniqueId
- The entry identifier
java.lang.Exception
public java.lang.String removeOldestEntry() throws java.lang.Exception
I_AdminMap
removeOldestEntry
in interface I_AdminMap
java.lang.Exception
public int removeTransientEntries() throws java.lang.Exception
I_AdminMap
removeTransientEntries
in interface I_AdminMap
java.lang.Exception
private QueuePropertyBase createRamCopy(QueuePropertyBase queuePropertyBase)
public void setProperties(java.lang.Object userData) throws XmlBlasterException
I_Map
setProperties
in interface I_Map
XmlBlasterException
I_Map.setProperties(Object)
public java.lang.Object getProperties()
getProperties
in interface I_Map
public java.lang.String getPropertyStr()
I_AdminMap
getPropertyStr
in interface I_AdminMap
public int put(I_MapEntry mapEntry) throws XmlBlasterException
put
in interface I_Map
XmlBlasterException
- in case an error occurs. Possible causes of
error can be a communication exception of the underlying implementation (jdbc, file system etc).I_Map.put(I_MapEntry)
private void assureTransientSpace(I_MapEntry mapEntry) throws XmlBlasterException
mapEntry
- The new entry which needs space for itself.
XmlBlasterException
private XmlBlasterException spaceLeftException(I_MapEntry mapEntry, I_Map map)
mapEntry
- may not be null
private boolean spaceLeft(I_MapEntry mapEntry, I_Map map)
mapEntry
- may not be null
public StorageId getStorageId()
getStorageId
in interface I_Storage
public I_MapEntry get(long uniqueId) throws XmlBlasterException
I_Map
get
in interface I_Map
XmlBlasterException
I_Map.get(long)
public I_MapEntry[] getAll(I_EntryFilter entryFilter) throws XmlBlasterException
getAll
in interface I_Map
entryFilter
- null to get everything. If specified you can filter by this
callback the wanted entries.
XmlBlasterException
I_Map#getAll()
private int removeNoNotify(I_MapEntry mapEntry) throws XmlBlasterException
XmlBlasterException
I_Map.remove(I_MapEntry)
public int remove(I_MapEntry mapEntry) throws XmlBlasterException
remove
in interface I_Map
XmlBlasterException
I_Map.remove(I_MapEntry)
public int remove(long uniqueId) throws XmlBlasterException
remove
in interface I_Map
XmlBlasterException
I_Map.remove(long)
public I_MapEntry removeOldest() throws XmlBlasterException
I_Map
removeOldest
in interface I_Map
XmlBlasterException
I_Map.removeOldest()
public int removeTransient() throws XmlBlasterException
XmlBlasterException
I_Map#removeTransient()
private long numSwapped()
public long getNumOfEntries()
getNumOfEntries
in interface I_AdminMap
getNumOfEntries
in interface I_Storage
I_Storage.getNumOfEntries()
public long getNumOfCachedEntries()
I_AdminMap
getNumOfCachedEntries
in interface I_AdminMap
I_AdminMap.getNumOfCachedEntries()
public long getNumOfPersistentEntries()
getNumOfPersistentEntries
in interface I_Map
getNumOfPersistentEntries
in interface I_AdminMap
I_Map.getNumOfPersistentEntries()
public long getMaxNumOfEntries()
I_AdminMap
getMaxNumOfEntries
in interface I_AdminMap
getMaxNumOfEntries
in interface I_Storage
I_Storage.getMaxNumOfEntries()
public long getMaxNumOfEntriesCache()
I_AdminMap
getMaxNumOfEntriesCache
in interface I_AdminMap
I_Map#getMaxNumOfEntriesCache()
public long getNumOfBytes()
I_AdminMap
getNumOfBytes
in interface I_AdminMap
getNumOfBytes
in interface I_Storage
I_Storage.getNumOfBytes()
public long getNumOfCachedBytes()
I_AdminMap
getNumOfCachedBytes
in interface I_AdminMap
I_AdminMap.getNumOfCachedBytes()
public long getNumOfPersistentBytes()
I_Map
getNumOfPersistentBytes
in interface I_Map
getNumOfPersistentBytes
in interface I_AdminMap
I_Map.getNumOfPersistentBytes()
public java.lang.String setMaxNumOfBytes(long max)
I_AdminMap
setMaxNumOfBytes
in interface I_AdminMap
I_AdminMap.setMaxNumOfBytes(long)
public java.lang.String setMaxNumOfBytesCache(long max)
I_AdminMap
setMaxNumOfBytesCache
in interface I_AdminMap
I_AdminMap.setMaxNumOfBytesCache(long)
public java.lang.String setMaxNumOfEntries(long max)
I_AdminMap
setMaxNumOfEntries
in interface I_AdminMap
I_AdminMap.setMaxNumOfEntries(long)
public java.lang.String setMaxNumOfEntriesCache(long max)
I_AdminMap
setMaxNumOfEntriesCache
in interface I_AdminMap
I_AdminMap.setMaxNumOfEntriesCache(long)
private java.lang.String setMaxNum(boolean setBytes, boolean setCache, long max)
public long getMaxNumOfBytes()
I_Map
getMaxNumOfBytes
in interface I_Map
getMaxNumOfBytes
in interface I_AdminMap
I_Map.getMaxNumOfBytes()
public long getMaxNumOfBytesCache()
I_AdminMap
getMaxNumOfBytesCache
in interface I_AdminMap
I_Map#getMaxNumOfBytesCache()
public long clear()
clear
in interface I_Map
clear
in interface I_AdminMap
public void shutdown()
shutdown
in interface I_Map
shutdown
in interface I_AdminMap
shutdown
in interface I_AdminPlugin
shutdown
in interface I_Plugin
public boolean isShutdown()
I_AdminMap
isShutdown
in interface I_AdminMap
isShutdown
in interface I_AdminPlugin
isShutdown
in interface I_Storage
public java.lang.String usage()
usage
in interface I_Map
usage
in interface I_AdminMap
usage
in interface I_AdminUsage
public java.lang.String getUsageUrl()
getUsageUrl
in interface I_AdminUsage
public void setUsageUrl(java.lang.String url)
setUsageUrl
in interface I_AdminUsage
public final java.lang.String toXml(java.lang.String extraOffset)
toXml
in interface I_Map
extraOffset
- Indent the dump with given ASCII blanks
public void init(Global glob, PluginInfo pluginInfo)
init
in interface I_Plugin
I_Plugin.init(org.xmlBlaster.util.Global, PluginInfo)
public java.lang.String getType()
getType
in interface I_AdminPlugin
getType
in interface I_Plugin
public java.lang.String getVersion()
getVersion
in interface I_AdminPlugin
getVersion
in interface I_Plugin
public PluginInfo getInfo()
getInfo
in interface I_StoragePlugin
public java.lang.String checkConsistency(java.lang.String fixIt, java.lang.String reportFileName)
I_AdminMap
checkConsistency
in interface I_AdminMap
fixIt
- "true": Unreferenced entries are deleted (ignoring case); else check is readonly,reportFileName
- The file name to dump the details
public void destroy() throws XmlBlasterException
destroy
in interface I_Map
XmlBlasterException
public boolean registerStorageProblemListener(I_StorageProblemListener listener)
I_StorageProblemNotifier
registerStorageProblemListener
in interface I_StorageProblemNotifier
I_StorageProblemNotifier.registerStorageProblemListener(I_StorageProblemListener)
public boolean unRegisterStorageProblemListener(I_StorageProblemListener listener)
I_StorageProblemNotifier
unRegisterStorageProblemListener
in interface I_StorageProblemNotifier
I_StorageProblemNotifier.unRegisterStorageProblemListener(I_StorageProblemListener)
public I_MapEntry change(I_MapEntry oldEntry, I_ChangeCallback callback) throws XmlBlasterException
change
in interface I_Map
oldEntry
- the entry to change. This is the old entry, i.e. the entry on which the modification
has to take place by callback.
Or it is the new entry and you can pass null for callback.
IMPORTANT: This method is not threadsafe since it does not make a lookup
to get the actual entry. The specified entry could be a dirty read, in which case the
current entry would be overwritten with this dirty value. If you want to work threadsafe
you should invoke change(long, callback). That method makes a lookup within the same
synchronization point.callback
- the object on which the callback method 'changeEntry' is invoked. The modification
of the object is done in that method. If you pass null, then the changeEntry is not invoked
and the processing continues with entry.
XmlBlasterException
- if something goes wrong when making the change (for example if the
entry is not in the map) or if the callback throws an exception.I_Map.change(I_MapEntry, I_ChangeCallback)
public void updateCounters(I_MapEntry entry) throws XmlBlasterException
updateCounters
in interface I_Map
entry
- the entry to change. This is the old entry, i.e. the entry on which the modification
has to take place by callback.
Or it is the new entry and you can pass null for callback.
IMPORTANT: This method is not threadsafe since it does not make a lookup
to get the actual entry. The specified entry could be a dirty read, in which case the
current entry would be overwritten with this dirty value. If you want to work threadsafe
you should invoke change(long, callback). That method makes a lookup within the same
synchronization point.
XmlBlasterException
- if something goes wrong when making the change (for example if the
entry is not in the map) or if the callback throws an exception.I_Map.change(I_MapEntry, I_ChangeCallback)
public I_MapEntry change(long uniqueId, I_ChangeCallback callback) throws XmlBlasterException
I_Map
change
in interface I_Map
uniqueId
- the uniqueId of the entry to change. This is the old entry, i.e. the entry on
which the modification has to take place.callback
- the object on which the callback method 'changeEntry' is invoked. The modification
of the object is done in that method. If you pass null, then the changeEntry is not invoked
and the processing continues with entry.
XmlBlasterException
- if something goes wrong when making the change (for example if the
entry is not in the map) or if the callback throws an exception.I_Map.change(long, I_ChangeCallback)
public long embeddedObjectsToXml(java.io.OutputStream out, java.util.Properties props) throws java.lang.Exception
I_Map
embeddedObjectsToXml
in interface I_Map
out
- The output stream to dump the entriesprops
- Configuration properties, not yet specified, just pass null
java.lang.Exception
I_Map.embeddedObjectsToXml(OutputStream, Properties)
public java.lang.String dumpEmbeddedObjectsToFile(java.lang.String fileName) throws java.lang.Exception
I_AdminMap
dumpEmbeddedObjectsToFile
in interface I_AdminMap
fileName
- The file name to dump, may contain a path.
java.lang.Exception
I_AdminMap.dumpEmbeddedObjectsToFile(String)
public void addStorageSizeListener(I_StorageSizeListener listener)
I_Storage
addStorageSizeListener
in interface I_Storage
listener
- the listener to be added, adding the same listener multiple times will only remember one and fire onceI_Storage.addStorageSizeListener(I_StorageSizeListener)
public void removeStorageSizeListener(I_StorageSizeListener listener)
I_Storage
removeStorageSizeListener
in interface I_Storage
listener
- the listener to be removed. Currently only one.
If you pass null, all queueSizeListeners are removed.I_Storage.removeStorageSizeListener(I_StorageSizeListener)
public boolean hasStorageSizeListener(I_StorageSizeListener listener)
I_Storage
hasStorageSizeListener
in interface I_Storage
listener
- the listener to check against. If you pass null
it checks if at least one listener exists.
I_Storage.hasStorageSizeListener(I_StorageSizeListener)
public I_StorageSizeListener[] getStorageSizeListeners()
getStorageSizeListeners
in interface I_Storage
I_Storage.getStorageSizeListeners()
|
xmlBlaster 2.2.0 API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |