use of org.gridlab.gat.URI in project compss by bsc-wdc.
the class LoadLevelerFileAdaptor method getFile.
private File getFile(URI location) {
File file;
URI correctedURI = newcorrectURI(location);
logger.debug("corrected uri '" + location + "' to '" + correctedURI + "'");
if ((correctedURI.getPath() == null) || (correctedURI.getPath().equals(""))) {
file = new File(".");
} else {
String path = correctedURI.getPath();
if (java.io.File.separatorChar == '\\') {
// This means we're on a Windows machine!
if (path.startsWith("/")) {
path = path.substring(1);
}
path = path.replace("/", "\\");
}
file = new File(path);
}
return file;
}
use of org.gridlab.gat.URI in project compss by bsc-wdc.
the class LoadLevelerFileAdaptor method renameTo.
/*
* (non-Javadoc)
*
* @see org.gridlab.gat.io.File#renameTo(java.io.File)
*/
public boolean renameTo(org.gridlab.gat.io.File arg0) throws GATInvocationException {
URI arg = arg0.toGATURI();
File tmp = getFile(arg);
return f.renameTo(tmp);
}
use of org.gridlab.gat.URI in project compss by bsc-wdc.
the class LsfFileAdaptor method getFile.
private File getFile(URI location) {
File file;
URI correctedURI = newcorrectURI(location);
logger.debug("corrected uri '" + location + "' to '" + correctedURI + "'");
if ((correctedURI.getPath() == null) || (correctedURI.getPath().equals(""))) {
file = new File(".");
} else {
String path = correctedURI.getPath();
if (java.io.File.separatorChar == '\\') {
// This means we're on a Windows machine!
if (path.startsWith("/")) {
path = path.substring(1);
}
path = path.replace("/", "\\");
}
file = new File(path);
}
return file;
}
use of org.gridlab.gat.URI in project compss by bsc-wdc.
the class LsfFileAdaptor method renameTo.
/*
* (non-Javadoc)
*
* @see org.gridlab.gat.io.File#renameTo(java.io.File)
*/
public boolean renameTo(org.gridlab.gat.io.File arg0) throws GATInvocationException {
URI arg = arg0.toGATURI();
File tmp = getFile(arg);
return f.renameTo(tmp);
}
use of org.gridlab.gat.URI in project compss by bsc-wdc.
the class SshLSFJob method getJobState.
protected void getJobState(String jobID) throws GATInvocationException {
synchronized (this) {
while (jobStateBusy) {
try {
wait();
} catch (InterruptedException e) {
// ignored
}
}
jobStateBusy = true;
}
JobState resultState;
try {
if (state == JobState.POST_STAGING || state == JobState.STOPPED || state == JobState.SUBMISSION_ERROR) {
return;
}
logger.debug("Getting task status in setState()");
// getting the status via ssh ... squeue
java.io.File squeueResultFile = null;
try {
// Create qstat job
SoftwareDescription sd = new SoftwareDescription();
// Use /bin/sh, so that $USER gets expanded.
sd.setExecutable("/bin/sh");
sd.setArguments("-c", "bjobs -noheader " + jobID + " | awk {' print $3 '}");
sd.addAttribute(SoftwareDescription.SANDBOX_USEROOT, "true");
squeueResultFile = java.io.File.createTempFile("GAT", "tmp");
try {
sd.setStdout(GAT.createFile(subContext, new URI("file:///" + squeueResultFile.getAbsolutePath().replace(File.separatorChar, '/'))));
} catch (Throwable e1) {
throw new GATInvocationException("Could not create GAT object for temporary " + squeueResultFile.getAbsolutePath(), e1);
}
JobDescription jd = new JobDescription(sd);
Job job = jobHelper.submitJob(jd, this, "job.status");
synchronized (job) {
while (job.getState() != Job.JobState.STOPPED && job.getState() != Job.JobState.SUBMISSION_ERROR) {
try {
job.wait();
} catch (InterruptedException e) {
// ignore
}
}
}
if (job.getState() != Job.JobState.STOPPED || job.getExitStatus() != 0) {
throw new GATInvocationException("Could not submit squeue job " + sd.toString());
}
// submit success.
BufferedReader in = new BufferedReader(new FileReader(squeueResultFile.getAbsolutePath()));
String status = in.readLine();
// or finished. Set to "" in this case. --Ceriel
if (status == null) {
status = "";
}
if (logger.isDebugEnabled()) {
logger.debug("squeue line: " + status);
}
resultState = mapLSFStatetoGAT(status);
} catch (IOException e) {
logger.debug("retrieving job status sshslurmjob failed", e);
throw new GATInvocationException("Unable to retrieve the Job Status", e);
} finally {
squeueResultFile.delete();
}
} finally {
synchronized (this) {
jobStateBusy = false;
notifyAll();
}
}
if (resultState != JobState.STOPPED) {
setState(resultState);
} else {
setState(JobState.POST_STAGING);
}
}
Aggregations