private JsonObject formatJobPlan(ClusterJob job) throws IOException { JsonObject jobJson = new JsonObject(); jobJson.addProperty("id", job.getJobId()); jobJson.addProperty("clusterId", job.getClusterId()); jobJson.addProperty("action", job.getClusterAction().name()); jobJson.addProperty("currentStage", job.getCurrentStageNumber()); JsonArray stagesJson = new JsonArray(); for (Set<String> stage : job.getStagedTasks()) { JsonArray stageJson = new JsonArray(); for (String taskId : stage) { ClusterTask task = clusterStore.getClusterTask(TaskId.fromString(taskId)); JsonObject taskJson = new JsonObject(); taskJson.addProperty("id", task.getTaskId()); taskJson.addProperty("taskName", task.getTaskName().name()); taskJson.addProperty("nodeId", task.getNodeId()); taskJson.addProperty("service", task.getService()); stageJson.add(taskJson); } stagesJson.add(stageJson); } jobJson.add("stages", stagesJson); return jobJson; }
ProvisionerAction action = taskOrder.get(i); TaskId retryTaskId = idService.getNewTaskId(JobId.fromString(task.getJobId())); ClusterTask retry = new ClusterTask(action, retryTaskId, task.getNodeId(), task.getService(), task.getClusterAction(), task.getClusterTemplateName(), task.getAccount()); retryTasks.add(retry);
void startNodeAction(ClusterTask clusterTask) throws IOException { // Update node properties if task is associated with a nodeId. // There are cases when we don't associate a nodeId with a task so that the node properties don't get overridden // by the task output. // Eg. deleting a box during a rollback operation since we reuse nodeIds. if (clusterTask.getNodeId() != null) { Node node = clusterStore.getNode(clusterTask.getNodeId()); if (node == null) { LOG.error("Cannot find node {} for task {} to update the properties", clusterTask.getNodeId(), clusterTask.getTaskId()); } else { nodeService.startAction(node, clusterTask.getTaskId(), clusterTask.getService(), clusterTask.getTaskName().name()); } } }
/** * Get the rollback task that should run if the given task fails. * * @param task Task that needs to get rolled back. * @return Cluster task that will roll back the given failed task. */ private ClusterTask getRollbackTask(ClusterTask task) { ProvisionerAction rollback = actions.getRollbackActions().get(task.getTaskName()); if (rollback == null) { return null; } TaskId rollbackTaskId = idService.getNewTaskId(JobId.fromString(task.getJobId())); ClusterTask rollbackTask = new ClusterTask(rollback, rollbackTaskId, task.getNodeId(), task.getService(), task.getClusterAction(), task.getClusterTemplateName(), task.getAccount()); return rollbackTask; }
if (service.getName().equals(task.getService())) { tService = service; break;
for (String taskId : job.getCurrentStage()) { ClusterTask task = clusterStore.getClusterTask(TaskId.fromString(taskId)); actionServices.add(new ActionService(task.getTaskName().name(), task.getService()));