Package org.apache.storm.utils
Class JCQueue
java.lang.Object
org.apache.storm.utils.JCQueue
- All Implemented Interfaces:
Closeable,AutoCloseable
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfacestatic interface -
Constructor Summary
ConstructorsConstructorDescriptionJCQueue(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 TypeMethodDescriptionvoidclose()intconsume(JCQueue.Consumer consumer) Non blocking.intconsume(JCQueue.Consumer consumer, JCQueue.ExitCondition exitCond) Non blocking.voidflush()if(batchSz>1) : Blocking call.intintdoublebooleanvoidBlocking call.voidintsize()booleantryFlush()if(batchSz>1) : Non-Blocking call.booleantryPublish(Object obj) Non-blocking call, returns false if full.booleantryPublishDirect(Object obj) Non-blocking call.booleanUn-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:
closein interfaceAutoCloseable- Specified by:
closein 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.
-