use of com.vmware.xenon.common.TaskState in project photon-model by vmware.
the class ResourceEnumerationTaskService method validateState.
public static void validateState(ResourceEnumerationTaskState state) {
if (state.resourcePoolLink == null) {
throw new IllegalArgumentException("resourcePoolLink is required.");
}
if (state.adapterManagementReference == null) {
throw new IllegalArgumentException("adapterManagementReference is required.");
}
if (state.options == null) {
state.options = EnumSet.noneOf(TaskOption.class);
}
if (state.taskInfo == null || state.taskInfo.stage == null) {
state.taskInfo = new TaskState();
state.taskInfo.stage = TaskState.TaskStage.CREATED;
}
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 ResourceIPDeallocationTaskService method failTask.
private void failTask(Throwable e, String messageFormat, Object... args) {
String message = String.format(messageFormat, args);
logWarning(() -> message);
ResourceIPDeallocationTaskState body = new ResourceIPDeallocationTaskState();
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 SnapshotTaskService method sendSelfPatch.
private void sendSelfPatch(TaskState.TaskStage nextStage, Throwable error) {
SnapshotTaskState body = new SnapshotTaskState();
body.taskInfo = new TaskState();
if (error != null) {
body.taskInfo.stage = TaskState.TaskStage.FAILED;
body.taskInfo.failure = Utils.toServiceErrorResponse(error);
} else {
body.taskInfo.stage = nextStage;
}
sendSelfPatch(body);
}
use of com.vmware.xenon.common.TaskState in project photon-model by vmware.
the class MockAdapter method createFailedTaskInfo.
public static TaskState createFailedTaskInfo() {
TaskState taskState = new TaskState();
taskState.stage = TaskState.TaskStage.FAILED;
taskState.failure = ServiceErrorResponse.create(new IllegalStateException("Mock adapter failing task on purpose"), 500);
return taskState;
}
use of com.vmware.xenon.common.TaskState in project photon-model by vmware.
the class AWSPowerServiceTest method configureEndpoint.
private EndpointState configureEndpoint() throws Throwable {
EndpointState ep = createEndpointState();
EndpointAllocationTaskState configureEndpoint = new EndpointAllocationTaskState();
configureEndpoint.endpointState = ep;
configureEndpoint.options = this.isMock ? EnumSet.of(TaskOption.IS_MOCK) : null;
configureEndpoint.taskInfo = new TaskState();
configureEndpoint.taskInfo.isDirect = true;
EndpointAllocationTaskState outTask = TestUtils.doPost(this.host, configureEndpoint, EndpointAllocationTaskState.class, UriUtils.buildUri(this.host, EndpointAllocationTaskService.FACTORY_LINK));
// outTask.documentSelfLink);
return outTask.endpointState;
}
Aggregations