use of com.vmware.xenon.common.TaskState in project photon-model by vmware.
the class ProvisionDiskTaskService method validateState.
public void validateState(ProvisionDiskTaskState state) {
if (state.diskLink == null) {
throw new IllegalArgumentException("diskReference is required");
}
state.taskInfo = new TaskState();
state.taskInfo.stage = TaskStage.CREATED;
if (state.taskSubStage == null) {
throw new IllegalArgumentException("taskSubStage is required");
}
if (state.documentExpirationTimeMicros == 0) {
state.documentExpirationTimeMicros = Utils.getNowMicrosUtc() + ProvisionDiskTaskState.DEFAULT_EXPIRATION_MICROS;
}
}
use of com.vmware.xenon.common.TaskState in project photon-model by vmware.
the class ProvisionNetworkTaskService method handleStart.
@Override
public void handleStart(Operation start) {
if (!start.hasBody()) {
start.fail(new IllegalArgumentException("body is required"));
return;
}
ProvisionNetworkTaskState state = start.getBody(ProvisionNetworkTaskState.class);
try {
state.validate();
} catch (Exception e) {
start.fail(e);
}
state.taskInfo = new TaskState();
state.taskInfo.stage = TaskState.TaskStage.CREATED;
state.taskSubStage = SubStage.CREATED;
start.complete();
// start the task
sendSelfPatch(TaskState.TaskStage.CREATED, null);
}
use of com.vmware.xenon.common.TaskState in project photon-model by vmware.
the class ResourceAllocationTaskService method sendSelfPatch.
private void sendSelfPatch(TaskStage stage, SubStage subStage, Throwable e) {
ResourceAllocationTaskState body = new ResourceAllocationTaskState();
body.taskInfo = new TaskState();
if (e == null) {
body.taskInfo.stage = 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)));
}
sendSelfPatch(body);
}
use of com.vmware.xenon.common.TaskState in project photon-model by vmware.
the class ResourceRemovalTaskService method validateState.
public static void validateState(ResourceRemovalTaskState state) {
if (state.resourceQuerySpec == null) {
throw new IllegalArgumentException("resourceQuerySpec is required");
}
if (state.taskInfo == null || state.taskInfo.stage == null) {
state.taskInfo = new TaskState();
state.taskInfo.stage = TaskState.TaskStage.CREATED;
}
if (state.taskSubStage == null) {
state.taskSubStage = SubStage.WAITING_FOR_QUERY_COMPLETION;
}
if (state.documentExpirationTimeMicros == 0) {
state.documentExpirationTimeMicros = Utils.getNowMicrosUtc() + DEFAULT_TIMEOUT_MICROS;
}
}
use of com.vmware.xenon.common.TaskState in project photon-model by vmware.
the class ResourceRemovalTaskService method sendSelfPatch.
private void sendSelfPatch(TaskState.TaskStage stage, SubStage subStage, Consumer<ResourceRemovalTaskState> patchBodyConfigurator) {
ResourceRemovalTaskState body = new ResourceRemovalTaskState();
body.taskInfo = new TaskState();
body.taskInfo.stage = stage;
body.taskSubStage = subStage;
if (patchBodyConfigurator != null) {
patchBodyConfigurator.accept(body);
}
sendSelfPatch(body);
}
Aggregations