use of com.netflix.titus.common.framework.scheduler.model.SchedulingStatus in project titus-control-plane by Netflix.
the class LocalSchedulerTransactionLogger method logScheduleUpdateEvent.
private static String logScheduleUpdateEvent(ScheduleUpdateEvent event) {
SchedulingStatus status = event.getSchedule().getCurrentAction().getStatus();
SchedulingState schedulingState = status.getState();
String summary;
switch(schedulingState) {
case Waiting:
summary = "Waiting...";
break;
case Running:
summary = "Running...";
break;
case Cancelling:
summary = "Schedule cancelled by a user";
break;
case Succeeded:
summary = "Scheduled action completed";
break;
case Failed:
summary = "Scheduled action failed: error=" + status.getError().map(Throwable::getMessage).orElse("<error_not_available>");
break;
default:
summary = "Unknown scheduling state: schedulingState=" + schedulingState;
}
return doFormat(event.getSchedule(), "ExecutionUpdate", summary);
}
use of com.netflix.titus.common.framework.scheduler.model.SchedulingStatus in project titus-control-plane by Netflix.
the class ScheduledActionExecutor method handleWaitingState.
private boolean handleWaitingState() {
long now = clock.wallTime();
if (action.getStatus().getExpectedStartTime() > now) {
return false;
}
SchedulingStatus oldStatus = action.getStatus();
this.action = action.toBuilder().withStatus(SchedulingStatus.newBuilder().withState(SchedulingState.Running).withTimestamp(now).build()).withStatusHistory(CollectionsExt.copyAndAdd(action.getStatusHistory(), oldStatus)).build();
this.schedule = schedule.toBuilder().withCurrentAction(action).build();
try {
this.retryer = descriptor.getRetryerSupplier().get();
this.actionCompleted = false;
this.error = null;
this.actionDisposable = actionProducer.apply(ExecutionContext.newBuilder().withId(schedule.getId()).withIteration(action.getExecutionId()).build()).timeout(descriptor.getTimeout()).subscribeOn(scheduler).publishOn(scheduler).doOnCancel(() -> actionCompleted = true).subscribe(next -> {
// Never
}, e -> {
if (logger.isDebugEnabled()) {
logger.warn("Action execution error: name={}", descriptor.getName(), e);
}
Throwable effectiveError = e;
if (e instanceof TimeoutException) {
effectiveError = new TimeoutException(String.format("Action did not complete in time: timeout=%sms", descriptor.getTimeout().toMillis()));
}
Throwable finalEffectiveError = effectiveError;
ExceptionExt.silent(() -> descriptor.getOnErrorHandler().accept(action, finalEffectiveError));
this.error = effectiveError;
this.actionCompleted = true;
}, () -> {
ExceptionExt.silent(() -> descriptor.getOnSuccessHandler().accept(action));
this.actionCompleted = true;
});
} catch (Exception e) {
logger.warn("Could not produce action: name={}", descriptor.getName(), e);
this.action = newFailedStatus();
}
return true;
}
use of com.netflix.titus.common.framework.scheduler.model.SchedulingStatus in project titus-control-plane by Netflix.
the class ScheduledActionExecutor method changeState.
private ScheduledAction changeState(Consumer<SchedulingStatus.Builder> updater) {
SchedulingStatus.Builder statusBuilder = SchedulingStatus.newBuilder().withTimestamp(clock.wallTime());
updater.accept(statusBuilder);
SchedulingStatus oldStatus = action.getStatus();
List<SchedulingStatus> statusHistory = CollectionsExt.copyAndAdd(action.getStatusHistory(), oldStatus);
return action.toBuilder().withStatus(statusBuilder.build()).withStatusHistory(statusHistory).build();
}
use of com.netflix.titus.common.framework.scheduler.model.SchedulingStatus 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();
}
Aggregations