use of com.netflix.titus.common.framework.scheduler.model.ScheduledAction in project titus-control-plane by Netflix.
the class DefaultLocalSchedulerTest method testTimeout.
@Test
public void testTimeout() throws Exception {
ScheduleReference reference = localScheduler.scheduleMono(scheduleDescriptor.toBuilder().withName("testTimeout").build(), tick -> Mono.never(), Schedulers.parallel());
expectScheduleAdded(reference);
expectScheduleUpdateEvent(SchedulingState.Running);
expectScheduleUpdateEvent(SchedulingState.Failed);
// Replacement
expectScheduleUpdateEvent(SchedulingState.Waiting);
assertThat(reference.getSchedule().getCompletedActions()).hasSize(1);
ScheduledAction failedAction = reference.getSchedule().getCompletedActions().get(0);
assertThat(failedAction.getStatus().getState()).isEqualTo(SchedulingState.Failed);
assertThat(failedAction.getStatus().getError().get()).isInstanceOf(TimeoutException.class);
}
use of com.netflix.titus.common.framework.scheduler.model.ScheduledAction in project titus-control-plane by Netflix.
the class LocalSchedulerTransactionLogger method toElapsedMs.
private static long toElapsedMs(Schedule schedule) {
SchedulingStatus currentStatus = schedule.getCurrentAction().getStatus();
if (currentStatus.getState() != SchedulingState.Waiting) {
List<SchedulingStatus> statusHistory = schedule.getCurrentAction().getStatusHistory();
return currentStatus.getTimestamp() - last(statusHistory).getTimestamp();
}
// Report time between the new action, and the previous one
if (schedule.getCompletedActions().isEmpty()) {
return 0;
}
ScheduledAction previousAction = last(schedule.getCompletedActions());
return currentStatus.getTimestamp() - previousAction.getStatus().getTimestamp();
}
use of com.netflix.titus.common.framework.scheduler.model.ScheduledAction in project titus-control-plane by Netflix.
the class DefaultLocalSchedulerPerf method checkSchedulingLatency.
private void checkSchedulingLatency(int intervalMs, ExecutionContext context) {
if (context.getPreviousAction().isPresent()) {
ScheduledAction previous = context.getPreviousAction().get();
long actualDelayMs = System.currentTimeMillis() - previous.getStatus().getTimestamp();
if (actualDelayMs < intervalMs) {
tooFastSchedules.incrementAndGet();
}
if (actualDelayMs > 2 * intervalMs) {
delayedSchedules.incrementAndGet();
}
}
}
use of com.netflix.titus.common.framework.scheduler.model.ScheduledAction in project titus-control-plane by Netflix.
the class DefaultLocalSchedulerPerf method observeEvents.
private void observeEvents(ScheduleReference reference) {
localScheduler.events().filter(e -> e.getSchedule().getId().equals(reference.getSchedule().getId())).subscribe(event -> {
if (event instanceof ScheduleUpdateEvent) {
ScheduleUpdateEvent updateEvent = (ScheduleUpdateEvent) event;
ScheduledAction action = updateEvent.getSchedule().getCurrentAction();
if (action.getStatus().getState() == SchedulingStatus.SchedulingState.Failed) {
eventFailures.incrementAndGet();
}
} else if (event instanceof ScheduleRemovedEvent) {
removedEvents.incrementAndGet();
}
});
}
Aggregations