Interface IBigQueue

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Interface Description
      static interface  IBigQueue.ItemIterator
      Item iterator interface
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      void applyForEach​(IBigQueue.ItemIterator iterator)
      apply an implementation of a ItemIterator interface for each queue item
      byte[] dequeue()
      Retrieves and removes the front of a queue
      CompletableFuture<byte[]> dequeueAsync()
      Retrieves a Future which will complete if new Items where enqued.
      void enqueue​(byte[] data)
      Adds an item at the back of a queue
      void flush()
      Force to persist current state of the queue, normally, you don't need to flush explicitly since: 1.)
      void gc()
      Delete all used data files to free disk space.
      boolean isEmpty()
      Determines whether a queue is empty
      byte[] peek()
      Retrieves the item at the front of a queue
      CompletableFuture<byte[]> peekAsync()
      Retrieves the item at the front of a queue asynchronously.
      void removeAll()
      Removes all items of a queue, this will empty the queue and delete all back data files.
      long size()
      Total number of items available in the queue.
    • Method Detail

      • isEmpty

        boolean isEmpty()
        Determines whether a queue is empty
        Returns:
        ture if empty, false otherwise
      • enqueue

        void enqueue​(byte[] data)
              throws IOException
        Adds an item at the back of a queue
        Parameters:
        data - to be enqueued data
        Throws:
        IOException - exception throws if there is any IO error during enqueue operation.
      • dequeue

        byte[] dequeue()
                throws IOException
        Retrieves and removes the front of a queue
        Returns:
        data at the front of a queue
        Throws:
        IOException - exception throws if there is any IO error during dequeue operation.
      • dequeueAsync

        CompletableFuture<byte[]> dequeueAsync()
        Retrieves a Future which will complete if new Items where enqued. Use this method to retrieve a future where to register as Listener instead of repeatedly polling the queues state. On complete this future contains the result of the dequeue operation. Hence the item was automatically removed from the queue.
        Returns:
        a ListenableFuture which completes with the first entry if items are ready to be dequeued.
      • removeAll

        void removeAll()
                throws IOException
        Removes all items of a queue, this will empty the queue and delete all back data files.
        Throws:
        IOException - exception throws if there is any IO error during dequeue operation.
      • peek

        byte[] peek()
             throws IOException
        Retrieves the item at the front of a queue
        Returns:
        data at the front of a queue
        Throws:
        IOException - exception throws if there is any IO error during peek operation.
      • peekAsync

        CompletableFuture<byte[]> peekAsync()
        Retrieves the item at the front of a queue asynchronously. On complete the value set in this future is the result of the peek operation. Hence the item remains at the front of the list.
        Returns:
        a future containing the first item if available. You may register as listener at this future to be informed if a new item arrives.
      • applyForEach

        void applyForEach​(IBigQueue.ItemIterator iterator)
                   throws IOException
        apply an implementation of a ItemIterator interface for each queue item
        Parameters:
        iterator - Callback used for each item in array.
        Throws:
        IOException - exception thrown if IO error occurs
      • gc

        void gc()
         throws IOException
        Delete all used data files to free disk space. BigQueue will persist enqueued data in disk files, these data files will remain even after the data in them has been dequeued later, so your application is responsible to periodically call this method to delete all used data files and free disk space.
        Throws:
        IOException - exception throws if there is any IO error during gc operation.
      • flush

        void flush()
        Force to persist current state of the queue, normally, you don't need to flush explicitly since: 1.) BigQueue will automatically flush a cached page when it is replaced out, 2.) BigQueue uses memory mapped file technology internally, and the OS will flush the changes even your process crashes, call this periodically only if you need transactional reliability and you are aware of the cost to performance.
      • size

        long size()
        Total number of items available in the queue.
        Returns:
        total number