public ClusterTask(ProvisionerAction taskName, TaskId taskId, String nodeId, String service, ClusterAction clusterAction, String clusterTemplateName, Account account) { this.taskId = taskId.getId(); this.jobId = String.valueOf(taskId.getJobId().getId()); this.clusterId = taskId.getClusterId(); this.taskName = taskName; this.clusterAction = clusterAction; this.nodeId = nodeId; this.service = service; this.attempts = Lists.newArrayList(); //TODO: populate clusterTemplateName and account field for existing tasks: https://issues.cask.co/browse/COOPR-593 this.clusterTemplateName = clusterTemplateName; this.account = account; addAttempt(); }
ClusterTask scheduleRetry(ClusterJob job, ClusterTask task) throws Exception { task.addAttempt(); List<ClusterTask> retryTasks = taskService.getRetryTask(task); if (retryTasks.size() == 1) { LOG.trace("Only one retry task for job {} for task {}", job, task); return retryTasks.get(0); } // store all retry tasks for (ClusterTask t : retryTasks) { clusterStore.writeClusterTask(t); } // Remove self from current stage job.getCurrentStage().remove(task.getTaskId()); // Add first retry task to current stage job.getCurrentStage().add(retryTasks.get(0).getTaskId()); // Add the rest of retry tasks after current stage. TODO: this needs to be revisited. job.insertTasksAfterCurrentStage(ImmutableList.copyOf(Iterables.transform(Iterables.skip(retryTasks, 1), CLUSTER_TASK_STRING_FUNCTION))); LOG.trace("Retry job {} for task {}", job, task); return retryTasks.get(0); }