use of com.netflix.titus.common.framework.simplereconciler.SimpleReconcilerEvent in project titus-control-plane by Netflix.
the class EventDistributor method doLoop.
private void doLoop() {
while (true) {
if (shutdown) {
completeEmitters();
return;
}
Stopwatch start = Stopwatch.createStarted();
List<SimpleReconcilerEvent<DATA>> events = new ArrayList<>();
try {
SimpleReconcilerEvent<DATA> event = eventQueue.poll(1, TimeUnit.MILLISECONDS);
if (event != null) {
events.add(event);
}
} catch (InterruptedException ignore) {
}
// Build snapshot early before draining the event queue
List<SimpleReconcilerEvent<DATA>> snapshot = null;
if (!sinkQueue.isEmpty()) {
snapshot = snapshotSupplier.get();
}
eventQueue.drainTo(events);
eventQueueDepth.accumulateAndGet(events.size(), (current, delta) -> current - delta);
// We emit events to already connected sinks first. For new sinks, we build snapshot and merge it with the
// pending event queue in addNewSinks method.
processEvents(events);
removeUnsubscribedSinks();
if (snapshot != null) {
addNewSinks(snapshot, events);
}
metricEmittedEvents.increment(events.size());
metricLoopExecutionTime.record(start.elapsed(TimeUnit.MILLISECONDS), TimeUnit.MILLISECONDS);
}
}
Aggregations