@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 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); }
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 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; } }
@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); }
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; }
StandardOutReader jobIDReaderCommandOutput = new StandardOutReader(); log.info("Executing RawCommand : " + rawCommandInfo.getCommand()); CommandExecutor.executeCommand(rawCommandInfo, cluster.getSession(), jobIDReaderCommandOutput); String stdOutputString = getOutputifAvailable(jobIDReaderCommandOutput, "Error submitting job to resource"); log.info("stdout=" + stdOutputString);