Class JCQueue

All Implemented Interfaces:
Closeable, AutoCloseable

public class JCQueue extends Object implements Closeable
  • Constructor Details

  • Method Details

    • getQueueName

      public String getQueueName()
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
    • consume

      public int consume(JCQueue.Consumer consumer)
      Non blocking. Returns immediately if Q is empty. Returns number of elements consumed from Q.
    • consume

      public int consume(JCQueue.Consumer consumer, JCQueue.ExitCondition exitCond)
      Non blocking. Returns immediately if Q is empty. Runs till Q is empty OR exitCond.keepRunning() return false. Returns number of elements consumed from Q.
    • size

      public int size()
    • getQueueLoad

      public double getQueueLoad()
    • publish

      public void publish(Object obj) throws InterruptedException
      Blocking call. Retries till it can successfully publish the obj. Can be interrupted via Thread.interrupt().
    • tryPublish

      public boolean tryPublish(Object obj)
      Non-blocking call, returns false if full.
    • tryPublishDirect

      public boolean tryPublishDirect(Object obj)
      Non-blocking call. Bypasses any batching that may be enabled on the recvQueue. Intended for sending flush/metrics tuples
    • tryPublishToOverflow

      public boolean tryPublishToOverflow(Object obj)
      Un-batched write to overflowQ. Should only be called by WorkerTransfer returns false if overflowLimit has reached
    • recordMsgDrop

      public void recordMsgDrop()
    • isEmptyOverflow

      public boolean isEmptyOverflow()
    • getOverflowCount

      public int getOverflowCount()
    • getQueuedCount

      public int getQueuedCount()
    • flush

      public void flush() throws InterruptedException
      if(batchSz>1) : Blocking call. Does not return until at least 1 element is drained or Thread.interrupt() is received if(batchSz==1) : NO-OP. Returns immediately. doesnt throw.
    • tryFlush

      public boolean tryFlush()
      if(batchSz>1) : Non-Blocking call. Tries to flush as many as it can. Returns true if flushed at least 1. if(batchSz==1) : This is a NO-OP. Returns true immediately.