use of com.netflix.titus.master.jobmanager.service.event.JobCheckpointReconcilerEvent in project titus-control-plane by Netflix.
the class DefaultV3JobOperations method toJobManagerEvent.
private List<JobManagerEvent<?>> toJobManagerEvent(Predicate<Pair<Job<?>, List<Task>>> jobsPredicate, Predicate<Pair<Job<?>, Task>> tasksPredicate, boolean withCheckpoints, JobManagerReconcilerEvent event) {
if (event instanceof JobCheckpointReconcilerEvent) {
if (withCheckpoints) {
JobCheckpointReconcilerEvent checkpoint = (JobCheckpointReconcilerEvent) event;
return Collections.singletonList(JobManagerEvent.keepAliveEvent(checkpoint.getTimestampNano()));
}
return Collections.emptyList();
}
if (event instanceof JobNewModelReconcilerEvent) {
JobNewModelReconcilerEvent newModelEvent = (JobNewModelReconcilerEvent) event;
return toNewJobUpdateEvent(newModelEvent, jobsPredicate);
}
if (!(event instanceof JobModelUpdateReconcilerEvent)) {
return Collections.emptyList();
}
JobModelUpdateReconcilerEvent modelUpdateEvent = (JobModelUpdateReconcilerEvent) event;
if (modelUpdateEvent.getModelActionHolder().getModel() != Model.Reference) {
return Collections.emptyList();
}
if (modelUpdateEvent.getChangedEntityHolder().getEntity() instanceof Job) {
// We have to emit for this case both task archived event followed by job update event.
if (modelUpdateEvent.getChangeAction().getTrigger() == Trigger.ReconcilerServiceTaskRemoved) {
Task archivedTask = modelUpdateEvent.getChangeAction().getTask().orElse(null);
if (archivedTask != null) {
Job<?> job = modelUpdateEvent.getJob();
TaskUpdateEvent archiveEvent = TaskUpdateEvent.taskArchived(job, archivedTask, modelUpdateEvent.getCallMetadata());
List<JobManagerEvent<?>> events = new ArrayList<>();
events.add(archiveEvent);
events.addAll(toJobUpdateEvent(modelUpdateEvent, jobsPredicate));
return events;
}
}
return toJobUpdateEvent(modelUpdateEvent, jobsPredicate);
}
return toTaskUpdateEvent(modelUpdateEvent, tasksPredicate);
}
Aggregations