public synchronized JobStatus getJobStatus(String jobID) throws SSHApiException { RawCommandInfo rawCommandInfo = jobManagerConfiguration.getMonitorCommand(jobID); StandardOutReader stdOutReader = new StandardOutReader(); log.info("Executing RawCommand : " + rawCommandInfo.getCommand()); CommandExecutor.executeCommand(rawCommandInfo, this.getSession(), stdOutReader); String result = getOutputifAvailable(stdOutReader, "Error getting job information from the resource !", jobManagerConfiguration.getBaseMonitorCommand()); return jobManagerConfiguration.getParser().parseJobStatus(jobID, result); }
public synchronized String submitBatchJobWithScript(String scriptPath, String workingDirectory) throws SSHApiException { this.scpTo(workingDirectory, scriptPath); // since this is a constant we do not ask users to fill this // RawCommandInfo rawCommandInfo = new RawCommandInfo(this.installedPath + this.jobManagerConfiguration.getSubmitCommand() + " " + // workingDirectory + File.separator + FilenameUtils.getName(scriptPath)); RawCommandInfo rawCommandInfo = jobManagerConfiguration.getSubmitCommand(workingDirectory,scriptPath); StandardOutReader standardOutReader = new StandardOutReader(); log.info("Executing RawCommand : " + rawCommandInfo.getCommand()); CommandExecutor.executeCommand(rawCommandInfo, this.session, standardOutReader); //Check whether pbs submission is successful or not, if it failed throw and exception in submitJob method // with the error thrown in qsub command // String outputifAvailable = getOutputifAvailable(standardOutReader,"Error reading output of job submission",jobManagerConfiguration.getBaseSubmitCommand()); log.info("Job Submission SSH Command Output: " + outputifAvailable); OutputParser outputParser = jobManagerConfiguration.getParser(); return outputParser.parseJobSubmission(outputifAvailable); }
@Override public String getJobIdByJobName(String jobName, String userName) throws SSHApiException { RawCommandInfo rawCommandInfo = jobManagerConfiguration.getJobIdMonitorCommand(jobName, userName); StandardOutReader stdOutReader = new StandardOutReader(); log.info("Executing RawCommand : " + rawCommandInfo.getCommand()); CommandExecutor.executeCommand(rawCommandInfo, this.getSession(), stdOutReader); String result = getOutputifAvailable(stdOutReader, "Error getting job information from the resource !", jobManagerConfiguration.getJobIdMonitorCommand(jobName,userName).getCommand()); return jobManagerConfiguration.getParser().parseJobId(jobName, result); }
@Deprecated public synchronized void getJobStatuses(String userName, Map<String,JobStatus> jobIDs)throws SSHApiException { int retry = 3; RawCommandInfo rawCommandInfo = jobManagerConfiguration.getUserBasedMonitorCommand(userName); StandardOutReader stdOutReader = new StandardOutReader(); while (retry > 0){ try { log.info("Executing RawCommand : " + rawCommandInfo.getCommand()); CommandExecutor.executeCommand(rawCommandInfo, this.getSession(), stdOutReader); retry=0; } catch (SSHApiException e) { retry--; try { Thread.sleep(5000); } catch (InterruptedException e1) { log.error(e1.getMessage(), e1); } reconnect(serverInfo, authenticationInfo); if (retry == 0) { throw new SSHApiException("Failed Getting statuses to remote file", e); } } } String result = getOutputifAvailable(stdOutReader, "Error getting job information from the resource !", jobManagerConfiguration.getBaseMonitorCommand()); jobManagerConfiguration.getParser().parseJobStatuses(userName, jobIDs, result); }
public void generateJobScript(JobDescriptor jobDescriptor) throws SSHApiException { TransformerFactory factory = TransformerFactory.newInstance(); URL resource = this.getClass().getClassLoader().getResource(jobManagerConfiguration.getJobDescriptionTemplateName()); String error = "System configuration file '" + jobManagerConfiguration.getJobDescriptionTemplateName() + "' not found in the classpath"; throw new SSHApiException(error); number = (number < 0 ? -number : number); tempPBSFile = new File(Integer.toString(number) + jobManagerConfiguration.getScriptExtension()); log.info("File Path: " + tempPBSFile.getAbsolutePath()); log.info("File Content: " + scriptContent);
public synchronized JobDescriptor cancelJob(String jobID) throws SSHApiException { JobStatus jobStatus = getJobStatus(jobID); if (jobStatus == null || jobStatus == JobStatus.U) { log.info("Validation before cancel is failed, couldn't found job in remote host to cancel. Job may be already completed|failed|canceled"); return null; } RawCommandInfo rawCommandInfo = jobManagerConfiguration.getCancelCommand(jobID); StandardOutReader stdOutReader = new StandardOutReader(); log.info("Executing RawCommand : " + rawCommandInfo.getCommand()); CommandExecutor.executeCommand(rawCommandInfo, this.getSession(), stdOutReader); String outputifAvailable = getOutputifAvailable(stdOutReader, "Error reading output of job submission", jobManagerConfiguration.getBaseCancelCommand()); // this might not be the case for all teh resources, if so Cluster implementation can override this method // because here after cancelling we try to get the job description and return it back try { return this.getJobDescriptorById(jobID); } catch (Exception e) { //its ok to fail to get status when the job is gone return null; } }
URL resource = CommonUtils.class.getClassLoader().getResource(jConfig.getJobDescriptionTemplateName());
public synchronized String submitBatchJob(JobDescriptor jobDescriptor) throws SSHApiException { TransformerFactory factory = TransformerFactory.newInstance(); URL resource = this.getClass().getClassLoader().getResource(jobManagerConfiguration.getJobDescriptionTemplateName()); String error = "System configuration file '" + jobManagerConfiguration.getJobDescriptionTemplateName() + "' not found in the classpath"; throw new SSHApiException(error); number = (number < 0 ? -number : number); tempPBSFile = new File(Integer.toString(number) + jobManagerConfiguration.getScriptExtension()); FileUtils.writeStringToFile(tempPBSFile, scriptContent);
public synchronized JobDescriptor getJobDescriptorById(String jobID) throws SSHApiException { RawCommandInfo rawCommandInfo = jobManagerConfiguration.getMonitorCommand(jobID); StandardOutReader stdOutReader = new StandardOutReader(); log.info("Executing RawCommand : " + rawCommandInfo.getCommand()); CommandExecutor.executeCommand(rawCommandInfo, this.getSession(), stdOutReader); String result = getOutputifAvailable(stdOutReader, "Error getting job information from the resource !",jobManagerConfiguration.getBaseMonitorCommand()); JobDescriptor jobDescriptor = new JobDescriptor(); jobManagerConfiguration.getParser().parseSingleJob(jobDescriptor, result); return jobDescriptor; }