Examples of JobStatus


Examples of org.glite.ce.creamapi.jobmanagement.JobStatus

                throw new CommandException("userId not defined!");
            }

            Job job = makeJobFromCmd(cmd);
           
            JobStatus status = new JobStatus(JobStatus.REGISTERED, job.getId());

            job.setUserId(userId);
            job.setLocalUser(cmd.getParameterAsString("LOCAL_USER"));
            job.setJDL(cmd.getParameterAsString("JDL"));
            job.setICEId(cmd.getParameterAsString("ICE_ID"));
            job.addCommandHistory(jobCmd);
           
            if (cmd.containsParameterKey("USER_VO")) {
                job.setVirtualOrganization(cmd.getParameterAsString("USER_VO"));
            }

            if (isEmptyField(job.getBatchSystem())) {
                throw new CommandException("\"BatchSystem\" attribute not defined into the JDL");
            }

            if (isEmptyField(job.getQueue())) {
                throw new CommandException("\"QueueName\" attribute not defined into the JDL");
            }

            if (!isBatchSystemSupported(job.getBatchSystem())) {
                throw new CommandException("Batch System " + job.getBatchSystem() + " not supported!");
            }

            String cream_sandbox_dir = getParameterValueAsString("CREAM_SANDBOX_DIR");
            if (cream_sandbox_dir == null) {
                throw new CommandException("parameter \"CREAM_SANDBOX_DIR\" not defined!");
            }

            job.setCreamURL(cmd.getParameterAsString("CREAM_URL"));
            job.setDelegationProxyId(cmd.getParameterAsString("DELEGATION_PROXY_ID"));
            job.setDelegationProxyInfo(cmd.getParameterAsString("DELEGATION_PROXY_INFO"));
            job.setDelegationProxyCertPath(cmd.getParameterAsString("DELEGATION_PROXY_PATH"));
            job.setLRMSAbsLayerJobId(Job.NOT_AVAILABLE_VALUE);
            job.setLRMSJobId(Job.NOT_AVAILABLE_VALUE);
            job.setWorkerNode(Job.NOT_AVAILABLE_VALUE);
            job.setWorkingDirectory(Job.NOT_AVAILABLE_VALUE);

            if (cmd.containsParameterKey("USER_DN")) {
                job.addExtraAttribute("USER_DN", cmd.getParameterAsString("USER_DN").replaceAll("\\s+", "\\\\ "));
            }

            if (cmd.containsParameterKey("USER_DN_X500")) {
                job.addExtraAttribute("USER_DN_X500", cmd.getParameterAsString("USER_DN_X500").replaceAll("\\s+", "\\\\ "));
            }

            if (cmd.containsParameterKey("LOCAL_USER_GROUP")) {
                job.addExtraAttribute("LOCAL_USER_GROUP", cmd.getParameterAsString("LOCAL_USER_GROUP"));
            }

            if (cmd.containsParameterKey("USER_FQAN")) {
                List<String> fqanList = cmd.getParameterMultivalue("USER_FQAN");
               
                if (fqanList != null && fqanList.size() > 0) {                   
                    StringBuffer fqanBuffer = new StringBuffer();
                   
                    for (String fqan : fqanList) {
                        fqanBuffer.append("\\\"userFQAN=").append(fqan.replaceAll("\\s+", "\\\\ ")).append("\\\"\\ ");
                    }

                    fqanBuffer.deleteCharAt(fqanBuffer.length() - 1);
                    fqanBuffer.deleteCharAt(fqanBuffer.length() - 1);
                   
                    job.addExtraAttribute("USER_FQAN", fqanBuffer.toString());
                }
            }
            
            if (this.containsParameterKey("LRMS_EVENT_LISTENER_PORT")) {
                job.setLoggerDestURI(InetAddress.getLocalHost().getHostAddress() + ":" + getParameterValueAsString("LRMS_EVENT_LISTENER_PORT"));
            }

            if (job.getCreamURL() != null) {
                try {
                    URL url = new URL(job.getCreamURL());
                    job.setCeId(url.getHost() + ":" + url.getPort() + "/cream-" + job.getBatchSystem() + "-" + job.getQueue());
                } catch (MalformedURLException e) {
                }
            }

            if (cmd.containsParameterKey("LEASE_ID")) {
                String leaseId = cmd.getParameterAsString("LEASE_ID");

                if (leaseId != null && leaseId.length() > 0) {
                    Lease lease = jobDB.retrieveJobLease(leaseId, userId);
                    if (lease != null) {
                        logger.debug("found lease \"" + leaseId + "\" = " + lease.getLeaseTime().getTime());
                        job.setLease(lease);
                    } else {
                        throw new CommandException("lease id \"" + leaseId + "\" not found!");
                    }
                }
            }

            boolean jobInserted = false;
            int count = 0;

            while (!jobInserted && count < 5) {
                try {
                    jobDB.insert(job);
                    jobInserted = true;
                } catch (DatabaseException de) {
                    if (de.getMessage().indexOf("Duplicate entry") > -1) {
                        job.setId(job.generateJobId());
                        count++;
                    } else {
                        logger.error(de.getMessage());
                        throw new CommandException("database error occurred");
                    }
                } catch (IllegalArgumentException ie) {
                    throw new CommandException(ie.getMessage());
                }
            }

            if (!jobInserted) {
                throw new CommandException("Duplicate jobId error: cannot insert the new job (" + job.getId() + ") into the database");
            }

            jobCmd.setJobId(job.getId());
            jobCmd.setStatus(JobCommand.SUCCESSFULL);
          
            if (LBLogger.isEnabled()) {
                try {
                    LBLogger.getInstance().register(job);
                } catch (Throwable e) {
                    logger.warn("LBLogger.register() failed: " + e.getMessage());
                }

                try {
                    LBLogger.getInstance().accept(job);
                } catch (Throwable e) {
                    logger.warn("LBLogger.accept() failed: " + e.getMessage());
                }
            }

            try {
                createJobSandboxDir(job, cmd.getParameterAsString("GSI_FTP_CREAM_URL"));
            } catch (Throwable e) {
                jobCmd.setStatus(JobCommand.ERROR);
                jobCmd.setFailureReason(e.getMessage());

                status.setType(JobStatus.ABORTED);
                status.setFailureReason(e.getMessage());

                doOnJobStatusChanged(status, job);
               
                throw new CommandException(e.getMessage());
            } finally {
View Full Code Here

Examples of org.glite.ce.creamapi.jobmanagement.JobStatus

        if (job == null) {
            logger.warn("job " + status.getJobId() + " not found!");
            return false;
        }
     
        JobStatus lastStatus = job.getLastStatus();
/*
        if (lastStatus == null) {
            throw new JobManagementException("job status " + status.getJobId() + " not found!");
        }
*/
        if (lastStatus != null && status.getType() == lastStatus.getType()) {
            if (lastStatus.getName().startsWith("DONE")) {
                try {
                    if (!"W".equalsIgnoreCase(lastStatus.getExitCode())) {
                        status.setExitCode(lastStatus.getExitCode());
                    }

                    if (status.getFailureReason() != null) {
                        if (lastStatus.getFailureReason() != null &&
                                !lastStatus.getFailureReason().equals(job.NOT_AVAILABLE_VALUE) &&
                                !status.getFailureReason().equals(lastStatus.getFailureReason())) {
                            status.setFailureReason(lastStatus.getFailureReason() + "; " + status.getFailureReason());
                        } else {
                            status.setFailureReason(status.getFailureReason());
                        }
                    }

                    status.setId(lastStatus.getId());

                    jobDB.updateStatus(status, null);

                    statusUpdated = true;

                    if (LBLogger.isEnabled()) {
                        try {
                            LBLogger.getInstance().statusChanged(job, status, null, LBLogger.START);
                        } catch (Exception e) {
                            logger.warn("LBLogger.statusChanged failed: " + e.getMessage());
                        }
                    }

                    logger.info("JOB " + status.getJobId() + " STATUS UPDATED: " + status.getName());

                    try {
                        sendNotification(job);
                    } catch (Throwable e) {
                        logger.error(e.getMessage());
                    }
                } catch (IllegalArgumentException e) {
                    logger.error(e);
                    throw new JobManagementException(e);
                } catch (DatabaseException e) {
                    logger.error(e.getMessage());
                    throw new JobManagementException("database error occurred");
                }
            }
        } else {
            if (lastStatus != null && (lastStatus.getType() == JobStatus.ABORTED || lastStatus.getType() == JobStatus.CANCELLED ||
                    lastStatus.getType() == JobStatus.DONE_OK || lastStatus.getType() == JobStatus.DONE_FAILED)) {
                return statusUpdated;
            }

            switch (status.getType()) {
            case JobStatus.ABORTED:
                setLeaseExpired(job);
                break;

            case JobStatus.CANCELLED:
                status.setDescription("Cancelled by CE admin");
                int cancelType = getCommandType(JobCommandConstant.JOB_CANCEL);

                for (int i = job.getCommandHistoryCount() - 1; i >= 0; i--) {
                    if (job.getCommandHistoryAt(i).getType() == cancelType) {
                        status.setDescription(job.getCommandHistoryAt(i).getDescription());
                        break;
                    }
                }
                setLeaseExpired(job);
                break;

            case JobStatus.DONE_OK:
            case JobStatus.DONE_FAILED:
                if (status.getType() == JobStatus.DONE_FAILED) {
                    int cancelledType = getCommandType(JobCommandConstant.JOB_CANCEL);

                    for (int i = job.getCommandHistoryCount() - 1; i >= 0; i--) {
                        if (job.getCommandHistoryAt(i).getType() == cancelledType) {                        
                            status.setType(JobStatus.CANCELLED);
                            status.setExitCode(null);
                            status.setDescription(job.getCommandHistoryAt(i).getDescription());
                            break;
                        }
                    }                 
                }
               
                if ("W".equalsIgnoreCase(status.getExitCode())) {
                    Calendar time = Calendar.getInstance();
                    time.add(Calendar.MINUTE, 1);
                    timer.schedule(new GetSTDTask(status.getJobId()), time.getTime());
                    timer.purge();
                }              

                setLeaseExpired(job);
                break;

            case JobStatus.REALLY_RUNNING:
                if (lastStatus != null && (lastStatus.getType() == JobStatus.ABORTED || lastStatus.getType() == JobStatus.CANCELLED ||
                        lastStatus.getType() == JobStatus.DONE_OK || lastStatus.getType() == JobStatus.DONE_FAILED)) {
                    return statusUpdated;
                }
                break;

            case JobStatus.RUNNING:
                if (status.getTimestamp().compareTo(lastStatus.getTimestamp()) <= 0) {
                    return statusUpdated;
                }

                if (lastStatus != null && (lastStatus.getType() == JobStatus.REALLY_RUNNING || lastStatus.getType() == JobStatus.ABORTED ||
                        lastStatus.getType() == JobStatus.CANCELLED || lastStatus.getType() == JobStatus.DONE_OK || lastStatus.getType() == JobStatus.DONE_FAILED)) {
                    return statusUpdated;
                }
                try {
                    List<JobStatus> statusList = jobDB.retrieveJobStatusHistory(status.getJobId(), null);

                    if (statusList != null && statusList.size() > 2) {
                        JobStatus oldStatus = statusList.get(statusList.size() - 2);
                        status.setType(oldStatus.getType() == JobStatus.REALLY_RUNNING ? JobStatus.REALLY_RUNNING : JobStatus.RUNNING);
                    }
                } catch (DatabaseException e) {
                    logger.error(e.getMessage());
                    throw new JobManagementException("database error occurred");
                }
View Full Code Here

Examples of org.glite.ce.creamapi.jobmanagement.JobStatus

                            jobDB.updateJobCommand(cmd);
                            logger.info(cmd.toString());
                        }

                        JobStatus status = job.getLastStatus();
                        status.setType(JobStatus.ABORTED);
                        status.setFailureReason("job aborted because the execution of the JOB_START command has been interrupted by the CREAM shutdown");
                        status.setTimestamp(job.getLastCommand().getExecutionCompletedTime());

                        jobDB.updateStatus(status, null);
                        logger.info("job " + job.getId() + " aborted because the execution of the JOB_START command has been interrupted by the CREAM shutdown");

                        try {
View Full Code Here

Examples of org.guvnor.rest.client.JobStatus

        JobResult result = null;
        try {
            result = helper.addRepositoryToOrganizationalUnit( jobRequest.getJobId(), jobRequest.getOrganizationalUnitName(), jobRequest.getRepositoryName() );
        } finally {
            JobStatus status = result != null ? result.getStatus() : JobStatus.SERVER_ERROR;
            logger.debug( "-----addRepositoryToOrganizationalUnit--- , OrganizationalUnit name: {}, repository name: {} [{}]",
                    jobRequest.getOrganizationalUnitName(), jobRequest.getRepositoryName(), status );
        }
        return result;
    }
View Full Code Here

Examples of org.kie.workbench.common.services.shared.rest.JobStatus

        JobResult result = null;
        try {
            result = helper.removeRepository( jobRequest.getJobId(), jobRequest.getRepositoryName() );
        } finally {
            JobStatus status = result != null ? result.getStatus() : JobStatus.SERVER_ERROR;
            logger.info( "-----removeRepository--- , repository name: {} [{}]",
                    jobRequest.getRepositoryName(), status);
        }
        return result;
    }
View Full Code Here

Examples of org.springframework.data.hadoop.mapreduce.JobUtils.JobStatus

   * @throws Exception if exception occurred
   */
  protected JobStatus waitStatus(Job job, long timeout, TimeUnit unit, JobStatus... jobStatuses) throws Exception {
    Assert.notNull(job, "Hadoop job must be set");

    JobStatus status = null;
    long end = System.currentTimeMillis() + unit.toMillis(timeout);

    // break label for inner loop
    done: do {
      status = findStatus(job);
      if (status == null) {
        break;
      }
      for (JobStatus statusCheck : jobStatuses) {
        if (status.equals(statusCheck)) {
          break done;
        }
      }
      Thread.sleep(1000);
    } while (System.currentTimeMillis() < end);
View Full Code Here

Examples of org.springframework.data.hadoop.mapreduce.JobUtils.JobStatus

              throw new IllegalStateException(ex);
            }

            if (!succes) {
              if (!shuttingDown) {
                JobStatus status = JobUtils.getStatus(job);
                if (JobStatus.KILLED == status) {
                  throw new IllegalStateException("Job " + job.getJobName() + "] killed");
                }
                else {
                  throw new IllegalStateException("Job " + job.getJobName() + "] failed to start; status=" +status);
View Full Code Here

Examples of org.springframework.data.hadoop.mapreduce.JobUtils.JobStatus

    checkHadoopJobWasKilled(victimJob);
  }

  private static void checkHadoopJobWasKilled(Job victimJob) throws Exception {
    JobStatus status = JobStatus.UNKNOWN;
    // wait for the job status to be updated...
    for (int i = 0; i < 5 && !status.isFinished(); i++) {
      Thread.sleep(1000 * 5);
      status = JobUtils.getStatus(victimJob);
    }
    JobStatus status2 = JobUtils.getStatus(victimJob);
    assertTrue("job not killed - " + status2, (JobStatus.KILLED == status2 || JobStatus.FAILED == status2));
    assertTrue(status.isFinished());
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.