|
xmlBlaster 1.6.2 API | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectorg.xmlBlaster.util.queue.ram.RamQueuePlugin
Queueing messages in RAM only, sorted after priority and timestamp
| Field Summary | |
private MsgComparator |
comparator
|
private Global |
glob
|
private boolean |
isShutdown
|
private static java.util.logging.Logger |
log
|
private int |
MAX_PRIO
|
private java.lang.String |
ME
|
private boolean |
notifiedAboutAddOrRemove
|
private long |
numOfPersistentEntries
|
private long |
persistentSizeInBytes
|
private PluginInfo |
pluginInfo
|
private QueuePropertyBase |
property
|
private I_QueuePutListener |
putListener
|
private long |
sizeInBytes
|
private java.util.TreeSet |
storage
|
private StorageId |
storageId
|
private StorageSizeListenerHelper |
storageSizeListenerHelper
|
| Fields inherited from interface org.xmlBlaster.util.queue.I_Queue |
IGNORE_PUT_INTERCEPTOR, USE_PUT_INTERCEPTOR |
| Constructor Summary | |
RamQueuePlugin()
|
|
| Method Summary | |
void |
addPutListener(I_QueuePutListener l)
Register a listener which wants to be informed on put() events. |
void |
addStorageSizeListener(I_StorageSizeListener listener)
Adds a storage size listener to the storage. |
long |
clear()
Flush the queue |
void |
destroy()
destroys silently all the resources associated to this queue. |
long |
embeddedObjectsToXml(java.io.OutputStream out,
java.util.Properties props)
Dump all entries of this queue to the given output stream. |
private ReturnDataHolder |
genericPeek(int numOfEntries,
long numOfBytes,
int minPrio,
int maxPrio)
|
java.util.ArrayList |
getEntries(I_EntryFilter entryFilter)
Gets a copy of the entries (the messages) in the queue. |
long[] |
getEntryReferences()
Gets the references of the messages in the queue. |
PluginInfo |
getInfo()
Enforced by I_StoragePlugin |
long |
getMaxNumOfBytes()
Access the configured capacity (maximum bytes) for this queue |
long |
getMaxNumOfEntries()
Returns the maximum number of elements for this queue |
long |
getNumOfBytes()
Returns the amount of bytes currently 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 |
getNumOfEntries()
Returns the number of elements in this 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()
i |
java.lang.Object |
getProperties()
Access the current queue configuration |
StorageId |
getStorageId()
For verbose logging |
I_StorageSizeListener[] |
getStorageSizeListeners()
|
long |
getSynchronizedNumOfBytes()
Gets the number of bytes by really reading (i.e. |
java.lang.String |
getType()
Enforced by I_Plugin |
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. |
private boolean |
isInsideRange(int numEntries,
int maxNumEntries,
long numBytes,
long maxNumBytes)
Helper method to find out if still to retrieve entries in getAndDeleteLowest or not. |
boolean |
isNotifiedAboutAddOrRemove()
Defaults to false. |
boolean |
isShutdown()
Performs what has to be done when the Map Plugin shuts down. |
boolean |
isTransient()
|
I_QueueEntry |
peek()
Returns the first element in the queue but does not remove it from that queue (leaves it untouched). |
java.util.ArrayList |
peek(int numOfEntries,
long numOfBytes)
Returns maximum the first num element in the queue but does not remove it from that queue (leaves it untouched). |
java.util.ArrayList |
peekLowest(int numOfEntries,
long numOfBytes,
I_QueueEntry limitEntry,
boolean leaveOne)
Same as takeLowest but it does not remove the entries. |
java.util.ArrayList |
peekSamePriority(int numOfEntries,
long numOfBytes)
Returns maximum the first num element in the queue of highest priority but does not remove it from that queue (leaves it untouched). |
java.util.ArrayList |
peekWithLimitEntry(I_QueueEntry limitEntry)
It returns the entries which are higher than the entry specified in the argument list. |
java.util.ArrayList |
peekWithPriority(int numOfEntries,
long numOfBytes,
int minPrio,
int maxPrio)
Returns maximum given number of entries from the queue (none blocking). |
void |
put(I_QueueEntry[] msgArr,
boolean ignorePutInterceptor)
Put messages into the queue, blocks if take thread blocks synchronize |
void |
put(I_QueueEntry entry,
boolean ignorePutInterceptor)
Put a message into the queue, blocks if take thread blocks synchronize |
boolean |
registerStorageProblemListener(I_StorageProblemListener listener)
registers a new listener to be notified. |
int |
remove()
Removes the first element in the queue. |
long |
remove(long numOfEntries,
long numOfBytes)
Removes max num messages. |
long |
removeHead(I_QueueEntry toEntry)
removes the head of the queue until (but not included) the entry specified as the argument. |
void |
removePutListener(I_QueuePutListener l)
Remove the listener which wanted to be informed on put() events. |
int |
removeRandom(I_Entry entry)
Removes the given entry. |
boolean[] |
removeRandom(I_Entry[] queueEntries)
Removes the given entries. |
void |
removeStorageSizeListener(I_StorageSizeListener listener)
Removes the specified listener from the queue. |
int |
removeTransient()
|
long |
removeWithLimitEntry(I_QueueEntry limitEntry,
boolean inclusive)
It removes the entries which are higher than the entry specified in the argument list. |
long |
removeWithPriority(long numOfEntries,
long numOfBytes,
int minPriority,
int maxPriority)
Removes max numOfEntries messages (or less depending on the numOfBytes). |
void |
setNotifiedAboutAddOrRemove(boolean notify)
|
void |
setProperties(java.lang.Object userData)
Allows to overwrite properties which where passed on initialize(). |
void |
shutdown()
Shutdown the implementation, sync with data store, free resources. |
I_QueueEntry |
take()
Currently NOT supported by I_Queue. |
java.util.ArrayList |
take(int numOfEntries,
long numOfBytes)
Currently NOT supported by I_Queue. |
java.util.ArrayList |
takeLowest(int numOfEntries,
long numOfBytes,
I_QueueEntry limitEntry,
boolean leaveOne)
Takes entries from the back of the queue. |
private java.util.ArrayList |
takeOrPeekLowest(int numOfEntries,
long numOfBytes,
I_QueueEntry limitEntry,
boolean leaveOne,
boolean doDelete)
|
java.util.ArrayList |
takeSamePriority(int numOfEntries,
long numOfBytes)
|
java.util.ArrayList |
takeWithPriority(int numOfEntries,
long numOfBytes,
int minPriority,
int maxPriority)
Takes given number of entries out of the queue. |
java.lang.String |
toXml()
Dump state of this object into a XML ASCII string. |
java.lang.String |
toXml(java.lang.String extraOffset)
Dump state of this object into a XML ASCII string. |
boolean |
unRegisterStorageProblemListener(I_StorageProblemListener listener)
unregisters a listener. |
java.lang.String |
usage()
|
| 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 StorageId storageId
private boolean notifiedAboutAddOrRemove
private java.util.TreeSet storage
private QueuePropertyBase property
private Global glob
private static java.util.logging.Logger log
private I_QueuePutListener putListener
private boolean isShutdown
private MsgComparator comparator
private final int MAX_PRIO
private long sizeInBytes
private long persistentSizeInBytes
private long numOfPersistentEntries
private PluginInfo pluginInfo
private StorageSizeListenerHelper storageSizeListenerHelper
| Constructor Detail |
public RamQueuePlugin()
| Method Detail |
public void initialize(StorageId uniqueQueueId,
java.lang.Object userData)
throws XmlBlasterException
initialize in interface I_QueueuniqueQueueId - A unique name, allowing to create a unique name for a persistent store (e.g. file name)
"update:/node/heron/client/joe/2", "history:userData - For example a Properties object or a String[] args object passing the configuration data
Here we expect a QueuePropertyBase instance
XmlBlasterException
public void setProperties(java.lang.Object userData)
throws XmlBlasterException
capacity is immutable, if you try to change a warning is logged
setProperties in interface I_QueueXmlBlasterExceptionpublic java.lang.Object getProperties()
getProperties in interface I_Queuepublic boolean isTransient()
isTransient in interface I_Storagepublic void setNotifiedAboutAddOrRemove(boolean notify)
setNotifiedAboutAddOrRemove in interface I_Queuepublic boolean isNotifiedAboutAddOrRemove()
I_Queue
isNotifiedAboutAddOrRemove in interface I_Queuepublic void addPutListener(I_QueuePutListener l)
I_Queue
addPutListener in interface I_QueueI_Queue.addPutListener(I_QueuePutListener)public void removePutListener(I_QueuePutListener l)
I_Queue
removePutListener in interface I_QueueI_Queue.removePutListener(I_QueuePutListener)
public long[] getEntryReferences()
throws XmlBlasterException
getEntryReferences in interface I_QueueXmlBlasterExceptionI_Queue.getEntryReferences()
public java.util.ArrayList getEntries(I_EntryFilter entryFilter)
throws XmlBlasterException
getEntries in interface I_QueueentryFilter - if not null the you can control which entries to return
with the callback entryFilter.intercept(I_Entry).
XmlBlasterException - alwayspublic StorageId getStorageId()
getStorageId in interface I_Storagepublic void shutdown()
I_Queue
shutdown in interface I_Queuepublic boolean isShutdown()
I_Storage
isShutdown in interface I_Storagepublic long clear()
clear in interface I_Queue
public int remove()
throws XmlBlasterException
I_Queue
remove in interface I_QueueXmlBlasterException - if the underlying implementation gets an exception.I_Queue.remove()
public long remove(long numOfEntries,
long numOfBytes)
throws XmlBlasterException
I_Queue
remove in interface I_QueuenumOfEntries - Erase num entries or less if less entries are available, -1 erases everythingnumOfBytes - so many entries are returned as not to exceed the amount specified. If the first
entry is bigger than this amount, it is removed anyway.
XmlBlasterException - if the underlying implementation gets an exception.I_Queue.remove(long, long)
public long removeWithPriority(long numOfEntries,
long numOfBytes,
int minPriority,
int maxPriority)
throws XmlBlasterException
I_Queue
removeWithPriority in interface I_QueuenumOfEntries - Erase num entries or less if less entries are available, -1 erases everythingnumOfBytes - so many entries are returned as not to exceed the amout specified. If the first
entry is bigger than this amount, it is returned anyway.minPriority - The lower priority (inclusive), usually 0 lowest, 9 highestmaxPriority - The higher priority (inclusive), usually 0 lowest, 9 highest
XmlBlasterException - in case the underlying implementation gets an exception while retrieving the element.
public int removeTransient()
throws XmlBlasterException
XmlBlasterExceptionI_Queue#removeTransient()public I_QueueEntry peek()
I_Queue
peek in interface I_QueueI_Queue.peek()
public java.util.ArrayList peekWithPriority(int numOfEntries,
long numOfBytes,
int minPrio,
int maxPrio)
throws XmlBlasterException
I_Queue
peekWithPriority in interface I_QueueminPrio - Extension to I_Queue: if -1 then only entries with similar priority as the first one are taken (= peekSamePriority())numOfEntries - Access num entries, if -1 take all entries currently foundnumOfBytes - so many entries are returned as not to exceed the amount specified. If the first
entry is bigger than this amount, it is returned anyway.maxPrio - The higher priority (inclusive), usually 0 lowest, 9 highest, <0 is not allowed
XmlBlasterException - in case the underlying implementation gets an exception while retrieving the element.I_Queue.peek(int, long)
private ReturnDataHolder genericPeek(int numOfEntries,
long numOfBytes,
int minPrio,
int maxPrio)
throws XmlBlasterException
numOfEntries - the number of entries to peek. If -1 then all entries
found are peeked.numOfBytes - as input it is the size in bytes to retrieve.minPrio - the minimum priority to return. If a negative number, then
all entries which have the same priority as the first entry are returned.
this value is inclusive.maxPrio - the maximum priority to return (inclusive).
XmlBlasterException
public java.util.ArrayList peek(int numOfEntries,
long numOfBytes)
throws XmlBlasterException
I_Queue
peek in interface I_QueuenumOfEntries - Access num entries, if -1 access all entries currently foundnumOfBytes - is the maximum size in bytes of the array to return, -1 is unlimited .
XmlBlasterException - if the underlying implementation gets an exception.I_Queue.peek(int, long)
public java.util.ArrayList peekSamePriority(int numOfEntries,
long numOfBytes)
throws XmlBlasterException
I_Queue
peekSamePriority in interface I_QueuenumOfEntries - Access num entries, if -1 access all entries currently foundnumOfBytes - so many entries are returned as not to exceed the amount specified. If the first
entry is bigger than this amount, it is returned anyway. -1 is unlimited.
XmlBlasterException - if the underlying implementation gets an exception.I_Queue.peekSamePriority(int, long)
public java.util.ArrayList peekWithLimitEntry(I_QueueEntry limitEntry)
throws XmlBlasterException
I_Queue
peekWithLimitEntry in interface I_QueuelimitEntry - the entry which limits the peek. Only entries of higher order, i.e.
entries having a higher priority, or same priority and lower uniqueId are
returned. If entryLimit is null or no entries are higher than entryLimit,
an empty list is returned.
Note: The limitEntry does not need to be in the queue.
XmlBlasterExceptionI_Queue.peekWithLimitEntry(I_QueueEntry)
public long removeWithLimitEntry(I_QueueEntry limitEntry,
boolean inclusive)
throws XmlBlasterException
I_Queue
removeWithLimitEntry in interface I_QueuelimitEntry - the entry which limits the remove. Only entries of higher order, i.e.
entries having a higher priority, or same priority and lower uniqueId are
deleted. If entryLimit is null or no entries are higher than entryLimit,
an empty list is returned.inclusive - if 'true', then also the entry specified will be removed (if it exists). If false
the remove is exclusive, i.e. the specified entry is left in the queue.
Note: The limitEntry does not need to be in the queue.
XmlBlasterExceptionI_Queue.removeWithLimitEntry(I_QueueEntry, boolean)public long getNumOfEntries()
I_Storage
getNumOfEntries in interface I_StorageI_Storage.getNumOfEntries()public long getNumOfPersistentEntries()
getNumOfPersistentEntries in interface I_QueueI_Queue.getNumOfPersistentEntries()public long getMaxNumOfEntries()
I_Storage
getMaxNumOfEntries in interface I_StorageI_Storage.getMaxNumOfEntries()public long getNumOfBytes()
I_Storage
getNumOfBytes in interface I_StorageI_Storage.getNumOfBytes()public long getNumOfPersistentBytes()
I_Queue
getNumOfPersistentBytes in interface I_QueueI_Queue.getNumOfPersistentBytes()public long getSynchronizedNumOfBytes()
I_Storage.getNumOfBytes()public long getMaxNumOfBytes()
I_Queue
getMaxNumOfBytes in interface I_QueueI_Queue.getMaxNumOfBytes()
public int removeRandom(I_Entry entry)
throws XmlBlasterException
I_Queue
removeRandom in interface I_Queueentry - The entry to erase.
XmlBlasterExceptionI_Queue.removeRandom(I_Entry)
public boolean[] removeRandom(I_Entry[] queueEntries)
throws XmlBlasterException
I_Queue
removeRandom in interface I_QueuequeueEntries - the entries to erase.
XmlBlasterExceptionI_Queue.removeRandom(I_Entry[])
public I_QueueEntry take()
throws XmlBlasterException
XmlBlasterException
public java.util.ArrayList take(int numOfEntries,
long numOfBytes)
throws XmlBlasterException
XmlBlasterException
public java.util.ArrayList takeSamePriority(int numOfEntries,
long numOfBytes)
throws XmlBlasterException
XmlBlasterException
public java.util.ArrayList takeWithPriority(int numOfEntries,
long numOfBytes,
int minPriority,
int maxPriority)
throws XmlBlasterException
I_Queue
takeWithPriority in interface I_QueuenumOfEntries - Take numOfEntries entries, if -1 take all entries currently foundnumOfBytes - so many entries are returned as not to exceed the amount specified. If the first
entry is bigger than this amount, it is returned anyway.minPriority - The lower priority (inclusive), usually 0 lowest, 9 highestmaxPriority - The higher priority (inclusive), usually 0 lowest, 9 highest
XmlBlasterException - in case the underlying implementation gets an exception while retrieving the element.I_Queue
private final boolean isInsideRange(int numEntries,
int maxNumEntries,
long numBytes,
long maxNumBytes)
public java.util.ArrayList takeLowest(int numOfEntries,
long numOfBytes,
I_QueueEntry limitEntry,
boolean leaveOne)
throws XmlBlasterException
I_Queue
takeLowest in interface I_QueuenumOfEntries - inclusive, zero up to numOfEntries, if -1 up to the whole queuenumOfBytes - inclusive, and minimum one is returned (but not if limitEntry suppress it)leaveOne - Usually set to false. (true for cache queue to never flush transient queue totally)
XmlBlasterExceptionI_Queue.takeLowest(int, long, I_QueueEntry, boolean)
public java.util.ArrayList peekLowest(int numOfEntries,
long numOfBytes,
I_QueueEntry limitEntry,
boolean leaveOne)
throws XmlBlasterException
I_Queue
peekLowest in interface I_QueueXmlBlasterExceptionI_Queue.peekLowest(int, long, I_QueueEntry, boolean)
private java.util.ArrayList takeOrPeekLowest(int numOfEntries,
long numOfBytes,
I_QueueEntry limitEntry,
boolean leaveOne,
boolean doDelete)
throws XmlBlasterException
XmlBlasterExceptionI_Queue.takeLowest(int, long, I_QueueEntry, boolean)
public void put(I_QueueEntry entry,
boolean ignorePutInterceptor)
throws XmlBlasterException
put in interface I_QueueignorePutInterceptor - if set to 'IGNORE_PUT_INTERCEPTOR=true' the put will not inform the
QueuePutListener that a put occurred.
XmlBlasterException - in case an error occurs. Possible causes of
error can be a communication exception of the underlying implementation (jdbc, file system etc).I_QueuePutListener.putPre(I_QueueEntry),
I_QueuePutListener.putPost(I_QueueEntry),
I_Queue.put(I_QueueEntry[], boolean)
public void put(I_QueueEntry[] msgArr,
boolean ignorePutInterceptor)
throws XmlBlasterException
put in interface I_QueueignorePutInterceptor - if set to 'IGNORE_PUT_INTERCEPTOR=true' the put will not inform the
QueuePutListener that a put occurred.
XmlBlasterException - in case an error occurs. Possible causes of
error can be a communication exception of the underlying implementation (jdbc, file system etc).I_QueuePutListener.putPre(I_QueueEntry[]),
I_QueuePutListener.putPost(I_QueueEntry[])public java.lang.String toXml()
public java.lang.String toXml(java.lang.String extraOffset)
toXml in interface I_QueueextraOffset - indenting of tags for nice output
public long removeHead(I_QueueEntry toEntry)
throws XmlBlasterException
I_Queue
removeHead in interface I_QueuetoEntry - the entry until to remove.
XmlBlasterExceptionI_Queue.removeHead(I_QueueEntry)
public void destroy()
throws XmlBlasterException
XmlBlasterExceptionpublic java.lang.String usage()
usage in interface I_Queue
public void init(Global glob,
PluginInfo pluginInfo)
init in interface I_PluginI_Plugin.init(org.xmlBlaster.util.Global, PluginInfo)public java.lang.String getType()
getType in interface I_Pluginpublic java.lang.String getVersion()
getVersion in interface I_Pluginpublic PluginInfo getInfo()
getInfo in interface I_StoragePluginpublic boolean registerStorageProblemListener(I_StorageProblemListener listener)
I_StorageProblemNotifier
registerStorageProblemListener in interface I_StorageProblemNotifierI_StorageProblemNotifier.registerStorageProblemListener(I_StorageProblemListener)public boolean unRegisterStorageProblemListener(I_StorageProblemListener listener)
I_StorageProblemNotifier
unRegisterStorageProblemListener in interface I_StorageProblemNotifierI_StorageProblemNotifier.unRegisterStorageProblemListener(I_StorageProblemListener)public void addStorageSizeListener(I_StorageSizeListener listener)
I_Storage
addStorageSizeListener in interface I_Storagelistener - 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_Storagelistener - 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_Storagelistener - 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_StorageI_Storage#getStorageSizeListeners()
public long embeddedObjectsToXml(java.io.OutputStream out,
java.util.Properties props)
I_Queue
embeddedObjectsToXml in interface I_Queueout - The output stream to dump the entriesprops - Configuration properties, not yet specified, just pass null
I_Queue.embeddedObjectsToXml(OutputStream, Properties)
|
xmlBlaster 1.6.2 API | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||