@Override protected void sendSelfPatch(State taskState, TaskState.TaskStage stage, Consumer<State> updateTaskState) { taskState.failureMessage = ""; super.sendSelfPatch(taskState, stage, updateTaskState); }
/** * Send ourselves a PATCH to indicate successful completion of task */ protected void sendSelfFinishedPatch(T task) { sendSelfPatch(task, TaskState.TaskStage.FINISHED, null); }
/** * Send ourselves a PATCH that will indicate failure */ protected void sendSelfFailurePatch(T task, String failureMessage) { sendSelfPatch(task, TaskState.TaskStage.FAILED, (s) -> s.failureMessage = failureMessage); }
/** * Send ourselves a PATCH that will indicate cancellation */ protected void sendSelfCancellationPatch(T task, String cancellationMessage) { sendSelfPatch(task, TaskState.TaskStage.CANCELLED, (s) -> s.failureMessage = cancellationMessage); }
/** * Send ourselves a PATCH that will advance to another step in the task workflow to the * specified stage and substage. * * @param taskState the task's state to use for the PATCH * @param stage the next stage to advance to * @param updateTaskState lambda helper for setting any custom field in the task's state (such * as SubStage). If null, it will be ignored. */ protected void sendSelfPatch(T taskState, TaskState.TaskStage stage, Consumer<T> updateTaskState) { if (taskState.taskInfo == null) { taskState.taskInfo = new TaskState(); } taskState.taskInfo.stage = stage; if (updateTaskState != null) { updateTaskState.accept(taskState); } sendSelfPatch(taskState); } }
/** * This handles the initial {@code POST} that creates the task service. Most subclasses won't * need to override this method, although they likely want to override the {@link * #validateStartPost(Operation)} and {@link #initializeState(TaskServiceState, Operation)} * methods. */ @Override public void handleStart(Operation taskOperation) { T task = validateStartPost(taskOperation); if (task == null) { return; } taskOperation.complete(); if (!ServiceHost.isServiceCreate(taskOperation) || (task.taskInfo != null && !TaskState.isCreated(task.taskInfo))) { // Skip self patch to STARTED if this is a restart operation, or, task stage is // other than CREATED. // Tasks that handle restart should override handleStart and decide if they should // continue processing on restart, or fail return; } initializeState(task, taskOperation); sendSelfPatch(task); }