Package org.logevents.observers.batch
Class CooldownBatcher<T>
- java.lang.Object
-
- org.logevents.observers.batch.CooldownBatcher<T>
-
- All Implemented Interfaces:
Batcher<T>
public class CooldownBatcher<T> extends Object implements Batcher<T>
Used to gather up a number of log event to process as a batch.The batch decides when to flush a batch based on
setCooldownTime(Duration)(minimum time since last processed batch),setIdleThreshold(Duration)(minimum time between log events in the batch) andsetMaximumWaitTime(Duration)(maximum time from the first message in a batch was generated until the batch is processed). When processing, theAbstractBatchingLogEventObservercallsprocessorwith the whole batch to process the log events. Consecutive Log events with the same message pattern and log level are grouped together so the processor can easily ignore duplicate messages.- Author:
- Johannes Brodwall
-
-
Field Summary
Fields Modifier and Type Field Description protected DurationcooldownTimeprotected DurationidleThresholdprotected DurationmaximumWaitTime
-
Constructor Summary
Constructors Constructor Description CooldownBatcher(Consumer<List<T>> processor, ScheduledExecutorService executor)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaccept(T o)protected voidadd(T o, Instant now)voidconfigure(Configuration configuration, String prefix)ReadidleThreshold,cooldownTimeandmaximumWaitTimefrom configurationvoidflush()List<T>getCurrentBatch()protected voidscheduleFlush(Duration delay)voidsetCooldownTime(Duration cooldownTime)Minimum time from a flush until the next flushvoidsetIdleThreshold(Duration idleThreshold)Minimum time from a flush until the next flushvoidsetMaximumWaitTime(Duration maximumWaitTime)Maximum time from the first event in a batch until the batch is flushedvoidshutdown()protected List<T>takeCurrentBatch()
-
-
-
Constructor Detail
-
CooldownBatcher
public CooldownBatcher(Consumer<List<T>> processor, ScheduledExecutorService executor)
-
-
Method Detail
-
configure
public void configure(Configuration configuration, String prefix)
ReadidleThreshold,cooldownTimeandmaximumWaitTimefrom configuration
-
setCooldownTime
public void setCooldownTime(Duration cooldownTime)
Minimum time from a flush until the next flush
-
setIdleThreshold
public void setIdleThreshold(Duration idleThreshold)
Minimum time from a flush until the next flush
-
setMaximumWaitTime
public void setMaximumWaitTime(Duration maximumWaitTime)
Maximum time from the first event in a batch until the batch is flushed
-
scheduleFlush
protected void scheduleFlush(Duration delay)
-
shutdown
public void shutdown()
-
getCurrentBatch
public List<T> getCurrentBatch()
- Specified by:
getCurrentBatchin interfaceBatcher<T>
-
-