Search in sources :

Example 1 with ContainerHealthState

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

the class AggregatingContainerHealthService method handleNewState.

private Flux<ContainerHealthEvent> handleNewState(Job<?> job, Task task, ConcurrentMap<String, ContainerHealthState> emittedStates) {
    ContainerHealthStatus newStatus = takeStatusOf(job, task);
    ContainerHealthState previousState = emittedStates.get(task.getId());
    ContainerHealthState newState = newStatus.getState();
    if (newState == previousState) {
        return Flux.empty();
    }
    if (newState == ContainerHealthState.Terminated) {
        emittedStates.remove(task.getId());
    } else {
        emittedStates.put(task.getId(), newState);
    }
    return Flux.just(ContainerHealthEvent.healthChanged(newStatus));
}
Also used : ContainerHealthStatus(com.netflix.titus.api.containerhealth.model.ContainerHealthStatus) ContainerHealthState(com.netflix.titus.api.containerhealth.model.ContainerHealthState)

Example 2 with ContainerHealthState

use of com.netflix.titus.api.containerhealth.model.ContainerHealthState 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)2 ContainerHealthStatus (com.netflix.titus.api.containerhealth.model.ContainerHealthStatus)1 ContainerHealthUpdateEvent (com.netflix.titus.api.containerhealth.model.event.ContainerHealthUpdateEvent)1