Class PersistedQueue


  • @ThreadSafe
    public class PersistedQueue
    extends Object
    Fast request queue implementation on top of Berkley DB Java Edition. The queue uses the canonalised dn for key and store only the last password change for each dn.

    • Constructor Detail

      • PersistedQueue

        public PersistedQueue​(File queueEnvPath,
                              String queueName,
                              int cacheSize)
        Creates instance of persistent queue.
        Parameters:
        queueEnvPath - queue database environment directory path
        queueName - descriptive queue name
        cacheSize - how often to sync the queue to disk
    • Method Detail

      • poll

        public String[] poll()
                      throws IOException
        Retrieves and returns element from the head of this queue.
        Returns:
        element from the head of the queue or null if queue is empty
        Throws:
        IOException - in case of disk IO failure
      • push

        public void push​(String dn,
                         String element)
                  throws IOException
        Pushes element to the queue.

        The entries are sorted in natural order and not in order of time when they were added.

        Parameters:
        dn - The entry DN
        element - element
        Throws:
        IOException - in case of disk IO failure
      • size

        public long size()
        Returns the size of this queue.
        Returns:
        the size of the queue
      • getQueueName

        public String getQueueName()
        Returns this queue name.
        Returns:
        this queue name
      • close

        public void close()
        Closes this queue and frees up all resources associated to it.