private String verifyJobSubmission(Cluster cluster, JobDetails jobDetails) { String jobName = jobDetails.getJobName(); String jobId = null; try { jobId = cluster.getJobIdByJobName(jobName, cluster.getServerInfo().getUserName()); } catch (SSHApiException e) { log.error("Error while verifying JobId from JobName"); } return jobId; }
private String stageInputFiles(Cluster cluster, String paramValue, String parentPath) throws GFacException { try { cluster.scpFrom(paramValue, parentPath); return "file://" + parentPath + File.separator + (new File(paramValue)).getName(); } catch (SSHApiException e) { log.error("Error tranfering remote file to local file, remote path: " + paramValue); throw new GFacException(e); } } }
if(paramValue.startsWith("scp:")){ paramValue = paramValue.substring(paramValue.indexOf(":") + 1, paramValue.length()); cluster.scpThirdParty(paramValue, targetFile); }else{ if(paramValue.startsWith("file")){ while(!success){ try { cluster.scpTo(targetFile, paramValue); success = true; } catch (Exception e) {
List<String> outputList = cluster.listDirectory(jobExecutionContext.getWorkingDir(),true); boolean missingOutput = false; cluster.scpFrom(outputFile, outputDataDir); ListIterator<String> li = outputList.listIterator(); while (li.hasNext()) { cluster.scpFrom(outputFile, outputDataDir); String localFile = outputDataDir + File.separator + fileName; jobExecutionContext.addOutputFile(localFile); String downloadFile = jobExecutionContext.getStandardOutput(); String fileName = downloadFile.substring(downloadFile.lastIndexOf(File.separatorChar) + 1, downloadFile.length()); cluster.scpFrom(downloadFile, outputDataDir); String localFile = outputDataDir + File.separator + fileName; jobExecutionContext.addOutputFile(localFile); String downloadFile = jobExecutionContext.getStandardError(); String fileName = downloadFile.substring(downloadFile.lastIndexOf(File.separatorChar) + 1, downloadFile.length()); cluster.scpFrom(downloadFile, outputDataDir); String localFile = outputDataDir + File.separator + fileName; jobExecutionContext.addOutputFile(localFile);
} else if (clusters.containsKey(key)) { int i = new Random().nextInt(Integer.MAX_VALUE) % maxClusterCount; if (clusters.get(key).get(i).getSession().isConnected()) { pbsCluster = clusters.get(key).get(i); } else { pbsCluster.listDirectory("~/"); // its hard to trust isConnected method, so we try to connect if it works we are good,else we recreate } catch (Exception e) { clusters.get(key).remove(i);
outputPath = outputPath + File.separator + jobExecutionContext.getExperimentID() + "-" + jobExecutionContext.getTaskData().getTaskID() + File.separator; pbsCluster.makeDirectory(outputPath); throw new GFacHandlerException("Empty Output returned from the application.." ); pbsCluster.scpTo(outputPath, downloadFile); String fileName = downloadFile.substring(downloadFile.lastIndexOf(File.separatorChar)+1, downloadFile.length()); OutputDataObjectType dataObjectType = new OutputDataObjectType(); }else if (outputDataObjectType.getType() == DataType.STDOUT) { stdoutPresent = true; pbsCluster.scpTo(outputPath, standardOutput); String fileName = standardOutput.substring(standardOutput.lastIndexOf(File.separatorChar)+1, standardOutput.length()); OutputDataObjectType dataObjectType = new OutputDataObjectType(); }else if (outputDataObjectType.getType() == DataType.STDERR) { stderrorPresent = true; pbsCluster.scpTo(outputPath, standardError); String fileName = standardError.substring(standardError.lastIndexOf(File.separatorChar)+1, standardError.length()); OutputDataObjectType dataObjectType = new OutputDataObjectType();
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); jobDetails.setJobName(jobDescriptor.getJobName()); log.info(jobDescriptor.toXML()); String jobID = cluster.submitBatchJob(jobDescriptor); ResourceJobManager resourceJobManager = jobExecutionContext.getResourceJobManager(); String jobFileContent = CommonUtils.getJobFileContent(jobDescriptor, resourceJobManager.getResourceJobManagerType().toString(), resourceJobManager.getJobManagerBinPath());
private static String stageInputFiles(Cluster cluster, JobExecutionContext jobExecutionContext, String paramValue) throws IOException, GFacException { int i = paramValue.lastIndexOf(File.separator); String substring = paramValue.substring(i + 1); try { String targetFile = jobExecutionContext.getInputDir() + File.separator + substring; if (paramValue.startsWith("file")) { paramValue = paramValue.substring(paramValue.indexOf(":") + 1, paramValue.length()); } boolean success = false; int j = 1; while(!success){ try { cluster.scpTo(targetFile, paramValue); success = true; } catch (Exception e) { log.info(e.getLocalizedMessage()); Thread.sleep(2000); if(j==3) { throw new GFacHandlerException("Error while input File Staging", e, e.getLocalizedMessage()); } } j++; } return targetFile; } catch (Exception e) { throw new GFacHandlerException("Error while input File Staging", e, e.getLocalizedMessage()); } }
cluster.makeDirectory(workingDirectory); if(!jobExecutionContext.getInputDir().equals(workingDirectory)) cluster.makeDirectory(jobExecutionContext.getInputDir()); if(!jobExecutionContext.getOutputDir().equals(workingDirectory)) cluster.makeDirectory(jobExecutionContext.getOutputDir());
if (cluster.cancelJob(jobDetails.getJobID()) != null) {
public HPCMonitorID(AuthenticationInfo authenticationInfo, JobExecutionContext jobExecutionContext) { super(jobExecutionContext); this.authenticationInfo = authenticationInfo; if (this.authenticationInfo != null) { try { String hostAddress = jobExecutionContext.getHostName(); SecurityContext securityContext = jobExecutionContext.getSecurityContext(hostAddress); ServerInfo serverInfo = null; if (securityContext != null) { if (securityContext instanceof GSISecurityContext){ serverInfo = (((GSISecurityContext) securityContext).getPbsCluster()).getServerInfo(); if (serverInfo.getUserName() != null) { setUserName(serverInfo.getUserName()); } } if (securityContext instanceof SSHSecurityContext){ serverInfo = (((SSHSecurityContext) securityContext).getPbsCluster()).getServerInfo(); if (serverInfo.getUserName() != null) { setUserName(serverInfo.getUserName()); } } } } catch (GFacException e) { logger.error("Error while getting security context", e); } } }
data.append("jobDesc=").append(jobDescriptor.toXML()); jobDetails.setJobDescription(jobDescriptor.toXML()); String jobID = cluster.submitBatchJob(jobDescriptor); jobExecutionContext.setJobDetails(jobDetails); if (jobID == null) {
} else if (clusters.containsKey(key)) { int i = new Random().nextInt(Integer.MAX_VALUE) % maxClusterCount; if (clusters.get(key).get(i).getSession().isConnected()) { pbsCluster = (PBSCluster) clusters.get(key).get(i); } else {
private boolean verifyJobSubmissionByJobId(Cluster cluster, String jobID) throws SSHApiException { JobStatus status = cluster.getJobStatus(jobID); return status != null && status != JobStatus.U; }
while(stdOutStr.isEmpty()){ try { cluster.scpFrom(jobExecutionContext.getStandardOutput(), localStdOutFile.getAbsolutePath()); stdOutStr = GFacUtils.readFileToString(localStdOutFile.getAbsolutePath()); } catch (Exception e) { } else { localStdErrFile = new File(outputDataDir + File.separator + jobExecutionContext.getApplicationName() + ".stderr"); cluster.scpFrom(jobExecutionContext.getStandardError(), localStdErrFile.getAbsolutePath()); StringBuffer temp = new StringBuffer(data.append(localStdErrFile.getAbsolutePath()).append(",").toString()); GFacUtils.saveHandlerData(jobExecutionContext, temp.insert(0, ++index), this.getClass().getName()); int retry=3; while(retry>0){ outputList = cluster.listDirectory(jobExecutionContext.getOutputDir()); if (outputList.size() == 1 && outputList.get(0).isEmpty()) { Thread.sleep(10000); data.append(oldFiles.get(index++)).append(","); } else { cluster.scpFrom(downloadFile, outputDataDir); String fileName = downloadFile.substring(downloadFile.lastIndexOf(File.separatorChar) + 1, downloadFile.length()); localFile = outputDataDir + File.separator + fileName; data.append(oldFiles.get(index++)).append(","); } else { cluster.scpFrom(jobExecutionContext.getOutputDir() + File.separator + valueList, outputDataDir); outputFile = outputDataDir + File.separator + valueList; jobExecutionContext.addOutputFile(outputFile);
} else if (clusters.containsKey(key)) { int i = new Random().nextInt(Integer.MAX_VALUE) % maxClusterCount; if (clusters.get(key).get(i).getSession().isConnected()) { pbsCluster = clusters.get(key).get(i); } else { pbsCluster.listDirectory("~/"); // its hard to trust isConnected method, so we try to connect if it works we are good,else we recreate } catch (Exception e) { clusters.get(key).remove(i);
log.info(remoteFile); File runscript = createShellScript(jobExecutionContext); cluster.scpTo(remoteFile, runscript.getAbsolutePath()); } else { hpcType = true;
cluster.makeDirectory(workingDirectory); if(!jobExecutionContext.getInputDir().equals(workingDirectory)) cluster.makeDirectory(jobExecutionContext.getInputDir()); if(!jobExecutionContext.getOutputDir().equals(workingDirectory)) cluster.makeDirectory(jobExecutionContext.getOutputDir());
cluster.cancelJob(jobDetails.getJobID()); } else { log.error("No Job Id is set, so cannot perform the cancel operation !!!");
while (stdOutStr.isEmpty()) { try { cluster.scpFrom(jobExecutionContext.getStandardOutput(), localStdOutFile.getAbsolutePath()); stdOutStr = GFacUtils.readFileToString(localStdOutFile.getAbsolutePath()); } catch (Exception e) { cluster.scpFrom(jobExecutionContext.getStandardError(), localStdErrFile.getAbsolutePath()); Thread.sleep(1000); int retry = 3; while (retry > 0) { outputList = cluster.listDirectory(jobExecutionContext.getOutputDir()); if (outputList.size() > 0) { break; if (DataType.URI == actualParameter1.getType()) { String downloadFile = actualParameter1.getValue(); cluster.scpFrom(downloadFile, outputDataDir); String fileName = downloadFile.substring(downloadFile.lastIndexOf(File.separatorChar) + 1, downloadFile.length()); String localFile = outputDataDir + File.separator + fileName; } else if (outputList.size() == 1) {//FIXME: Ultrascan case String valueList = outputList.get(0); cluster.scpFrom(jobExecutionContext.getOutputDir() + File.separator + valueList, outputDataDir); String outputPath = outputDataDir + File.separator + valueList; jobExecutionContext.addOutputFile(outputPath);