Package ch.cern.dirq
Class QueueNull
java.lang.Object
ch.cern.dirq.QueueNull
QueueNull - object oriented interface to a null directory based queue.
The goal of this module is to offer a null queue system using the same API as the other directory queue implementations. The queue will behave like a black hole: added data will disappear immediately so the queue will therefore always appear empty.
This can be used for testing purposes or to discard data like one would do on Unix by redirecting output to
Please refer to
All the methods that add data will return an invalid element name.
All the methods that work on elements will throw an
The goal of this module is to offer a null queue system using the same API as the other directory queue implementations. The queue will behave like a black hole: added data will disappear immediately so the queue will therefore always appear empty.
This can be used for testing purposes or to discard data like one would do on Unix by redirecting output to
/dev/null.
Please refer to
Queue for general information about
directory queues.
All the methods that add data will return an invalid element name.
All the methods that work on elements will throw an
UnsupportedOperationException exception.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static classIterator for the null directory queue (private). -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionadd(byte[] data) Add byte array data to the queue.Add String data to the queue.Add the given file (identified by its path) to the queue and return the corresponding element name, the file must be on the same filesystem and will be moved to the queue.intcount()Return the number of elements in the queue.Get the given locked element as String data.byte[]getAsByteArray(String name) Get the given locked element as byte array data.getId()Return a unique identifier for the queue.Get the path of the given locked element.Return the path of the queue.iterator()Iterator for the null directory queue.booleanLock an element in permissive mode.booleanLock an element.voidpurge()Purge the queue by removing unused intermediate directories, removing too old temporary elements and unlocking too old locked elements (aka staled locks); note: this can take a long time on queues with many elements.voidpurge(int maxLock) Purge the queue by removing unused intermediate directories, removing too old temporary elements and unlocking too old locked elements (aka staled locks); note: this can take a long time on queues with many elements.voidpurge(int maxLock, int maxTemp) Purge the queue by removing unused intermediate directories, removing too old temporary elements and unlocking too old locked elements (aka staled locks); note: this can take a long time on queues with many elements.voidRemove a locked element from the queue.booleanUnlock an element in non-permissive mode.booleanUnlock an element.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
QueueNull
public QueueNull()Constructor for the null directory queue.
-
-
Method Details
-
getQueuePath
Description copied from interface:QueueReturn the path of the queue.- Specified by:
getQueuePathin interfaceQueue- Returns:
- queue path
-
getId
Description copied from interface:QueueReturn a unique identifier for the queue. -
add
Description copied from interface:QueueAdd String data to the queue. -
add
Description copied from interface:QueueAdd byte array data to the queue. -
addPath
Description copied from interface:QueueAdd the given file (identified by its path) to the queue and return the corresponding element name, the file must be on the same filesystem and will be moved to the queue.- Specified by:
addPathin interfaceQueue- Parameters:
path- path of the file to be added- Returns:
- element name (as directory_name/file_name)
- Throws:
IOException- if any file operation fails
-
get
Description copied from interface:QueueGet the given locked element as String data. -
getAsByteArray
Description copied from interface:QueueGet the given locked element as byte array data.- Specified by:
getAsByteArrayin interfaceQueue- Parameters:
name- name of the element to be retrieved- Returns:
- data associated with the given element
-
getPath
Description copied from interface:QueueGet the path of the given locked element.
This pathFile can be read but not removed, you must use the remove() method for this purpose. -
lock
Description copied from interface:QueueLock an element in permissive mode. -
lock
Description copied from interface:QueueLock an element. -
unlock
Description copied from interface:QueueUnlock an element in non-permissive mode. -
unlock
Description copied from interface:QueueUnlock an element. -
remove
Description copied from interface:QueueRemove a locked element from the queue. -
count
public int count()Description copied from interface:QueueReturn the number of elements in the queue.
Locked elements are counted but temporary elements are not. -
purge
public void purge()Description copied from interface:QueuePurge the queue by removing unused intermediate directories, removing too old temporary elements and unlocking too old locked elements (aka staled locks); note: this can take a long time on queues with many elements.
It uses default value for maxTemp and maxLock -
purge
public void purge(int maxLock) Description copied from interface:QueuePurge the queue by removing unused intermediate directories, removing too old temporary elements and unlocking too old locked elements (aka staled locks); note: this can take a long time on queues with many elements. -
purge
public void purge(int maxLock, int maxTemp) Description copied from interface:QueuePurge the queue by removing unused intermediate directories, removing too old temporary elements and unlocking too old locked elements (aka staled locks); note: this can take a long time on queues with many elements.- Specified by:
purgein interfaceQueue- Parameters:
maxLock- maximum time for a locked element (in seconds); if set to 0, locked elements will not be unlocked; if set to null, the object's default value will be usedmaxTemp- maximum time for a temporary element (in seconds); if set to 0, temporary elements will not be removed if set to null, the object's default value will be used
-
iterator
Iterator for the null directory queue.
-