Search in sources :

Example 1 with ContainerHealthUpdateEvent

use of com.netflix.titus.api.containerhealth.model.event.ContainerHealthUpdateEvent in project titus-control-plane by Netflix.

the class EurekaContainerHealthService method handleTaskStateUpdate.

private Optional<ContainerHealthEvent> handleTaskStateUpdate(Job<?> job, Task task, ConcurrentMap<String, ContainerHealthEvent> state) {
    ContainerHealthUpdateEvent lastEvent = (ContainerHealthUpdateEvent) state.get(task.getId());
    if (lastEvent == null) {
        return Optional.of(recordNewState(state, task, ContainerHealthEvent.healthChanged(buildHealthStatus(job, task))));
    }
    ContainerHealthState newTaskState = takeStateOf(job, task);
    String newReason = takeStateReasonOf(job, task);
    if (lastEvent.getContainerHealthStatus().getState() == newTaskState && lastEvent.getContainerHealthStatus().getReason().equals(newReason)) {
        return Optional.empty();
    }
    return Optional.of(recordNewState(state, task, ContainerHealthEvent.healthChanged(buildHealthStatus(task, newTaskState, newReason))));
}
Also used : ContainerHealthState(com.netflix.titus.api.containerhealth.model.ContainerHealthState) ContainerHealthUpdateEvent(com.netflix.titus.api.containerhealth.model.event.ContainerHealthUpdateEvent)

Aggregations

ContainerHealthState (com.netflix.titus.api.containerhealth.model.ContainerHealthState)1 ContainerHealthUpdateEvent (com.netflix.titus.api.containerhealth.model.event.ContainerHealthUpdateEvent)1