Package org.apache.storm.utils
Class JCQueue
java.lang.Object
org.apache.storm.utils.JCQueue
- All Implemented Interfaces:
Closeable
,AutoCloseable
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
static interface
-
Constructor Summary
ConstructorDescriptionJCQueue
(String queueName, String metricNamePrefix, int size, int overflowLimit, int producerBatchSz, IWaitStrategy backPressureWaitStrategy, String topologyId, String componentId, List<Integer> taskIds, int port, StormMetricRegistry metricRegistry) -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
int
consume
(JCQueue.Consumer consumer) Non blocking.int
consume
(JCQueue.Consumer consumer, JCQueue.ExitCondition exitCond) Non blocking.void
flush()
if(batchSz>1) : Blocking call.int
int
double
boolean
void
Blocking call.void
int
size()
boolean
tryFlush()
if(batchSz>1) : Non-Blocking call.boolean
tryPublish
(Object obj) Non-blocking call, returns false if full.boolean
tryPublishDirect
(Object obj) Non-blocking call.boolean
Un-batched write to overflowQ.
-
Constructor Details
-
JCQueue
public JCQueue(String queueName, String metricNamePrefix, int size, int overflowLimit, int producerBatchSz, IWaitStrategy backPressureWaitStrategy, String topologyId, String componentId, List<Integer> taskIds, int port, StormMetricRegistry metricRegistry)
-
-
Method Details
-
getQueueName
-
close
public void close()- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
-
consume
Non blocking. Returns immediately if Q is empty. Returns number of elements consumed from Q. -
consume
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
Blocking call. Retries till it can successfully publish the obj. Can be interrupted via Thread.interrupt().- Throws:
InterruptedException
-
tryPublish
Non-blocking call, returns false if full. -
tryPublishDirect
Non-blocking call. Bypasses any batching that may be enabled on the recvQueue. Intended for sending flush/metrics tuples -
tryPublishToOverflow
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
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.- Throws:
InterruptedException
-
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.
-