use of com.netflix.titus.common.framework.scheduler.ScheduleReference in project titus-control-plane by Netflix.
the class DefaultLocalSchedulerPerf method newAction.
private ScheduleReference newAction(boolean failSometimes) {
int intervalMs = 50;
ScheduleReference reference = localScheduler.schedule(ScheduleDescriptor.newBuilder().withName("runnableAction").withDescription("Test...").withInterval(Duration.ofMillis(intervalMs)).withTimeout(Duration.ofSeconds(1)).build(), context -> {
checkSchedulingLatency(intervalMs, context);
if (context.getExecutionId().getTotal() > EXECUTIONS) {
localScheduler.cancel(context.getId()).subscribe();
return;
}
if (failSometimes && context.getExecutionId().getTotal() % 2 == 0) {
expectedFailures.incrementAndGet();
throw new RuntimeException("Simulated error");
}
try {
Thread.sleep(10);
successes.incrementAndGet();
} catch (InterruptedException ignore) {
}
}, true);
observeEvents(reference);
return reference;
}
use of com.netflix.titus.common.framework.scheduler.ScheduleReference in project titus-control-plane by Netflix.
the class DefaultLocalSchedulerTest method testRetries.
@Test
public void testRetries() throws InterruptedException {
AtomicInteger counter = new AtomicInteger();
ScheduleReference reference = localScheduler.scheduleMono(scheduleDescriptor.toBuilder().withName("testRetries").build(), tick -> Mono.defer(() -> counter.incrementAndGet() % 2 == 0 ? Mono.empty() : Mono.error(new RuntimeException("Simulated error at iteration " + counter.get()))), Schedulers.parallel());
expectScheduleAdded(reference);
expectScheduleUpdateEvent(SchedulingState.Running);
expectScheduleUpdateEvent(SchedulingState.Failed);
expectScheduleUpdateEvent(SchedulingState.Waiting);
expectScheduleUpdateEvent(SchedulingState.Running);
expectScheduleUpdateEvent(SchedulingState.Succeeded);
}
Aggregations