/** * Sets the status of the given job to {@link ClusterJob.Status#FAILED} and the status of the given cluster to * {@link co.cask.coopr.cluster.Cluster.Status#TERMINATED}. * * @param job Job to fail. * @param cluster Cluster to terminate. * @param message Error message. * @throws IOException */ public void failJobAndTerminateCluster(ClusterJob job, Cluster cluster, String message) throws IOException, IllegalAccessException { failJobAndSetClusterStatus(job, cluster, Cluster.Status.TERMINATED, message); }
/** * Sets the status of the given job to {@link ClusterJob.Status#FAILED} and the status of the cluster to the default * failure status as given in {@link co.cask.coopr.scheduler.ClusterAction#getFailureStatus()}. * * @param job Job to fail. * @param cluster Cluster to set the status for. * @throws IOException */ public void failJobAndSetClusterStatus(ClusterJob job, Cluster cluster) throws IOException, IllegalAccessException { failJobAndSetClusterStatus(job, cluster, job.getClusterAction().getFailureStatus(), null); }
taskService.failJobAndSetClusterStatus(toFailJob, cluster, clusterStatus, "Exception while solving layout."); break;
} else { taskService.failJobAndSetClusterStatus(job, cluster);
private void onStart(CallbackData callbackData, CallbackContext callbackContext) { ClusterJob job = callbackData.getJob(); Cluster cluster = callbackData.getCluster(); try { if (clusterCallback.onStart(callbackData, callbackContext)) { String jobId = callbackData.getJob().getJobId(); jobQueues.add(gElement.getQueueName(), new Element(jobId)); LOG.debug("added job {} to job queue", jobId); } else { switch (job.getClusterAction()) { case CLUSTER_CREATE: taskService.failJobAndTerminateCluster(job, cluster, "Cluster creation stopped by failed start callback."); break; default: // failed to plan means the job should fail, but state has already been changed so the cluster // state in the db is inconsistent with reality. // TODO: Should revert it here but need versioning or cluster history or something to that effect. taskService.failJobAndSetClusterStatus( job, cluster, Cluster.Status.INCONSISTENT, "Failed to schedule the " + job.getClusterAction() + " operation."); break; } } } catch (Exception e) { LOG.error("Exception failing job {} for cluster {}", job.getJobId(), cluster.getId(), e); } } }
taskService.failJobAndSetClusterStatus(job, cluster, Cluster.Status.INCONSISTENT, "Failed to schedule the " + clusterAction + " operation."); break;