use of com.netflix.titus.api.containerhealth.model.ContainerHealthStatus in project titus-control-plane by Netflix.
the class EurekaContainerHealthService method handleEurekaEvent.
private Flux<ContainerHealthEvent> handleEurekaEvent(EurekaEvent event, ConcurrentMap<String, ContainerHealthEvent> state) {
if (!(event instanceof CacheRefreshedEvent)) {
return Flux.empty();
}
List<Pair<Job, List<Task>>> allJobsAndTasks = jobOperations.getJobsAndTasks();
List<Task> allTasks = new ArrayList<>();
List<ContainerHealthEvent> events = new ArrayList<>();
allJobsAndTasks.forEach(jobAndTasks -> {
jobAndTasks.getRight().forEach(task -> {
handleTaskStateUpdate(jobAndTasks.getLeft(), task, state).ifPresent(events::add);
allTasks.add(task);
});
});
// Cleanup, in case we have stale entries.
Set<String> unknownTaskIds = CollectionsExt.copyAndRemove(state.keySet(), allTasks.stream().map(Task::getId).collect(Collectors.toSet()));
unknownTaskIds.forEach(taskId -> {
state.remove(taskId);
// Assume the task was terminated.
ContainerHealthStatus terminatedStatus = ContainerHealthStatus.newBuilder().withTaskId(taskId).withTimestamp(titusRuntime.getClock().wallTime()).withState(ContainerHealthState.Terminated).withReason("terminated").build();
events.add(ContainerHealthUpdateEvent.healthChanged(terminatedStatus));
});
return Flux.fromIterable(events);
}
Aggregations