|
xmlBlaster 2.2.0 client API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.xmlBlaster.util.queue.ram.RamQueuePlugin
public final class RamQueuePlugin
Queueing messages in RAM only, sorted after priority and timestamp
Field Summary |
---|
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)
|
long |
embeddedQueueObjectsToXml(java.io.OutputStream out,
java.util.Properties props)
NOTE: rename from embeddedObjectsToXml to embeddedQueueObjectsToXml as it used the map lookup and lost priority info Dump all entries of this queue to the given output stream. |
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. |
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 |
peekStartAt(int numOfEntries,
long numOfBytes,
I_QueueEntry firstEntryExlusive)
Returns maximum the first num element in the queue but does not remove it from that queue (leaves it untouched). |
java.util.ArrayList |
peekWithLimitEntry(I_QueueEntry limitEntry)
Deprecated. |
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 |
removeHead(I_QueueEntry toEntry)
removes the head of the queue until (but not included) the entry specified as the argument. |
long |
removeNum(long numOfEntries)
Removes max num messages. |
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()
Cleans up the resource. |
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. |
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 |
Constructor Detail |
---|
public RamQueuePlugin()
Method Detail |
---|
public void initialize(StorageId uniqueQueueId, java.lang.Object userData) throws XmlBlasterException
initialize
in interface I_Queue
uniqueQueueId
- 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_Queue
XmlBlasterException
public java.lang.Object getProperties()
getProperties
in interface I_Queue
public boolean isTransient()
isTransient
in interface I_Storage
public void setNotifiedAboutAddOrRemove(boolean notify)
setNotifiedAboutAddOrRemove
in interface I_Queue
public boolean isNotifiedAboutAddOrRemove()
I_Queue
isNotifiedAboutAddOrRemove
in interface I_Queue
public void addPutListener(I_QueuePutListener l)
I_Queue
addPutListener
in interface I_Queue
I_Queue.addPutListener(I_QueuePutListener)
public void removePutListener(I_QueuePutListener l)
I_Queue
removePutListener
in interface I_Queue
I_Queue.removePutListener(I_QueuePutListener)
public long[] getEntryReferences() throws XmlBlasterException
getEntryReferences
in interface I_Queue
XmlBlasterException
I_Queue.getEntryReferences()
public java.util.ArrayList getEntries(I_EntryFilter entryFilter) throws XmlBlasterException
getEntries
in interface I_Queue
entryFilter
- 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_Storage
public void shutdown()
I_Plugin
shutdown
in interface I_Plugin
shutdown
in interface I_Queue
public boolean isShutdown()
I_Storage
isShutdown
in interface I_Storage
public long clear()
clear
in interface I_Queue
public int remove() throws XmlBlasterException
I_Queue
remove
in interface I_Queue
XmlBlasterException
- if the underlying implementation gets an exception.I_Queue.remove()
public long removeNum(long numOfEntries) throws XmlBlasterException
I_Queue
removeNum
in interface I_Queue
numOfEntries
- Erase num entries or less if less entries are available, -1 erases everything
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_Queue
numOfEntries
- 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
XmlBlasterException
I_Queue#removeTransient()
public I_QueueEntry peek()
I_Queue
peek
in interface I_Queue
I_Queue.peek()
public java.util.ArrayList peekWithPriority(int numOfEntries, long numOfBytes, int minPrio, int maxPrio) throws XmlBlasterException
I_Queue
peekWithPriority
in interface I_Queue
minPrio
- 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)
public java.util.ArrayList peek(int numOfEntries, long numOfBytes) throws XmlBlasterException
I_Queue
peek
in interface I_Queue
numOfEntries
- 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 peekStartAt(int numOfEntries, long numOfBytes, I_QueueEntry firstEntryExlusive) throws XmlBlasterException
I_Queue
peekStartAt
in interface I_Queue
numOfEntries
- 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.public java.util.ArrayList peekSamePriority(int numOfEntries, long numOfBytes) throws XmlBlasterException
I_Queue
peekSamePriority
in interface I_Queue
numOfEntries
- 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_Queue
limitEntry
- 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.
XmlBlasterException
I_Queue.peekWithLimitEntry(I_QueueEntry)
public long removeWithLimitEntry(I_QueueEntry limitEntry, boolean inclusive) throws XmlBlasterException
I_Queue
removeWithLimitEntry
in interface I_Queue
limitEntry
- 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.
XmlBlasterException
I_Queue.removeWithLimitEntry(I_QueueEntry, boolean)
public long getNumOfEntries()
I_Storage
getNumOfEntries
in interface I_Storage
I_Storage.getNumOfEntries()
public long getNumOfPersistentEntries()
getNumOfPersistentEntries
in interface I_Queue
I_Queue.getNumOfPersistentEntries()
public long getMaxNumOfEntries()
I_Storage
getMaxNumOfEntries
in interface I_Storage
I_Storage.getMaxNumOfEntries()
public long getNumOfBytes()
I_Storage
getNumOfBytes
in interface I_Storage
I_Storage.getNumOfBytes()
public long getNumOfPersistentBytes()
I_Queue
getNumOfPersistentBytes
in interface I_Queue
I_Queue.getNumOfPersistentBytes()
public long getSynchronizedNumOfBytes()
I_Storage.getNumOfBytes()
public long getMaxNumOfBytes()
I_Queue
getMaxNumOfBytes
in interface I_Queue
I_Queue.getMaxNumOfBytes()
public int removeRandom(I_Entry entry) throws XmlBlasterException
I_Queue
removeRandom
in interface I_Queue
entry
- The entry to erase.
XmlBlasterException
I_Queue.removeRandom(I_Entry)
public boolean[] removeRandom(I_Entry[] queueEntries) throws XmlBlasterException
I_Queue
removeRandom
in interface I_Queue
queueEntries
- the entries to erase.
XmlBlasterException
I_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_Queue
numOfEntries
- 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
public java.util.ArrayList takeLowest(int numOfEntries, long numOfBytes, I_QueueEntry limitEntry, boolean leaveOne) throws XmlBlasterException
I_Queue
takeLowest
in interface I_Queue
numOfEntries
- 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)
XmlBlasterException
I_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_Queue
XmlBlasterException
I_Queue.peekLowest(int, long, I_QueueEntry, boolean)
public void put(I_QueueEntry entry, boolean ignorePutInterceptor) throws XmlBlasterException
put
in interface I_Queue
ignorePutInterceptor
- 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_Queue
ignorePutInterceptor
- 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_Queue
extraOffset
- indenting of tags for nice output
public long removeHead(I_QueueEntry toEntry) throws XmlBlasterException
I_Queue
removeHead
in interface I_Queue
toEntry
- the entry until to remove.
XmlBlasterException
I_Queue.removeHead(I_QueueEntry)
public void destroy() throws XmlBlasterException
XmlBlasterException
public java.lang.String usage()
usage
in interface I_Queue
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_Plugin
public java.lang.String getVersion()
getVersion
in interface I_Plugin
public PluginInfo getInfo()
getInfo
in interface I_StoragePlugin
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 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()
public long embeddedQueueObjectsToXml(java.io.OutputStream out, java.util.Properties props) throws java.lang.Exception
I_Queue
embeddedQueueObjectsToXml
in interface I_Queue
out
- The output stream to dump the entriesprops
- Configuration properties, not yet specified, just pass null
java.lang.Exception
public long embeddedObjectsToXml(java.io.OutputStream out, java.util.Properties props)
I_Queue#embeddedObjectsToXml(OutputStream, Properties)
|
xmlBlaster 2.2.0 client API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |