Search in sources :

Example 1 with ScheduledAction

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);
}
Also used : ScheduleReference(com.netflix.titus.common.framework.scheduler.ScheduleReference) ScheduledAction(com.netflix.titus.common.framework.scheduler.model.ScheduledAction) Test(org.junit.Test)

Example 2 with ScheduledAction

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();
}
Also used : SchedulingStatus(com.netflix.titus.common.framework.scheduler.model.SchedulingStatus) ScheduledAction(com.netflix.titus.common.framework.scheduler.model.ScheduledAction)

Example 3 with ScheduledAction

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();
        }
    }
}
Also used : ScheduledAction(com.netflix.titus.common.framework.scheduler.model.ScheduledAction)

Example 4 with ScheduledAction

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();
        }
    });
}
Also used : SchedulingStatus(com.netflix.titus.common.framework.scheduler.model.SchedulingStatus) Clocks(com.netflix.titus.common.util.time.Clocks) ExecutionContext(com.netflix.titus.common.framework.scheduler.ExecutionContext) ScheduleRemovedEvent(com.netflix.titus.common.framework.scheduler.model.event.ScheduleRemovedEvent) Set(java.util.Set) Mono(reactor.core.publisher.Mono) ScheduleReference(com.netflix.titus.common.framework.scheduler.ScheduleReference) HashSet(java.util.HashSet) AtomicLong(java.util.concurrent.atomic.AtomicLong) DefaultRegistry(com.netflix.spectator.api.DefaultRegistry) ScheduleDescriptor(com.netflix.titus.common.framework.scheduler.model.ScheduleDescriptor) Duration(java.time.Duration) ScheduleUpdateEvent(com.netflix.titus.common.framework.scheduler.model.event.ScheduleUpdateEvent) Schedulers(reactor.core.scheduler.Schedulers) ScheduledAction(com.netflix.titus.common.framework.scheduler.model.ScheduledAction) LocalScheduler(com.netflix.titus.common.framework.scheduler.LocalScheduler) ScheduleRemovedEvent(com.netflix.titus.common.framework.scheduler.model.event.ScheduleRemovedEvent) ScheduledAction(com.netflix.titus.common.framework.scheduler.model.ScheduledAction) ScheduleUpdateEvent(com.netflix.titus.common.framework.scheduler.model.event.ScheduleUpdateEvent)

Aggregations

ScheduledAction (com.netflix.titus.common.framework.scheduler.model.ScheduledAction)4 ScheduleReference (com.netflix.titus.common.framework.scheduler.ScheduleReference)2 SchedulingStatus (com.netflix.titus.common.framework.scheduler.model.SchedulingStatus)2 DefaultRegistry (com.netflix.spectator.api.DefaultRegistry)1 ExecutionContext (com.netflix.titus.common.framework.scheduler.ExecutionContext)1 LocalScheduler (com.netflix.titus.common.framework.scheduler.LocalScheduler)1 ScheduleDescriptor (com.netflix.titus.common.framework.scheduler.model.ScheduleDescriptor)1 ScheduleRemovedEvent (com.netflix.titus.common.framework.scheduler.model.event.ScheduleRemovedEvent)1 ScheduleUpdateEvent (com.netflix.titus.common.framework.scheduler.model.event.ScheduleUpdateEvent)1 Clocks (com.netflix.titus.common.util.time.Clocks)1 Duration (java.time.Duration)1 HashSet (java.util.HashSet)1 Set (java.util.Set)1 AtomicLong (java.util.concurrent.atomic.AtomicLong)1 Test (org.junit.Test)1 Mono (reactor.core.publisher.Mono)1 Schedulers (reactor.core.scheduler.Schedulers)1