/** * Sets the status of the given job to {@link ClusterJob.Status#FAILED} and persists it to the store. * * @param job Job to fail. * @throws IOException */ public void failJob(ClusterJob job) throws IOException { job.setJobStatus(ClusterJob.Status.FAILED); clusterStore.writeClusterJob(job); }
/** * Sets the status of the given job to {@link ClusterJob.Status#RUNNING} and add it to the queue to be run. * * @param job Job to start. * @param cluster Cluster the job is for. * @throws IOException */ public void startJob(ClusterJob job, Cluster cluster) throws IOException { // TODO: wrap in a transaction LOG.debug("Starting job {} for cluster {}", job.getJobId(), cluster.getId()); job.setJobStatus(ClusterJob.Status.RUNNING); // Note: writing job status as RUNNING, will allow other operations on the job // (like cancel, etc.) to happen in parallel. clusterStore.writeClusterJob(job); callbackQueues.add(cluster.getAccount().getTenantId(), new Element(gson.toJson(new CallbackData(CallbackData.Type.START, cluster, job)))); }
clusterJob.setJobStatus(ClusterJob.Status.PAUSED); clusterJob.setStatusMessage("Paused by user."); clusterStore.writeClusterJob(clusterJob);
SolverRequest solverRequest = gson.fromJson(solveElement.getValue(), SolverRequest.class); try { solverJob.setJobStatus(ClusterJob.Status.RUNNING); clusterStore.writeClusterJob(solverJob);
solverJob.setJobStatus(ClusterJob.Status.COMPLETE); clusterStore.writeClusterJob(solverJob);
clusterJob.setJobStatus(ClusterJob.Status.RUNNING); clusterJob.setStatusMessage("Resumed by user."); clusterStore.writeClusterJob(clusterJob);
job.setJobStatus(ClusterJob.Status.RUNNING); cluster.setLatestJobId(job.getJobId()); cluster.setStatus(Cluster.Status.PENDING);
solverJob.setJobStatus(ClusterJob.Status.COMPLETE); clusterStore.writeClusterJob(solverJob);
job.setJobStatus(ClusterJob.Status.RUNNING); cluster.setLatestJobId(job.getJobId()); cluster.setStatus(Cluster.Status.PENDING);
JobId deleteJobId = idService.getNewJobId(clusterId); ClusterJob deleteJob = new ClusterJob(deleteJobId, ClusterAction.CLUSTER_DELETE); deleteJob.setJobStatus(ClusterJob.Status.RUNNING); cluster.setLatestJobId(deleteJobId.getId()); cluster.setStatus(Cluster.Status.PENDING);
restartServices ? ClusterAction.CLUSTER_CONFIGURE_WITH_RESTART : ClusterAction.CLUSTER_CONFIGURE; ClusterJob configureJob = new ClusterJob(configureJobId, action); configureJob.setJobStatus(ClusterJob.Status.RUNNING); cluster.setLatestJobId(configureJobId.getId()); cluster.setStatus(Cluster.Status.PENDING);
/** * Sets the status of the given job to {@link ClusterJob.Status#FAILED} and the status of the cluster to some given * status. * * @param job Job to fail. * @param cluster Cluster to set the status for. * @param status Status to set the cluster to. * @param message Error message. * @throws IOException * @throws IllegalAccessException */ public void failJobAndSetClusterStatus(ClusterJob job, Cluster cluster, Cluster.Status status, String message) throws IOException, IllegalAccessException { cluster.setStatus(status); clusterStore.writeCluster(cluster); job.setJobStatus(ClusterJob.Status.FAILED); if (message != null) { job.setStatusMessage(message); } clusterStore.writeClusterJob(job); serverStats.getFailedClusterStats().incrementStat(job.getClusterAction()); callbackQueues.add(cluster.getAccount().getTenantId(), new Element(gson.toJson(new CallbackData(CallbackData.Type.FAILURE, cluster, job)))); }
/** * Sets the status of the given job to {@link ClusterJob.Status#COMPLETE} and the status of the given cluster to * {@link co.cask.coopr.cluster.Cluster.Status#ACTIVE}. * * @param job Job to complete. * @param cluster Cluster the job was for. * @throws IOException */ public void completeJob(ClusterJob job, Cluster cluster) throws IOException, IllegalAccessException { job.setJobStatus(ClusterJob.Status.COMPLETE); clusterStore.writeClusterJob(job); LOG.debug("Job {} is complete", job.getJobId()); // Update cluster status if (job.getClusterAction() == ClusterAction.CLUSTER_DELETE) { cluster.setStatus(Cluster.Status.TERMINATED); } else { cluster.setStatus(Cluster.Status.ACTIVE); } clusterStore.writeCluster(cluster); serverStats.getSuccessfulClusterStats().incrementStat(job.getClusterAction()); if (job.getClusterAction() == ClusterAction.CLUSTER_DELETE) { wipeSensitiveFields(cluster); } callbackQueues.add(cluster.getAccount().getTenantId(), new Element(gson.toJson(new CallbackData(CallbackData.Type.SUCCESS, cluster, job)))); }
clusterJob.setJobStatus(ClusterJob.Status.FAILED); clusterJob.setStatusMessage("Aborted by user."); clusterStore.writeClusterJob(clusterJob);
@Test public void testAdminCanDeleteClustersOwnedByOthers() throws Exception { String clusterId = "2"; Cluster cluster = Entities.ClusterExample.createCluster(); cluster.setStatus(Cluster.Status.ACTIVE); ClusterJob clusterJob = new ClusterJob(new JobId(clusterId, 1), ClusterAction.CLUSTER_DELETE); clusterJob.setJobStatus(ClusterJob.Status.COMPLETE); cluster.setLatestJobId(clusterJob.getJobId()); clusterStoreService.getView(cluster.getAccount()).writeCluster(cluster); clusterStore.writeClusterJob(clusterJob); assertResponseStatus(doDeleteExternalAPI("/clusters/" + clusterId, ADMIN_HEADERS), HttpResponseStatus.OK); }
Set currentStage = job.getCurrentStage(); job.setJobStatus(ClusterJob.Status.PAUSED); clusterStore.writeClusterJob(job); job = clusterStore.getClusterJob(JobId.fromString(jobId)); job.setJobStatus(ClusterJob.Status.RUNNING); clusterStore.writeClusterJob(job); jobQueues.add(tenantId, new Element(jobId));
cluster.setStatus(Cluster.Status.ACTIVE); ClusterJob clusterJob = new ClusterJob(new JobId(clusterId, 1), ClusterAction.CLUSTER_DELETE); clusterJob.setJobStatus(ClusterJob.Status.COMPLETE); cluster.setLatestJobId(clusterJob.getJobId()); clusterStoreService.getView(cluster.getAccount()).writeCluster(cluster);