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));
}
}
}
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);
}
Aggregations