Class ConsumerRunner<M extends Message>
- java.lang.Object
-
- org.nuxeo.lib.stream.pattern.consumer.internals.ConsumerRunner<M>
-
- All Implemented Interfaces:
Callable<ConsumerStatus>,RebalanceListener
public class ConsumerRunner<M extends Message> extends Object implements Callable<ConsumerStatus>, RebalanceListener
Read messages from a tailer and drive a consumer according to its policy.- Since:
- 9.1
-
-
Field Summary
Fields Modifier and Type Field Description protected longacceptCounterprotected booleanalreadySaltedprotected longbatchCommitCounterprotected longbatchFailureCounterprotected longcommittedCounterprotected Consumer<M>consumerprotected StringconsumerIdprotected BatchPolicycurrentBatchPolicyprotected ConsumerFactory<M>factoryprotected io.dropwizard.metrics5.TimerglobalAcceptTimerprotected io.dropwizard.metrics5.TimerglobalBatchCommitTimerprotected io.dropwizard.metrics5.CounterglobalBatchFailureCounterprotected io.dropwizard.metrics5.CounterglobalCommittedCounterprotected io.dropwizard.metrics5.CounterglobalConsumersCounterstatic StringNUXEO_METRICS_REGISTRY_NAMEprotected ConsumerPolicypolicyprotected io.dropwizard.metrics5.MetricRegistryregistryprotected LogTailer<M>tailerprotected StringthreadName
-
Constructor Summary
Constructors Constructor Description ConsumerRunner(ConsumerFactory<M> factory, ConsumerPolicy policy, LogManager manager, List<LogPartition> defaultAssignments)Deprecated.since 11.1, due to serialization issue with java 11, useConsumerRunner(ConsumerFactory, ConsumerPolicy, LogManager, Codec, List)which allows to give acodectotailer.ConsumerRunner(ConsumerFactory<M> factory, ConsumerPolicy policy, LogManager manager, Codec<M> codec, List<LogPartition> defaultAssignments)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected BatchStateacceptBatch()protected voidaddSalt()protected voidbeginBatch()ConsumerStatuscall()protected voidcommitBatch(BatchState state)protected voidconsumerLoop()protected LogTailer<M>createTailer(LogManager manager, Codec<M> codec, List<LogPartition> defaultAssignments)voidonPartitionsAssigned(Collection<LogPartition> partitions)voidonPartitionsLost(Collection<LogPartition> partitions)voidonPartitionsRevoked(Collection<LogPartition> partitions)protected booleanprocessBatch()protected booleanprocessBatchWithRetry(net.jodah.failsafe.Execution execution)protected voidrestoreBatchPolicy()protected voidrollbackBatch(Exception e)protected voidsetBatchRetryPolicy()protected voidsetMetrics()protected voidsetTailerPosition(LogManager manager)protected voidsetThreadName(String message)
-
-
-
Field Detail
-
NUXEO_METRICS_REGISTRY_NAME
public static final String NUXEO_METRICS_REGISTRY_NAME
- See Also:
- Constant Field Values
-
factory
protected final ConsumerFactory<M extends Message> factory
-
policy
protected final ConsumerPolicy policy
-
consumerId
protected String consumerId
-
currentBatchPolicy
protected BatchPolicy currentBatchPolicy
-
threadName
protected String threadName
-
registry
protected final io.dropwizard.metrics5.MetricRegistry registry
-
acceptCounter
protected long acceptCounter
-
committedCounter
protected long committedCounter
-
batchCommitCounter
protected long batchCommitCounter
-
batchFailureCounter
protected long batchFailureCounter
-
alreadySalted
protected boolean alreadySalted
-
globalAcceptTimer
protected io.dropwizard.metrics5.Timer globalAcceptTimer
-
globalCommittedCounter
protected io.dropwizard.metrics5.Counter globalCommittedCounter
-
globalBatchCommitTimer
protected io.dropwizard.metrics5.Timer globalBatchCommitTimer
-
globalBatchFailureCounter
protected io.dropwizard.metrics5.Counter globalBatchFailureCounter
-
globalConsumersCounter
protected io.dropwizard.metrics5.Counter globalConsumersCounter
-
-
Constructor Detail
-
ConsumerRunner
@Deprecated public ConsumerRunner(ConsumerFactory<M> factory, ConsumerPolicy policy, LogManager manager, List<LogPartition> defaultAssignments)
Deprecated.since 11.1, due to serialization issue with java 11, useConsumerRunner(ConsumerFactory, ConsumerPolicy, LogManager, Codec, List)which allows to give acodectotailer.
-
ConsumerRunner
public ConsumerRunner(ConsumerFactory<M> factory, ConsumerPolicy policy, LogManager manager, Codec<M> codec, List<LogPartition> defaultAssignments)
-
-
Method Detail
-
createTailer
protected LogTailer<M> createTailer(LogManager manager, Codec<M> codec, List<LogPartition> defaultAssignments)
-
call
public ConsumerStatus call() throws Exception
-
setMetrics
protected void setMetrics()
-
addSalt
protected void addSalt() throws InterruptedException
- Throws:
InterruptedException
-
setTailerPosition
protected void setTailerPosition(LogManager manager)
-
consumerLoop
protected void consumerLoop() throws InterruptedException
- Throws:
InterruptedException
-
processBatchWithRetry
protected boolean processBatchWithRetry(net.jodah.failsafe.Execution execution) throws InterruptedException
- Throws:
InterruptedException
-
setBatchRetryPolicy
protected void setBatchRetryPolicy()
-
restoreBatchPolicy
protected void restoreBatchPolicy()
-
processBatch
protected boolean processBatch() throws InterruptedException
- Throws:
InterruptedException
-
beginBatch
protected void beginBatch()
-
commitBatch
protected void commitBatch(BatchState state)
-
rollbackBatch
protected void rollbackBatch(Exception e)
-
acceptBatch
protected BatchState acceptBatch() throws InterruptedException
- Throws:
InterruptedException
-
setThreadName
protected void setThreadName(String message)
-
onPartitionsRevoked
public void onPartitionsRevoked(Collection<LogPartition> partitions)
- Specified by:
onPartitionsRevokedin interfaceRebalanceListener
-
onPartitionsLost
public void onPartitionsLost(Collection<LogPartition> partitions)
- Specified by:
onPartitionsLostin interfaceRebalanceListener
-
onPartitionsAssigned
public void onPartitionsAssigned(Collection<LogPartition> partitions)
- Specified by:
onPartitionsAssignedin interfaceRebalanceListener
-
-