private boolean allCreateTasksFailed(ClusterJob job) throws IOException { for (Map.Entry<String, ClusterTask.Status> entry : job.getTaskStatus().entrySet()) { String taskId = entry.getKey(); ClusterTask.Status taskStatus = entry.getValue(); // no task can succeed or be in progress if (taskStatus == ClusterTask.Status.COMPLETE || taskStatus == ClusterTask.Status.IN_PROGRESS) { return false; } if (taskStatus == ClusterTask.Status.FAILED) { // looks up every failed task... not so great. But it should be roughly equal to the # of nodes in the cluster. ClusterTask task = clusterStore.getClusterTask(TaskId.fromString(taskId)); // check it is a create task if (!task.failedBeforeCreate()) { return false; } } } // if we get here, we only have failed, dropped, or not submitted tasks, and all the failed tasks failed before // they could create anything return true; }