Package ch.cern.dirq
Class QueueNull
- java.lang.Object
-
- ch.cern.dirq.QueueNull
-
- All Implemented Interfaces:
Queue
,java.lang.Iterable<java.lang.String>
public class QueueNull extends java.lang.Object implements Queue
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/dev/null
.
Please refer toQueue
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 anUnsupportedOperationException
exception.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
QueueNull.QueueNullIterator
Iterator for the null directory queue (private).
-
Constructor Summary
Constructors Constructor Description QueueNull()
Constructor for the null directory queue.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
add(byte[] data)
Add byte array data to the queue.java.lang.String
add(java.lang.String data)
Add String data to the queue.java.lang.String
addPath(java.lang.String path)
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.int
count()
Return the number of elements in the queue.java.lang.String
get(java.lang.String name)
Get the given locked element as String data.byte[]
getAsByteArray(java.lang.String name)
Get the given locked element as byte array data.java.lang.String
getId()
Return a unique identifier for the queue.java.lang.String
getPath(java.lang.String path)
Get the path of the given locked element.java.lang.String
getQueuePath()
Return the path of the queue.java.util.Iterator<java.lang.String>
iterator()
Iterator for the null directory queue.boolean
lock(java.lang.String name)
Lock an element in permissive mode.boolean
lock(java.lang.String name, boolean permissive)
Lock an element.void
purge()
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.void
purge(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.void
purge(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.void
remove(java.lang.String name)
Remove a locked element from the queue.boolean
unlock(java.lang.String name)
Unlock an element in non-permissive mode.boolean
unlock(java.lang.String name, boolean permissive)
Unlock an element.
-
-
-
Method Detail
-
getQueuePath
public java.lang.String getQueuePath()
Description copied from interface:Queue
Return the path of the queue.- Specified by:
getQueuePath
in interfaceQueue
- Returns:
- queue path
-
getId
public java.lang.String getId()
Description copied from interface:Queue
Return a unique identifier for the queue.
-
add
public java.lang.String add(java.lang.String data)
Description copied from interface:Queue
Add String data to the queue.
-
add
public java.lang.String add(byte[] data)
Description copied from interface:Queue
Add byte array data to the queue.
-
addPath
public java.lang.String addPath(java.lang.String path) throws java.io.IOException
Description copied from interface: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.
-
get
public java.lang.String get(java.lang.String name)
Description copied from interface:Queue
Get the given locked element as String data.
-
getAsByteArray
public byte[] getAsByteArray(java.lang.String name)
Description copied from interface:Queue
Get the given locked element as byte array data.- Specified by:
getAsByteArray
in interfaceQueue
- Parameters:
name
- name of the element to be retrieved- Returns:
- data associated with the given element
-
getPath
public java.lang.String getPath(java.lang.String path)
Description copied from interface:Queue
Get 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
public boolean lock(java.lang.String name)
Description copied from interface:Queue
Lock an element in permissive mode.
-
lock
public boolean lock(java.lang.String name, boolean permissive)
Description copied from interface:Queue
Lock an element.
-
unlock
public boolean unlock(java.lang.String name)
Description copied from interface:Queue
Unlock an element in non-permissive mode.
-
unlock
public boolean unlock(java.lang.String name, boolean permissive)
Description copied from interface:Queue
Unlock an element.
-
remove
public void remove(java.lang.String name)
Description copied from interface:Queue
Remove a locked element from the queue.
-
count
public int count()
Description copied from interface:Queue
Return the number of elements in the queue.
Locked elements are counted but temporary elements are not.
-
purge
public void purge()
Description copied from interface:Queue
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.
It uses default value for maxTemp and maxLock
-
purge
public void purge(int maxLock)
Description copied from interface:Queue
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.
-
purge
public void purge(int maxLock, int maxTemp)
Description copied from interface:Queue
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.- Specified by:
purge
in 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
public java.util.Iterator<java.lang.String> iterator()
Iterator for the null directory queue.- Specified by:
iterator
in interfacejava.lang.Iterable<java.lang.String>
-
-