@Override protected StatsAggregationTaskState validateStartPost(Operation postOp) { StatsAggregationTaskState state = super.validateStartPost(postOp); if (state == null) { return null; } if (state.query == null) { postOp.fail(new IllegalArgumentException("query needs to be specified")); return null; } if (state.metricNames == null || state.metricNames.isEmpty()) { postOp.fail(new IllegalStateException("metricNames should not be null or empty")); return null; } return state; }
@Override protected SingleResourceStatsAggregationTaskState validateStartPost(Operation postOp) { SingleResourceStatsAggregationTaskState state = super.validateStartPost(postOp); if (state == null) { return null; } if (state.resourceLink == null) { postOp.fail(new IllegalArgumentException("resourceLink needs to be specified")); return null; } if (state.metricNames == null || state.metricNames.isEmpty()) { postOp.fail(new IllegalArgumentException("metricNames needs to be specified")); return null; } return state; }
@Override protected StatsAggregationTaskState validateStartPost(Operation postOp) { StatsAggregationTaskState state = super.validateStartPost(postOp); if (state == null) { return null; } if (state.query == null) { postOp.fail(new IllegalArgumentException("query needs to be specified")); return null; } if (state.metricNames == null || state.metricNames.isEmpty()) { postOp.fail(new IllegalStateException("metricNames should not be null or empty")); return null; } return state; }
@Override protected SingleResourceStatsAggregationTaskState validateStartPost(Operation postOp) { SingleResourceStatsAggregationTaskState state = super.validateStartPost(postOp); if (state == null) { return null; } if (state.resourceLink == null) { postOp.fail(new IllegalArgumentException("resourceLink needs to be specified")); return null; } if (state.metricNames == null || state.metricNames.isEmpty()) { postOp.fail(new IllegalArgumentException("metricNames needs to be specified")); return null; } return state; }
@Override protected SingleResourceStatsCollectionTaskState validateStartPost(Operation postOp) { SingleResourceStatsCollectionTaskState state = super.validateStartPost(postOp); if (state == null) { return null; } if (state.computeLink == null) { postOp.fail(new IllegalArgumentException("computeReference needs to be specified")); return null; } if (state.parentTaskReference == null) { postOp.fail(new IllegalArgumentException("parentTaskReference needs to be specified")); return null; } if (state.parentPatchBody == null) { postOp.fail(new IllegalArgumentException("parentPatchBody needs to be specified")); return null; } return state; }
@Override protected SingleResourceStatsCollectionTaskState validateStartPost(Operation postOp) { SingleResourceStatsCollectionTaskState state = super.validateStartPost(postOp); if (state == null) { return null; } if (state.computeLink == null) { postOp.fail(new IllegalArgumentException("computeReference needs to be specified")); return null; } if (state.parentTaskReference == null) { postOp.fail(new IllegalArgumentException("parentTaskReference needs to be specified")); return null; } if (state.parentPatchBody == null) { postOp.fail(new IllegalArgumentException("parentPatchBody needs to be specified")); return null; } return state; }
/** * Validates that a new task service has been requested appropriately (and that the request * doesn't provide values for internal-only fields). * * @see TaskService#validateStartPost(Operation) */ @Override protected NodeGroupMigrationState validateStartPost(Operation taskOperation) { NodeGroupMigrationState task = super.validateStartPost(taskOperation); if (task != null) { if (task.subStage != null) { taskOperation.fail( new IllegalArgumentException("Do not specify subStage: internal use only")); return null; } if (task.sourceNodeReference == null) { taskOperation.fail(new IllegalArgumentException("sourceNodeReference cannot be empty")); return null; } if (task.destinationNodeReference == null) { taskOperation.fail(new IllegalArgumentException("destinationNodeReference cannot be empty")); return null; } } return task; }
/** * This method validates the initial state of a task. * @param startOp Supplies the POST {@link Operation} which has caused this task to be created. * @return A {@link DemoTaskState} initialized from the operation, or null on failure. */ @Override protected DemoTaskState validateStartPost(Operation startOp) { DemoTaskState taskState = super.validateStartPost(startOp); if (taskState == null) { return null; } if (!ServiceHost.isServiceCreate(startOp)) { return taskState; } if (taskState.taskInfo != null && taskState.taskInfo.stage != null) { startOp.fail(new IllegalArgumentException("taskInfo.stage may not be specified")); return null; } if (taskState.subStage != null) { startOp.fail(new IllegalArgumentException("subStage may not be specified")); return null; } // Additional input validation should go here. return taskState; }
ImageEnumerationTaskState taskState = super.validateStartPost(startOp);
@Override protected State validateStartPost(Operation post) { State task = super.validateStartPost(post); if (task == null) { return null;
@Override protected EndpointRemovalTaskState validateStartPost(Operation taskOperation) { EndpointRemovalTaskState task = super.validateStartPost(taskOperation); if (task == null) { return null; } if (TaskState.isCancelled(task.taskInfo) || TaskState.isFailed(task.taskInfo) || TaskState.isFinished(task.taskInfo)) { return null; } if (!ServiceHost.isServiceCreate(taskOperation)) { return task; } if (task.endpointLink == null) { taskOperation.fail(new IllegalArgumentException("endpointLink is required")); return null; } return task; }
@Override protected EndpointRemovalTaskState validateStartPost(Operation taskOperation) { EndpointRemovalTaskState task = super.validateStartPost(taskOperation); if (task == null) { return null; } if (TaskState.isCancelled(task.taskInfo) || TaskState.isFailed(task.taskInfo) || TaskState.isFinished(task.taskInfo)) { return null; } if (!ServiceHost.isServiceCreate(taskOperation)) { return task; } if (task.endpointLink == null) { taskOperation.fail(new IllegalArgumentException("endpointLink is required")); return null; } return task; }
@Override protected EndpointAllocationTaskState validateStartPost(Operation taskOperation) { EndpointAllocationTaskState task = super.validateStartPost(taskOperation); if (task == null) { return null; } if (TaskState.isCancelled(task.taskInfo) || TaskState.isFailed(task.taskInfo) || TaskState.isFinished(task.taskInfo)) { return null; } if (!ServiceHost.isServiceCreate(taskOperation)) { return task; } if (task.endpointState == null) { taskOperation.fail(new IllegalArgumentException("endpointState is required")); return null; } if (task.endpointState.endpointType == null) { taskOperation.fail(new IllegalArgumentException("endpointType is required")); return null; } return task; }
@Override protected EndpointAllocationTaskState validateStartPost(Operation taskOperation) { EndpointAllocationTaskState task = super.validateStartPost(taskOperation); if (task == null) { return null; } if (TaskState.isCancelled(task.taskInfo) || TaskState.isFailed(task.taskInfo) || TaskState.isFinished(task.taskInfo)) { return null; } if (!ServiceHost.isServiceCreate(taskOperation)) { return task; } if (task.endpointState == null) { taskOperation.fail(new IllegalArgumentException("endpointState is required")); return null; } if (task.endpointState.endpointType == null) { taskOperation.fail(new IllegalArgumentException("endpointType is required")); return null; } return task; }
ExampleTaskServiceState task = super.validateStartPost(taskOperation); if (task == null) { return null;
ImageEnumerationTaskState taskState = super.validateStartPost(startOp);
@Override protected GraphQueryTask validateStartPost(Operation taskOperation) { GraphQueryTask task = super.validateStartPost(taskOperation); if (task == null) { return null;
/** * 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); }