Interface TaskQueue

  • All Known Implementing Classes:
    FileTaskQueue

    public interface TaskQueue
    TaskQueue objects manage access to named queues of task entries. Entries represent curation task requests that have been deferred. The queue supports concurrent non-blocking writers, but controls read access to a single reader possessing a ticket (first come, first serve). After the read, the queue remains locked until released by the reader, after which it is typically purged.
    Author:
    richardrodgers
    • Method Detail

      • queueNames

        String[] queueNames()
        Returns list of queue names.
        Returns:
        queues the list of names of active queues
      • enqueue

        void enqueue​(String queueName,
                     TaskQueueEntry entry)
              throws IOException
        Queues a single entry to a named queue.
        Parameters:
        queueName - the name of the queue on which to write
        entry - the task entry
        Throws:
        IOException - if IO error
      • enqueue

        void enqueue​(String queueName,
                     Set<TaskQueueEntry> entrySet)
              throws IOException
        Queues a set of task entries to a named queue.
        Parameters:
        queueName - the name of the queue on which to write
        entrySet - the set of task entries
        Throws:
        IOException - if IO error
      • dequeue

        Set<TaskQueueEntry> dequeue​(String queueName,
                                    long ticket)
                             throws IOException
        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.
        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 - if IO error
      • release

        void release​(String queueName,
                     long ticket,
                     boolean removeEntries)
        Releases the lock upon the named queue, deleting it if removeEntries is set to true.
        Parameters:
        queueName - the name of the queue to release
        ticket - a token that was presented when queue was dequeued.
        removeEntries - flag to indicate whether entries may be deleted