use of com.vmware.xenon.common.TaskState in project photon-model by vmware.
the class IPAddressAllocationTaskService method failTask.
private void failTask(Throwable e, String messageFormat, Object... args) {
String message = String.format(messageFormat, args);
logWarning(() -> message);
IPAddressAllocationTaskState body = new IPAddressAllocationTaskState();
body.taskInfo = new TaskState();
body.taskInfo.stage = TaskState.TaskStage.FAILED;
body.taskInfo.failure = Utils.toServiceErrorResponse(e);
sendSelfPatch(body);
}
use of com.vmware.xenon.common.TaskState in project photon-model by vmware.
the class IPAddressAllocationTaskService 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(IPAddressAllocationTaskState startState, Operation startOp) {
if (startState.taskInfo == null || startState.taskInfo.stage == null) {
startState.taskInfo = new TaskState();
startState.taskInfo.stage = TaskState.TaskStage.CREATED;
}
startState.taskSubStage = IPAddressAllocationTaskState.SubStage.CREATED;
}
use of com.vmware.xenon.common.TaskState in project photon-model by vmware.
the class IPAddressAllocationTaskService method proceedTo.
private void proceedTo(IPAddressAllocationTaskState.SubStage nextSubstage, Consumer<IPAddressAllocationTaskState> patchBodyConfigurator) {
IPAddressAllocationTaskState state = new IPAddressAllocationTaskState();
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 ImageEnumerationTaskService 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(ImageEnumerationTaskState startState, Operation startOp) {
if (startState.options == null) {
startState.options = EnumSet.noneOf(TaskOption.class);
}
if (startState.taskInfo == null || startState.taskInfo.stage == null) {
startState.taskInfo = new TaskState();
startState.taskInfo.stage = TaskState.TaskStage.CREATED;
}
if (startState.documentExpirationTimeMicros <= 0) {
setExpiration(startState, DEFAULT_EXPIRATION_MINUTES, TimeUnit.MINUTES);
}
}
use of com.vmware.xenon.common.TaskState in project photon-model by vmware.
the class ProvisionDiskTaskService method sendSelfPatch.
private void sendSelfPatch(TaskStage newStage, ProvisionDiskTaskState.SubStage newSubStage, Throwable ex) {
ProvisionDiskTaskState patchBody = new ProvisionDiskTaskState();
patchBody.taskInfo = new TaskState();
patchBody.taskInfo.stage = newStage;
patchBody.taskSubStage = newSubStage;
if (ex != null) {
patchBody.taskInfo.failure = Utils.toServiceErrorResponse(ex);
}
Operation patch = Operation.createPatch(createInventoryUri(this.getHost(), getUri())).setBody(patchBody).setCompletion((o, e) -> {
if (e != null) {
logWarning(() -> String.format("Self patch failed: %s", com.vmware.xenon.common.Utils.toString(e)));
}
});
sendRequest(patch);
}
Aggregations