org.dspace.curate
Class FileTaskQueue

java.lang.Object
  extended by org.dspace.curate.FileTaskQueue
All Implemented Interfaces:
TaskQueue

public class FileTaskQueue
extends Object
implements TaskQueue

FileTaskQueue provides a TaskQueue implementation based on flat files for the queues and semaphores.

Author:
richardrodgers

Constructor Summary
FileTaskQueue()
           
 
Method Summary
 Set<TaskQueueEntry> dequeue(String queueName, long ticket)
          Returns the set of task entries from the named queue.
 void enqueue(String queueName, Set<TaskQueueEntry> entrySet)
          Queues a set of task entries to a named queue.
 void enqueue(String queueName, TaskQueueEntry entry)
          Queues a single entry to a named queue.
 String[] queueNames()
          Returns list of queue names.
 void release(String queueName, long ticket, boolean remove)
          Releases the lock upon the named queue, deleting it if removeEntries is set to true.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileTaskQueue

public FileTaskQueue()
Method Detail

queueNames

public String[] queueNames()
Description copied from interface: TaskQueue
Returns list of queue names.

Specified by:
queueNames in interface TaskQueue
Returns:
queues the list of names of active queues

enqueue

public void enqueue(String queueName,
                    TaskQueueEntry entry)
             throws IOException
Description copied from interface: TaskQueue
Queues a single entry to a named queue.

Specified by:
enqueue in interface TaskQueue
Parameters:
queueName - the name of the queue on which to write
entry - the task entry
Throws:
IOException

enqueue

public void enqueue(String queueName,
                    Set<TaskQueueEntry> entrySet)
             throws IOException
Description copied from interface: TaskQueue
Queues a set of task entries to a named queue.

Specified by:
enqueue in interface TaskQueue
Parameters:
queueName - the name of the queue on which to write
entrySet - the set of task entries
Throws:
IOException

dequeue

public Set<TaskQueueEntry> dequeue(String queueName,
                                   long ticket)
                            throws IOException
Description copied from interface: TaskQueue
Returns the set of task entries from the named queue. The operation locks the queue from any further enqueue or dequeue operations until a release is called. The ticket may be any number, but a timestamp should guarantee sufficient uniqueness.

Specified by:
dequeue in interface TaskQueue
Parameters:
queueName - the name of the queue to read
ticket - a token which must be presented to release the queue
Returns:
set the current set of queued task entries
Throws:
IOException

release

public void release(String queueName,
                    long ticket,
                    boolean remove)
Description copied from interface: TaskQueue
Releases the lock upon the named queue, deleting it if removeEntries is set to true.

Specified by:
release in interface TaskQueue
Parameters:
queueName - the name of the queue to release
ticket - a token that was presented when queue was dequeued.
remove - flag to indicate whether entries may be deleted


Copyright © 2012 DuraSpace. All Rights Reserved.