public static void main(String[] args) { String test = "Job <2477982> is submitted to queue <short>."; System.out.println(test.substring(test.indexOf("<")+1, test.indexOf(">"))); String test1 = "JOBID USER STAT QUEUE FROM_HOST EXEC_HOST JOB_NAME SUBMIT_TIME\n" + "2636607 lg11w RUN long ghpcc06 c11b02 *069656647 Mar 7 00:58\n" + "2636582 lg11w RUN long ghpcc06 c02b01 2134490944 Mar 7 00:48"; Map<String, JobStatus> statusMap = new HashMap<String, JobStatus>(); statusMap.put("2477983,2134490944", JobStatus.U); LSFOutputParser lsfOutputParser = new LSFOutputParser(); try { lsfOutputParser.parseJobStatuses("cjh", statusMap, test1); } catch (SSHApiException e) { logger.error(e.getMessage(), e); } System.out.println(statusMap.get("2477983,2134490944")); } }
public synchronized void scpThirdParty(String remoteFileSource, String remoteFileTarget) throws SSHApiException { try { if(!session.isConnected()){ session.connect(); } log.info("Transfering from:" + remoteFileSource + " To: " + remoteFileTarget); SSHUtils.scpThirdParty(remoteFileSource, remoteFileTarget, session); } catch (IOException e) { throw new SSHApiException("Failed during scping file:" + remoteFileSource + " to remote file " +remoteFileTarget , e); } catch (JSchException e) { throw new SSHApiException("Failed during scping file:" + remoteFileSource + " to remote file " +remoteFileTarget, e); } }
String error = "Cancel request failed " + jobExecutionContext.getHostName() + " message: " + e.getMessage(); log.error(error); StringWriter errors = new StringWriter(); e.printStackTrace(new PrintWriter(errors)); GFacUtils.saveErrorDetails(jobExecutionContext, errors.toString(), CorrectiveAction.CONTACT_SUPPORT, ErrorCategory.AIRAVATA_INTERNAL_ERROR);
String error = "Error submitting the job to host " + jobExecutionContext.getHostName() + " message: " + e.getMessage(); log.error(error); jobDetails.setJobID("none"); GFacUtils.saveJobStatus(jobExecutionContext, jobDetails, JobState.FAILED, monitorPublisher); GFacUtils.saveErrorDetails(jobExecutionContext, e.getCause().toString(), CorrectiveAction.CONTACT_SUPPORT, ErrorCategory.AIRAVATA_INTERNAL_ERROR); throw new GFacProviderException(error, e); } catch (Exception e) {
try { StringWriter errors = new StringWriter(); e.printStackTrace(new PrintWriter(errors)); GFacUtils.saveErrorDetails(jobExecutionContext, errors.toString(), CorrectiveAction.CONTACT_SUPPORT, ErrorCategory.AIRAVATA_INTERNAL_ERROR); } catch (GFacException e1) { log.error(e.getMessage()); throw new GFacHandlerException(e); } catch (Exception e) {
/** * This method will read standard output and if there's any it will be parsed * * @param jobIDReaderCommandOutput * @param errorMsg * @return * @throws SSHApiException */ private String getOutputifAvailable(StandardOutReader jobIDReaderCommandOutput, String errorMsg, String command) throws SSHApiException { String stdOutputString = jobIDReaderCommandOutput.getStdOutputString(); String stdErrorString = jobIDReaderCommandOutput.getStdErrorString(); log.info("StandardOutput Returned:" + stdOutputString); log.info("StandardError Returned:" +stdErrorString); String[] list = command.split(File.separator); command = list[list.length - 1]; // We are checking for stderr containing the command issued. Thus ignores the verbose logs in stderr. if (stdErrorString != null && stdErrorString.contains(command.trim()) && !stdErrorString.contains("Warning")) { log.error("Standard Error output : " + stdErrorString); throw new SSHApiException(errorMsg + "\n\r StandardOutput: "+ stdOutputString + "\n\r StandardError: "+ stdErrorString); }else if(stdOutputString.contains("error")){ throw new SSHApiException(errorMsg + "\n\r StandardOutput: "+ stdOutputString + "\n\r StandardError: "+ stdErrorString); } return stdOutputString; }
if (e.getMessage().contains("No such file or directory")) { throw new AiravataMonitorException(e); } catch (SSHApiException e) { logger.error(e.getMessage()); if (e.getMessage().contains("Unknown Job Id Error")) { } else if (e.getMessage().contains("illegally formed job identifier")) { logger.error("Wrong job ID is given so dropping the job from monitoring system"); } else if (!this.queue.contains(take)) {
/** * This method will read standard output and if there's any it will be parsed * * @param jobIDReaderCommandOutput * @param errorMsg * @return * @throws SSHApiException */ private String getOutputifAvailable(StandardOutReader jobIDReaderCommandOutput, String errorMsg) throws SSHApiException { String stdOutputString = jobIDReaderCommandOutput.getStdOutputString(); String stdErrorString = jobIDReaderCommandOutput.getStdErrorString(); if (stdOutputString == null || stdOutputString.isEmpty() || (stdErrorString != null && !stdErrorString.isEmpty())) { log.error("Standard Error output : " + stdErrorString); throw new SSHApiException(errorMsg + stdErrorString); } return stdOutputString; }
monitor(jobExecutionContext); } catch (SSHApiException e) { String error = "Error submitting the job to host " + jobExecutionContext.getHostName() + " message: " + e.getMessage(); log.error(error); jobDetails.setJobID("none");
String error = "System configuration file '" + jobManagerConfiguration.getJobDescriptionTemplateName() + "' not found in the classpath"; throw new SSHApiException(error); FileUtils.writeStringToFile(tempPBSFile, scriptContent); } catch (TransformerConfigurationException e) { throw new SSHApiException("Error parsing PBS transformation", e); } catch (TransformerException e) { throw new SSHApiException("Error generating PBS script", e); } catch (IOException e) { throw new SSHApiException("An exception occurred while connecting to server." + "Connecting server - " + serverInfo.getHost() + ":" + serverInfo.getPort() + " connecting user name - "
String error = "System configuration file '" + jobManagerTemplate + "' not found in the classpath"; throw new SSHApiException(error);
throw new SSHApiException("Failed during listing directory:" + directoryPath + " to remote file ", e); reconnect(serverInfo, authenticationInfo); if (retry == 0) { throw new SSHApiException("Failed during listing directory :" + directoryPath + " to remote file ", e); throw new SSHApiException("Failed during listing directory :" + directoryPath + " to remote file " + serverInfo.getHost() + ":rFile", e);
reconnect(serverInfo, authenticationInfo); if (retry == 0) { throw new SSHApiException("Failed during scping local file:" + localFile + " to remote file " + serverInfo.getHost() + ":rFile : " + remoteFile, e); throw new SSHApiException("Failed during scping local file:" + localFile + " to remote file " + serverInfo.getHost() + ":rFile : " + remoteFile, e);
retry = 0; } catch (IOException e) { throw new SSHApiException("Failed during creating directory:" + directoryPath + " to remote file " + serverInfo.getHost() + ":rFile", e); } catch (JSchException e) { throw new SSHApiException("Failed during creating directory :" + directoryPath + " to remote file " + serverInfo.getHost() + ":rFile", e); throw new SSHApiException("Failed during creating directory :" + directoryPath + " to remote file " + serverInfo.getHost() + ":rFile", e);
throw new SSHApiException("Failed during listing directory:" + directoryPath + " to remote file ", e); reconnect(serverInfo, authenticationInfo); if (retry == 0) { throw new SSHApiException("Failed during listing directory :" + directoryPath + " to remote file ", e); throw new SSHApiException("Failed during listing directory :" + directoryPath + " to remote file " + serverInfo.getHost() + ":rFile", e);
String error = "System configuration file '" + jobManagerConfiguration.getJobDescriptionTemplateName() + "' not found in the classpath"; throw new SSHApiException(error); throw new SSHApiException("Error parsing PBS transformation", e); } catch (TransformerException e) { throw new SSHApiException("Error generating PBS script", e); } catch (IOException e) { throw new SSHApiException("An exception occurred while connecting to server." + "Connecting server - " + serverInfo.getHost() + ":" + serverInfo.getPort() + " connecting user name - "
String error = "Error Reading input Stream"; log.error(error); throw new SSHApiException(error); String error = "Error Reading input Stream"; log.error(error); throw new SSHApiException(error); String error = "Error Reading input Stream"; log.error(error); throw new SSHApiException(error); String error = "Error Reading input Stream"; log.error(error); throw new SSHApiException(error); throw new SSHApiException(stdOutReader.getStdErrorString());
throw new SSHApiException("Failed during scping local file:" + localFile + " to remote file " + serverInfo.getHost() + ":rFile", e); }else{ throw new SSHApiException("Failed during scping local file:" + localFile + " to remote file " + serverInfo.getHost() + ":rFile", e); }else{
String error = "Error transfering the file content"; log.error(error); throw new SSHApiException(error); throw new SSHApiException(stdOutReader.getStdErrorString());
String error = "Error transfering the file content"; log.error(error); throw new SSHApiException(error); throw new SSHApiException(stdOutReader.getStdErrorString());