Package org.glite.ce.creamapi.jobmanagement.command

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


        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

                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

    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

    private boolean jobCancelByLeaseManager(Job job, Calendar now) {
        boolean ok = false;
        int count = checkCommand(job.getCommandHistory());
        if ((count != -1) && (count <= 3)) {
            logger.debug("The lease time is expired (" + count + "/3): the job " + job.getId() + " will be cancelled!");
            JobCommand cmd = new JobCommand(JobCommandConstant.JOB_CANCEL, job.getId());
            cmd.setCreationTime(now);
            cmd.setDescription("Job cancelled by Lease Manager! (try " + count + "/3)!");
            cmd.setUserId(job.getUserId());
            cmd.setStartSchedulingTime(now);
            cmd.setStatus(JobCommand.PROCESSING);

            try {
                executor.getJobDB().insertJobCommand(cmd);
                executor.cancel(job);
                cmd.setStatus(JobCommand.SUCCESSFULL);
                executor.getJobDB().updateJobCommand(cmd);
                ok = true;
            } catch (CommandException e) {
                logger.error(e.getMessage());
                cmd.setFailureReason(e.getMessage());
                cmd.setStatus(JobCommand.ERROR);
                try {
                    executor.getJobDB().updateJobCommand(cmd);
                } catch (IllegalArgumentException iae) {
                    logger.error(iae.getMessage());
                } catch (DatabaseException de) {
View Full Code Here

    private JobCommand readJobCommand(ObjectInput in) throws IOException {
        if (in == null) {
            throw new IOException("readJobCommand error: ObjectInput is null");
        }

        JobCommand cmd = new JobCommand();
        cmd.setCommandExecutorName(readString(in));
        cmd.setDescription(readString(in));
        cmd.setFailureReason(readString(in));
        cmd.setJobId(readString(in));
        cmd.setUserId(readString(in));
        cmd.setCreationTime(readCalendar(in));
        cmd.setExecutionCompletedTime(readCalendar(in));
        cmd.setStartProcessingTime(readCalendar(in));
        cmd.setStartSchedulingTime(readCalendar(in));
        cmd.setStatus(in.readInt());
        cmd.setType(in.readInt());

        return cmd;
    }
View Full Code Here

            }

            Calendar now = Calendar.getInstance();
            int[] statusType = new int[] {JobStatus.REGISTERED, JobStatus.HELD, JobStatus.IDLE, JobStatus.PENDING, JobStatus.REALLY_RUNNING, JobStatus.RUNNING};

            JobCommand jobCmd = new JobCommand();
            jobCmd.setCreationTime(command.getCreationTime());
            //jobCmd.setDescription(command.getDescription());
            jobCmd.setDescription(delegProxyInfo);
            jobCmd.setStartSchedulingTime(command.getStartProcessingTime());
            jobCmd.setStartProcessingTime(now);
            jobCmd.setExecutionCompletedTime(now);
            jobCmd.setType(cmdType);
            jobCmd.setStatus(JobCommand.SUCCESSFULL);
            jobCmd.setCommandExecutorName(getName());
            jobCmd.setUserId(userId);

            insertJobCommand(jobCmd, delegId, statusType);

        } else if (JobCommandConstant.JOB_REGISTER.equals(command.getName())) {
            logger.debug("Calling jobRegister.");
            jobRegister(command);

        } else if (JobCommandConstant.JOB_SET_LEASEID.equals(command.getName())) {
            logger.debug("Calling jobSetLeaseId.");
            jobSetLeaseId(command);

        } else if (JobCommandConstant.DELETE_LEASE.equals(command.getName())) {
            logger.debug("Calling deleteLease.");
            deleteLease(command);

        } else if (JobCommandConstant.SET_LEASE.equals(command.getName())) {
            logger.debug("Calling setLease.");
            setLease(command);

        } else if (JobCommandConstant.GET_LEASE.equals(command.getName())) {
            logger.debug("Calling getLease.");
            getLease(command);

        } else if (JobCommandConstant.JOB_INFO.equals(command.getName())) {
            logger.debug("Calling jobInfo.");
            getJobList(command);

        } else if (JobCommandConstant.JOB_STATUS.equals(command.getName())) {
            logger.debug("Calling jobStatus.");
            JobEnumeration jobEnum = getJobList(command);
            String user = null;

            if (!isAdmin) {
                user = userId;
            }

            try {
                List<JobStatus> jobStatusList = jobDB.retrieveLastJobStatus(jobEnum.getJobIdList(), user);
                command.getResult().addParameter("JOB_STATUS_LIST", jobStatusList);

                if (command.containsParameterKey("JOB_ID") || command.containsParameterKey("JOB_ID_LIST")) {
                    if (jobStatusList.size() < jobEnum.getJobIdList().size()) {               
                        List<String> jobIdList = new ArrayList<String>(jobStatusList.size());

                        for (JobStatus status : jobStatusList) {
                            jobIdList.add(status.getJobId());
                        }

                        jobEnum.getJobIdList().removeAll(jobIdList);

                        int found = 0;

                        List<JobIdFilterResult> jobIdFilterResultList = (List<JobIdFilterResult>) command.getResult().getParameter("JOBID_FILTER_RESULT_LIST");

                        for (JobIdFilterResult filterResult : jobIdFilterResultList) {
                            if (jobEnum.getJobIdList().contains(filterResult.getJobId())) {
                                filterResult.setErrorCode(JobIdFilterFailure.JOBID_ERRORCODE);
                                filterResult.setFailureReason(JobIdFilterFailure.failureReason[JobIdFilterFailure.JOBID_ERRORCODE]);

                                if (++found == jobEnum.getJobIdList().size()) {
                                    break;
                                }
                            }
                        }

                        command.getResult().addParameter("JOB_ENUM", new JobEnumeration(jobIdList, jobDB));
                    }
                }
            } catch (DatabaseException e) {
                logger.error(e.getMessage());
                throw new CommandException("database error occurred");
            }
        } else if (JobCommandConstant.QUERY_EVENT.equals(command.getName())) {
            logger.debug("Calling queryEvent.");
            int maxEvents = 100;
           
            try {
                maxEvents = Integer.parseInt(command.getParameterAsString("MAX_QUERY_EVENT_RESULT_SIZE"));
            } catch (Throwable t) {
                logger.warn("queryEvent: wrong value for MAX_QUERY_EVENT_RESULT_SIZE");
            }
           
            int[] jobStatusTypeArray = null;
            if (command.containsParameterKey("statusList")) {
                List<String> statusList = command.getParameterMultivalue("statusList");
               
                jobStatusTypeArray = new int[statusList.size()];

                for (int i = 0; i < statusList.size(); i++) {
                    jobStatusTypeArray[i] = -1;
                   
                    for (int x = 0; x < JobStatus.statusName.length; x++) {
                        if (statusList.get(i).equals(JobStatus.getNameByType(x))) {
                            jobStatusTypeArray[i] = x;
                            continue;
                        }
                    }
                }
            }
           
            JobStatusEventManagerInterface jobStatusEventManager = (JobStatusEventManagerInterface) EventManagerFactory.getEventManager("JOB_STATUS_EVENT_MANAGER");
            List<Event> eventList = null;
           
            try {
                eventList = jobStatusEventManager.getEvents(command.getParameterAsString("FROM_EVENT_ID"), command.getParameterAsString("TO_EVENT_ID"),
                        makeDate(command.getParameterAsString("FROM_DATE")), makeDate(command.getParameterAsString("TO_DATE")), jobStatusTypeArray,
                        maxEvents, userId);               
            } catch (EventManagerException e) {
                throw new CommandException(e.getMessage());
            }

            command.getResult().addParameter("EVENT_LIST", eventList);
        } else if (JobCommandConstant.SET_JOB_STATUS.equals(command.getName())) {
            logger.debug("Calling setJobStatus.");

            int statusType = Integer.valueOf(command.getParameterAsString("STATUS_TYPE"));
            String jobId = command.getParameterAsString("JOB_ID");
            String workerNode = command.getParameterAsString("WORKER_NODE");
            String lrmsJobId = command.getParameterAsString("LRMS_JOB_ID");
            String exitCode = command.getParameterAsString("EXIT_CODE");
            String failureReason = command.getParameterAsString("FAILURE_REASON");
            Calendar changeTime = null;
            if (command.containsParameterKey("STATUS_CHANGE_TIME")) {
                changeTime = new GregorianCalendar();
                SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                dateFormat.setCalendar(changeTime);
                try {
                     dateFormat.parse(command.getParameterAsString("STATUS_CHANGE_TIME"));
                } catch (ParseException e) {
                    logger.error(e.getMessage());
                }
            }

            JobStatus status = new JobStatus(statusType, jobId, changeTime);
            status.setExitCode(exitCode);
            status.setFailureReason(failureReason);

            Job job = null;
            try {
                job = jobDB.retrieveJob(status.getJobId(), null);
            } catch (Exception e) {
                logger.warn("job " + status.getJobId() + " not found!");
                return;
            }

            try {
                if(doOnJobStatusChanged(status, job)) {
                    boolean updateJob = false;
                    if (lrmsJobId != null && (job.getLRMSJobId() == null || job.getLRMSJobId().equalsIgnoreCase("N/A"))) {
                        job.setLRMSJobId(lrmsJobId);
                        updateJob = true;
                    }

                    if (workerNode != null) {
                        boolean isReallyRunning = false;

                        if(job.getWorkerNode() != null && !job.getWorkerNode().equals("N/A") && status.getType() != JobStatus.REALLY_RUNNING) {
                            for(JobStatus oldStatus : job.getStatusHistory()) {
                                if(oldStatus.getType() == JobStatus.REALLY_RUNNING) {
                                    isReallyRunning = true;
                                    break;
                                }
                            }
                        }

                        if(!isReallyRunning) {
                            job.setWorkerNode(workerNode);
                            updateJob = true;
                        }
                    }

                    if (updateJob) {
                        try {
                            jobDB.update(job);
                        } catch (Throwable e) {
                            logger.error(e);
                        }
                    }
                }
            } catch (JobManagementException e) {
                logger.error(e.getMessage());
            }
        } else if (JobCommandConstant.JOB_LIST.equals(command.getName())) {
            logger.debug("Calling jobList.");
            try {
                String user = null;

                if (!isAdmin) {
                    user = userId;
                }

                List<String> jobIdFound = jobDB.retrieveJobId(user);
                JobEnumeration jobEnum = new JobEnumeration(jobIdFound, jobDB);
                command.getResult().addParameter("JOB_ENUM", jobEnum);
            } catch (DatabaseException e) {
                logger.error(e.getMessage());
                throw new CommandException("database error occurred");
            }
        } else {
            JobEnumeration jobEnum = getJobList(command);
           
            try {
                List<Job> jobList = new ArrayList<Job>(0);
                Calendar now = Calendar.getInstance();
               
                while (jobEnum.hasMoreJobs()) {
                    Job job = jobEnum.nextJob();

                    JobCommand jobCmd = new JobCommand();
                    jobCmd.setJobId(job.getId());
                    jobCmd.setCreationTime(command.getCreationTime());
                    jobCmd.setDescription(command.getDescription());
                    jobCmd.setStartSchedulingTime(command.getStartProcessingTime());
                    jobCmd.setStartProcessingTime(now);
                    jobCmd.setType(cmdType);
                    jobCmd.setCommandExecutorName(getName());

                    if (!isAdmin || job.getUserId().equals(command.getUserId())) {
                        jobCmd.setUserId(command.getUserId());
                    }

                    if ((JobCommandConstant.JOB_CANCEL.equals(command.getName())) && (jobCmd.getDescription() == null)) {
                        if (!isAdmin || job.getUserId().equals(command.getUserId())) {
                            jobCmd.setDescription("Cancelled by user");
                        } else {
                            jobCmd.setDescription("Cancelled by CE admin");
                        }
                    }
                   
                    logger.debug("Calling jobDB.insertJobCommand.");
                    try {
                        jobDB.insertJobCommand(jobCmd);
                    } catch (Throwable e) {
                        logger.error(e.getMessage());
                        continue;
                    }

                    logger.debug("jobDB.insertJobCommand has been executed.");

                    if (jobCmd.getStatus() != JobCommand.ERROR) {
                        job.addCommandHistory(jobCmd);
                        jobList.add(job);
                    }
                }

                for (Job j : jobList) {
                    JobCommand jobCmd = j.getLastCommand();
                    if (jobCmd == null) {
                        continue;
                    }

                    jobCmd.setStatus(JobCommand.PROCESSING);

                    if (LBLogger.isEnabled()) {
                        try {
                            LBLogger.getInstance().execute(j, command, LBLogger.START, null, null);
                        } catch (Throwable t) {
                            logger.warn("LBLogger.execute() failed: " + t.getMessage());
                        }
                    }

                    try {
                        if (JobCommandConstant.JOB_CANCEL.equals(command.getName())) {
                            if (j.getLastStatus() != null && j.getLastStatus().getType() == JobStatus.REGISTERED) {
                                JobStatus status = new JobStatus(JobStatus.CANCELLED, j.getId(), now);
                                status.setDescription(jobCmd.getDescription());
                                doOnJobStatusChanged(status, j);
                            } else {
                                cancel(j);
                            }

                        } else if (JobCommandConstant.JOB_PURGE.equals(command.getName())) {
                            purge(j);
                       
                        } else if (JobCommandConstant.JOB_SUSPEND.equals(command.getName())) {
                            suspend(j);
                       
                        } else if (JobCommandConstant.JOB_RESUME.equals(command.getName())) {
                            resume(j);
                       
                        } else if (JobCommandConstant.JOB_START.equals(command.getName())) {
                            command.addParameter("JOB", j);
                            jobStart(command);

                            StringBuffer sb = new StringBuffer(command.toString());

                            if (j.getLRMSAbsLayerJobId() != null) {
                                sb.append(" lrmsAbsJobId=").append(j.getLRMSAbsLayerJobId()).append(";");
                            }

                            if (j.getLRMSJobId() != null) {
                                sb.append(" lrmsJobId=").append(j.getLRMSJobId()).append(";");
                            }

                            logger.info(sb.toString());
                            sb = null;
                            break;
//                        case JobCommandConstant.UPDATE_PROXY_TO_SANDBOX.equals(command.getName())) {
//                            logger.info(logInfo + jobCmd.toString() + " delegationId=" + j.getDelegationProxyId() + ";");
//
//                            String attr = j.getExtraAttribute("PROXY_RENEWAL");
//                            if (attr.equals("ENABLED")) {
//                                String delegationProxyInfo = command.getParameterAsString("DELEGATION_PROXY_INFO");
//                                if (delegationProxyInfo != null) {
//                                    j.setDelegationProxyInfo(delegationProxyInfo);
//                                    jobDB.update(j);
//                                }
//                            }
                        }

                        if (!JobCommandConstant.JOB_PURGE.equals(command.getName())) {
                            jobCmd.setStatus(JobCommand.SUCCESSFULL);

                            jobDB.updateJobCommand(jobCmd);
                        }

                        if (LBLogger.isEnabled()) {
                            try {
                                LBLogger.getInstance().execute(j, command, LBLogger.OK, j.getLRMSAbsLayerJobId(), null);
                            } catch (Throwable t) {
                                logger.warn("LBLogger.execute() failed: " + t.getMessage());
                            }
                        }
                    } catch (CommandException ce) {
                        jobCmd.setStatus(JobCommand.ERROR);
                        jobCmd.setFailureReason(ce.getMessage());

                        jobDB.updateJobCommand(jobCmd);

                        if (LBLogger.isEnabled()) {
                            try {
                                LBLogger.getInstance().execute(j, command, LBLogger.FAILED, null, ce);
                            } catch (Throwable t) {
                                logger.warn("LBLogger.execute() failed: " + t.getMessage());
                            }
                        }
                    }
                }

                List<String> invalidJobIdlist = (List<String>) command.getResult().getParameter("JOB_ID_LIST_STATUS_NOT_COMPATIBLE_FOUND");

                if (invalidJobIdlist != null) {
                    for (String jobId : invalidJobIdlist) {
                        try {
                            JobCommand jobCmd = new JobCommand(cmdType, jobId);
                            jobCmd.setCreationTime(command.getCreationTime());
                            jobCmd.setDescription(command.getDescription());
                            jobCmd.setStartSchedulingTime(command.getStartProcessingTime());
                            jobCmd.setStatus(JobCommand.ERROR);
                            jobCmd.setFailureReason("status not compatible with the specified command!");

                            if (!isAdmin) {
                                jobCmd.setUserId(command.getUserId());
                            }

                            jobDB.insertJobCommand(jobCmd);
                        } catch (DatabaseException e) {
                            logger.error(e.getMessage());
View Full Code Here

TOP

Related Classes of org.glite.ce.creamapi.jobmanagement.command.JobCommand

Copyright © 2018 www.massapicom. 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.