java.lang.Object
io.micronaut.kubernetes.client.openapi.operator.workqueue.DefaultWorkQueue<T>
Type Parameters:
T - item type
All Implemented Interfaces:
WorkQueue<T>
Direct Known Subclasses:
DefaultDelayingQueue

public class DefaultWorkQueue<T> extends Object implements WorkQueue<T>
The default WorkQueue implementation that uses a doubly-linked list to store work items. This class ensures the added work items are not in dirty set nor in currently processing set before adding them to the list.

The code has been copied from the official client and modified: DefaultWorkQueue

  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    add(T item)
    Adds an item to the queue of items which need processing.
    void
    done(T item)
    Marks an item as completed.
    get()
    Gets an item for processing.
    boolean
    Returns whether the queue is shutdown.
    int
    Returns the current queue length, for informational purposes only.
    void
    Initiates a shutdown of the work queue.
    void
    Starts the work queue.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • DefaultWorkQueue

      public DefaultWorkQueue()
  • Method Details

    • add

      public void add(T item)
      Description copied from interface: WorkQueue
      Adds an item to the queue of items which need processing.
      Specified by:
      add in interface WorkQueue<T>
      Parameters:
      item - item to add
    • length

      public int length()
      Description copied from interface: WorkQueue
      Returns the current queue length, for informational purposes only.
      Specified by:
      length in interface WorkQueue<T>
      Returns:
      current queue length
    • get

      public T get() throws InterruptedException
      Description copied from interface: WorkQueue
      Gets an item for processing. It blocks until there is an available item.
      Specified by:
      get in interface WorkQueue<T>
      Returns:
      the item
      Throws:
      InterruptedException
    • done

      public void done(T item)
      Description copied from interface: WorkQueue
      Marks an item as completed. Also, it will add the same item back to the queue of items which need processing if the item was marked as dirty while processing was in progress.
      Specified by:
      done in interface WorkQueue<T>
      Parameters:
      item - specific item
    • start

      public void start()
      Description copied from interface: WorkQueue
      Starts the work queue. Can be called after shutdown to enable queue usage.
      Specified by:
      start in interface WorkQueue<T>
    • shutdown

      public void shutdown()
      Description copied from interface: WorkQueue
      Initiates a shutdown of the work queue. All added items whose processing not started will be ignored and removed from the queue.
      Specified by:
      shutdown in interface WorkQueue<T>
    • isShutdown

      public boolean isShutdown()
      Description copied from interface: WorkQueue
      Returns whether the queue is shutdown.
      Specified by:
      isShutdown in interface WorkQueue<T>
      Returns:
      true if the queue is shutdown