Search in sources :

Example 1 with ContainerHealthSnapshotEvent

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

the class ContainerHealthAsserts method assertContainerHealthSnapshot.

@SafeVarargs
public static void assertContainerHealthSnapshot(ContainerHealthEvent event, Predicate<ContainerHealthStatus>... predicates) {
    assertThat(event).isInstanceOf(ContainerHealthSnapshotEvent.class);
    ContainerHealthSnapshotEvent snapshotEvent = (ContainerHealthSnapshotEvent) event;
    List<ContainerHealthStatus> snapshotEvents = snapshotEvent.getSnapshot();
    assertThat(snapshotEvents).describedAs("Expecting %s events, but got %s", predicates.length, snapshotEvents.size()).hasSize(predicates.length);
    for (int i = 0; i < snapshotEvents.size(); i++) {
        if (!predicates[i].test(snapshotEvents.get(i))) {
            fail("Event %s does not match its predicate: event=%s", i, snapshotEvents.get(i));
        }
    }
}
Also used : ContainerHealthStatus(com.netflix.titus.api.containerhealth.model.ContainerHealthStatus) ContainerHealthSnapshotEvent(com.netflix.titus.api.containerhealth.model.event.ContainerHealthSnapshotEvent)

Example 2 with ContainerHealthSnapshotEvent

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

the class AggregatingContainerHealthService method buildCurrentSnapshot.

private ContainerHealthSnapshotEvent buildCurrentSnapshot() {
    List<ContainerHealthStatus> snapshot = new ArrayList<>();
    jobOperations.getJobsAndTasks().forEach(p -> {
        Job job = p.getLeft();
        p.getRight().forEach(task -> {
            if (task.getStatus().getState() == TaskState.Finished) {
                snapshot.add(ContainerHealthStatus.terminated(task.getId(), titusRuntime.getClock().wallTime()));
            } else {
                snapshot.add(takeStatusOf(job, task));
            }
        });
    });
    return new ContainerHealthSnapshotEvent(snapshot);
}
Also used : ContainerHealthStatus(com.netflix.titus.api.containerhealth.model.ContainerHealthStatus) ArrayList(java.util.ArrayList) ContainerHealthSnapshotEvent(com.netflix.titus.api.containerhealth.model.event.ContainerHealthSnapshotEvent) Job(com.netflix.titus.api.jobmanager.model.job.Job)

Aggregations

ContainerHealthStatus (com.netflix.titus.api.containerhealth.model.ContainerHealthStatus)2 ContainerHealthSnapshotEvent (com.netflix.titus.api.containerhealth.model.event.ContainerHealthSnapshotEvent)2 Job (com.netflix.titus.api.jobmanager.model.job.Job)1 ArrayList (java.util.ArrayList)1