public class JCQueue extends Object implements IStatefulObject, Closeable
Modifier and Type | Class and Description |
---|---|
static interface |
JCQueue.Consumer |
static interface |
JCQueue.ExitCondition |
class |
JCQueue.QueueMetrics
This inner class provides methods to access the metrics of the JCQueue.
|
Constructor and Description |
---|
JCQueue(String queueName,
int size,
int overflowLimit,
int producerBatchSz,
IWaitStrategy backPressureWaitStrategy,
String topologyId,
String componentId,
Integer taskId,
int port,
StormMetricRegistry metricRegistry) |
Modifier and Type | Method and Description |
---|---|
void |
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.
|
JCQueue.QueueMetrics |
getMetrics() |
String |
getName() |
int |
getOverflowCount() |
int |
getQueuedCount() |
Object |
getState() |
boolean |
isEmptyOverflow() |
void |
publish(Object obj)
Blocking call.
|
void |
recordMsgDrop() |
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 |
tryPublishToOverflow(Object obj)
Un-batched write to overflowQ.
|
public JCQueue(String queueName, int size, int overflowLimit, int producerBatchSz, IWaitStrategy backPressureWaitStrategy, String topologyId, String componentId, Integer taskId, int port, StormMetricRegistry metricRegistry)
public String getName()
public void close()
close
in interface Closeable
close
in interface AutoCloseable
public int consume(JCQueue.Consumer consumer)
Non blocking. Returns immediately if Q is empty. Returns number of elements consumed from Q.
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.
public int size()
public void publish(Object obj) throws InterruptedException
Blocking call. Retries till it can successfully publish the obj. Can be interrupted via Thread.interrupt().
InterruptedException
public boolean tryPublish(Object obj)
Non-blocking call, returns false if full.
public boolean tryPublishDirect(Object obj)
Non-blocking call. Bypasses any batching that may be enabled on the recvQueue. Intended for sending flush/metrics tuples
public boolean tryPublishToOverflow(Object obj)
Un-batched write to overflowQ. Should only be called by WorkerTransfer returns false if overflowLimit has reached
public void recordMsgDrop()
public boolean isEmptyOverflow()
public int getOverflowCount()
public int getQueuedCount()
public void flush() throws InterruptedException
InterruptedException
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.
public Object getState()
getState
in interface IStatefulObject
public JCQueue.QueueMetrics getMetrics()
Copyright © 2022 The Apache Software Foundation. All rights reserved.