public class TrafficStatisticsManager extends Object
CommonLogFormatEntry
and generates TrafficStatistic
.
The events are processed periodically according to the refresh period configuration.
The events are stored internally in ConcurrentLinkedQueue
and retrieved from an EventBus
Constructor and Description |
---|
TrafficStatisticsManager(com.google.common.eventbus.EventBus eventBus,
int refreshPeriod)
Creates a consumer of events of type
CommonLogFormatEntry . |
Modifier and Type | Method and Description |
---|---|
void |
consumeClfEvent(CommonLogFormatEntry commonLogFormatEntry)
Consumes a
CommonLogFormatEntry event. |
void |
refreshStatistics(Instant maxAge)
Processes all the
CommonLogFormatEntry present in the buffer whose log date time
is "timeSecondsInterval" seconds before now and produces a new TrafficStatistic . |
@Inject public TrafficStatisticsManager(com.google.common.eventbus.EventBus eventBus, int refreshPeriod)
CommonLogFormatEntry
.eventBus
- The EventBus
used to listen to the events
of type CommonLogFormatEntry
refreshPeriod
- The refresh period in seconds after which
the CommonLogFormatEntry
events buffer is checked and all
the events of the last refresh periods seconds are processed.public void refreshStatistics(Instant maxAge)
CommonLogFormatEntry
present in the buffer whose log date time
is "timeSecondsInterval" seconds before now and produces a new TrafficStatistic
.maxAge
- the maximum log date time to process from the buffer.public void consumeClfEvent(CommonLogFormatEntry commonLogFormatEntry)
CommonLogFormatEntry
event.
It adds the CommonLogFormatEntry
to the log buffer if its log date time is after
the most recent stored log entry and discards it otherwise.commonLogFormatEntry
- a CommonLogFormatEntry
type event.Copyright © 2019. All rights reserved.