Examples of JobCommand


Examples of org.apache.oozie.command.wf.JobCommand

        try {
            if (useXCommand) {
                return new JobXCommand(jobId).call();
            }
            else {
                return new JobCommand(jobId).call();
            }
        }
        catch (CommandException ex) {
            throw new DagEngineException(ex);
        }
View Full Code Here

Examples of org.apache.oozie.command.wf.JobCommand

        try {
            if (useXCommand) {
                return new JobXCommand(jobId, start, length).call();
            }
            else {
                return new JobCommand(jobId, start, length).call();
            }
        }
        catch (CommandException ex) {
            throw new DagEngineException(ex);
        }
View Full Code Here

Examples of org.apache.oozie.command.wf.JobCommand

     * @throws DagEngineException thrown if the job info could not be obtained.
     */
    @Override
    public WorkflowJob getJob(String jobId) throws DagEngineException {
        try {
            return new JobCommand(jobId).call();
        }
        catch (CommandException ex) {
            throw new DagEngineException(ex);
        }
    }
View Full Code Here

Examples of org.apache.oozie.command.wf.JobCommand

     * @throws DagEngineException thrown if the job info could not be obtained.
     */
    @Override
    public WorkflowJob getJob(String jobId, int start, int length) throws DagEngineException {
        try {
            return new JobCommand(jobId, start, length).call();
        }
        catch (CommandException ex) {
            throw new DagEngineException(ex);
        }
    }
View Full Code Here

Examples of org.apache.oozie.command.wf.JobCommand

        try {
            if (useXCommand) {
                return new JobXCommand(jobId).call();
            }
            else {
                return new JobCommand(jobId).call();
            }
        }
        catch (CommandException ex) {
            throw new DagEngineException(ex);
        }
View Full Code Here

Examples of org.apache.oozie.command.wf.JobCommand

        try {
            if (useXCommand) {
                return new JobXCommand(jobId, start, length).call();
            }
            else {
                return new JobCommand(jobId, start, length).call();
            }
        }
        catch (CommandException ex) {
            throw new DagEngineException(ex);
        }
View Full Code Here

Examples of org.glite.ce.creamapi.jobmanagement.command.JobCommand

        JobEnumeration jobEnum = getJobList(command);
        jobIdList = jobEnum.getJobIdList();
        int commandType = getCommandType(JobCommandConstant.JOB_SET_LEASEID);

        for (int index = 0; index < jobIdList.size(); index++) {
            JobCommand jobCmd = new JobCommand(commandType, jobIdList.get(index));
            jobCmd.setCreationTime(command.getCreationTime());
            // jobCmd.setDescription(msg);
            jobCmd.setUserId(userId);
            jobCmd.setStartSchedulingTime(command.getStartSchedulingTime());
            jobCmd.setStartProcessingTime(command.getStartProcessingTime());
            jobCmd.setStatus(JobCommand.PROCESSING);
            try {
                jobDB.insertJobCommand(jobCmd);
               
                leaseManager.setJobLeaseId(jobIdList.get(index), leaseId, userId);

                jobCmd.setStatus(JobCommand.SUCCESSFULL);
                               
                jobDB.updateJobCommand(jobCmd);
            } catch (Exception e) {
                logger.error(e.getMessage());
                jobCmd.setStatus(JobCommand.ERROR);
                jobCmd.setFailureReason(e.getMessage());
                try {
                    jobDB.updateJobCommand(jobCmd);
                } catch (DatabaseException de) {
                    logger.error(e.getMessage());
                }
View Full Code Here

Examples of org.glite.ce.creamapi.jobmanagement.command.JobCommand

        if (cmd == null) {
            throw new CommandException("command not defined!");
        }
       
        JobCommand jobCmd = new JobCommand(getCommandType(JobCommandConstant.JOB_REGISTER));
        jobCmd.setStatus(cmd.getStatus());
        jobCmd.setCreationTime(cmd.getCreationTime());
        jobCmd.setDescription(cmd.getDescription());
        jobCmd.setUserId(cmd.getUserId());
        jobCmd.setStartSchedulingTime(cmd.getStartProcessingTime());

        try {
            String userId = cmd.getUserId();
           
            if (userId == null) {
                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);
View Full Code Here

Examples of org.glite.ce.creamapi.jobmanagement.command.JobCommand

                job = jobDB.retrieveJob(jobId, null);

                if (job != null && (job.getLRMSAbsLayerJobId() == null || Job.NOT_AVAILABLE_VALUE.equals(job.getLRMSAbsLayerJobId()))) {
                    if (isEmptyField(job.getLRMSAbsLayerJobId())) {
                        if (job.getCommandHistoryCount() > 1) {
                            JobCommand cmd = job.getCommandHistoryAt(1);
                            cmd.setStatus(JobCommand.ABORTED);
                            cmd.setFailureReason("command aborted because its execution has been interrupted by the CREAM shutdown");

                            if ("ADMINISTRATOR".equals(cmd.getUserId())) {
                                cmd.setUserId(job.getUserId());
                            }

                            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");
View Full Code Here

Examples of org.glite.ce.creamapi.jobmanagement.command.JobCommand

    private int checkCommand(List<JobCommand> command) {
        if (command == null) {
            return 0;
        }
        int count = 1;
        JobCommand jobCmd = null;
        for (int x = 0; x < command.size(); x++) {
            jobCmd = command.get(x);

            if (jobCmd != null && JobCommandConstant.JOB_CANCEL.equals(jobCmd.getName()) && jobCmd.getDescription() != null && jobCmd.getDescription().indexOf("Lease") > 0) {
                logger.debug("jobCmd.getExecutionCompletedTime() == null ? " + (jobCmd.getExecutionCompletedTime() == null));
                if (jobCmd.getExecutionCompletedTime() == null) {
                    return -1;
                }
                count++;
            }
        }
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.