use of com.vmware.xenon.common.TaskState in project photon-model by vmware.
the class ResourceIPDeallocationTaskService method initializeState.
/**
* Customize the initialization logic (set the task with default values) that's part of initial
* {@code POST} creating the task service.
*
* @see #handleStart(Operation)
*/
@Override
protected void initializeState(ResourceIPDeallocationTaskState startState, Operation startOp) {
if (startState.taskInfo == null || startState.taskInfo.stage == null) {
startState.taskInfo = new TaskState();
startState.taskInfo.stage = TaskState.TaskStage.CREATED;
}
startState.taskSubStage = ResourceIPDeallocationTaskState.SubStage.CREATED;
}
use of com.vmware.xenon.common.TaskState in project photon-model by vmware.
the class ResourceIPDeallocationTaskService method proceedTo.
private void proceedTo(ResourceIPDeallocationTaskState.SubStage nextSubstage, Consumer<ResourceIPDeallocationTaskState> patchBodyConfigurator) {
ResourceIPDeallocationTaskState state = new ResourceIPDeallocationTaskState();
state.taskInfo = new TaskState();
state.taskSubStage = nextSubstage;
sendSelfPatch(state, TaskState.TaskStage.STARTED, patchBodyConfigurator);
}
use of com.vmware.xenon.common.TaskState in project photon-model by vmware.
the class EndpointAllocationTaskService method createUpdateSubStageTask.
private EndpointAllocationTaskState createUpdateSubStageTask(TaskStage stage, SubStage subStage, Throwable e) {
EndpointAllocationTaskState body = new EndpointAllocationTaskState();
body.taskInfo = new TaskState();
if (e == null) {
body.taskInfo.stage = stage == null ? TaskStage.STARTED : stage;
body.taskSubStage = subStage;
} else {
body.taskInfo.stage = TaskStage.FAILED;
body.taskInfo.failure = Utils.toServiceErrorResponse(e);
logWarning(() -> String.format("Patching to failed: %s", Utils.toString(e)));
}
return body;
}
use of com.vmware.xenon.common.TaskState in project photon-model by vmware.
the class ProvisionNetworkTaskService method sendSelfPatch.
private void sendSelfPatch(TaskState.TaskStage stage, Throwable e) {
ProvisionNetworkTaskState body = new ProvisionNetworkTaskState();
body.taskInfo = new TaskState();
if (e == null) {
body.taskInfo.stage = stage;
} else {
body.taskInfo.stage = TaskState.TaskStage.FAILED;
body.taskInfo.failure = Utils.toServiceErrorResponse(e);
logWarning(() -> String.format("Patching to failed: %s", Utils.toString(e)));
}
sendSelfPatch(body);
}
use of com.vmware.xenon.common.TaskState in project photon-model by vmware.
the class NicSecurityGroupsTaskService method handleStart.
@Override
public void handleStart(Operation start) {
if (!start.hasBody()) {
start.fail(new IllegalArgumentException("body is required"));
return;
}
NicSecurityGroupsTaskState state = start.getBody(NicSecurityGroupsTaskState.class);
try {
Utils.validateState(getStateDescription(), state);
} catch (Exception e) {
start.fail(e);
return;
}
validateSecurityGroupsEndpoint(state).whenComplete((ignore, e) -> {
if (e != null) {
start.fail(e);
return;
}
state.taskInfo = new TaskState();
state.taskInfo.stage = TaskState.TaskStage.CREATED;
state.taskSubStage = SubStage.CREATED;
start.complete();
// start the task
sendSelfPatch(TaskState.TaskStage.CREATED, null);
});
}
Aggregations