use of org.gridlab.gat.GATInvocationException in project compss by bsc-wdc.
the class SshLsfResourceBrokerAdaptor method submitJob.
public Job submitJob(AbstractJobDescription abstractDescription, MetricListener listener, String metricDefinitionName) throws GATInvocationException {
if (!(abstractDescription instanceof JobDescription)) {
throw new GATInvocationException("can only handle JobDescriptions: " + abstractDescription.getClass());
}
JobDescription description = (JobDescription) ((JobDescription) abstractDescription).clone();
SoftwareDescription sd = description.getSoftwareDescription();
int nproc = description.getProcessCount();
if (sd.streamingStderrEnabled() || sd.streamingStdinEnabled() || sd.streamingStdoutEnabled()) {
throw new GATInvocationException("Streaming I/O not supported by SshLSF adaptor");
}
String authority = getAuthority();
if (authority == null) {
authority = "localhost";
}
// Create filename for return value.
String returnValueFile = ".rc." + Math.random();
/*java.io.File jobScriptFile = createJobScript(description);
java.io.File jobStarterFile = null;
if (nproc > 1) {
jobStarterFile = createJobStarter(description, nproc, jobScriptFile);
}*/
java.io.File bsubFile = createBsubScript(description, returnValueFile, nproc);
if (logger.isDebugEnabled()) {
logger.debug("**** Adding pre and post staging:\n " + sd);
}
try {
// Careful, you may be running on windows, so add a scheme.
sd.addPostStagedFile(GAT.createFile(gatContext, new URI(returnValueFile)));
} catch (Throwable e) {
throw new GATInvocationException("Error in file staging", e);
}
ResourceBroker subBroker;
try {
subBroker = subResourceBroker(getSubContext(gatContext), brokerURI);
} catch (Throwable e) {
throw new GATInvocationException("Could not create subbroker to submit LSF jobs through ssh", e);
}
Sandbox sandbox = new Sandbox(gatContext, description, authority, null, true, true, true, true);
SshLSFJob sshLSFJob = new SshLSFJob(gatContext, brokerURI, description, sandbox, subBroker, returnValueFile);
Job job = null;
if (description instanceof WrapperJobDescription) {
WrapperJobCpi tmp = new WrapperJobCpi(gatContext, sshLSFJob, listener, metricDefinitionName);
listener = tmp;
job = tmp;
} else {
job = sshLSFJob;
}
if (listener != null && metricDefinitionName != null) {
Metric metric = sshLSFJob.getMetricDefinitionByName(metricDefinitionName).createMetric(null);
sshLSFJob.addMetricListener(listener, metric);
}
if (logger.isDebugEnabled()) {
logger.debug("*******We are going to perform the ssh submission: ");
}
String jobid = sshLsfSubmission(sshLSFJob, description, bsubFile, subBroker, sandbox);
if (jobid != null) {
sshLSFJob.setState(Job.JobState.SCHEDULED);
sshLSFJob.setSoft(description.getSoftwareDescription());
sshLSFJob.setJobID(jobid);
sshLSFJob.startListener();
} else {
// sandbox.removeSandboxDir();
throw new GATInvocationException("Could not submit sshLSF job");
}
bsubFile.delete();
return job;
}
use of org.gridlab.gat.GATInvocationException in project compss by bsc-wdc.
the class FileAdaptorTest method lengthTest.
private AdaptorTestResultEntry lengthTest(GATContext gatContext, Preferences preferences, String host, String filename, int tabs, long correctValue) {
FileInterface file = null;
try {
file = GAT.createFile(gatContext, preferences, "any://" + host + "/" + filename).getFileInterface();
} catch (GATObjectCreationException e) {
return new AdaptorTestResultEntry(false, 0, e);
}
long start = System.currentTimeMillis();
long length;
try {
length = file.length();
} catch (GATInvocationException e) {
return new AdaptorTestResultEntry(false, 0, e);
}
long stop = System.currentTimeMillis();
return new AdaptorTestResultEntry(length == correctValue, (stop - start), null);
}
use of org.gridlab.gat.GATInvocationException in project compss by bsc-wdc.
the class FileAdaptorTest method canReadTest.
private AdaptorTestResultEntry canReadTest(GATContext gatContext, Preferences preferences, String host, String filename, int tabs, boolean correctValue) {
FileInterface file = null;
try {
file = GAT.createFile(gatContext, preferences, "any://" + host + "/" + filename).getFileInterface();
} catch (GATObjectCreationException e) {
return new AdaptorTestResultEntry(false, 0, e);
}
long start = System.currentTimeMillis();
boolean readable;
try {
readable = file.canRead();
} catch (GATInvocationException e) {
return new AdaptorTestResultEntry(false, 0, e);
}
long stop = System.currentTimeMillis();
return new AdaptorTestResultEntry(readable == correctValue, (stop - start), null);
}
use of org.gridlab.gat.GATInvocationException in project compss by bsc-wdc.
the class FileAdaptorTest method run.
private void run(String host, String script) {
Preferences preferences = new Preferences();
preferences.put("resourcebroker.adaptor.name", "commandlinessh,sshtrilead,local");
preferences.put("file.adaptor.name", "commandlinessh,sshtrilead,local");
SoftwareDescription sd = new SoftwareDescription();
sd.setExecutable("/bin/bash");
sd.setArguments(script);
try {
sd.addPreStagedFile(GAT.createFile(preferences, "tests" + java.io.File.separator + "src" + java.io.File.separator + "benchmarks" + java.io.File.separator + script));
} catch (GATObjectCreationException e) {
e.printStackTrace();
System.exit(1);
}
ResourceBroker broker = null;
try {
broker = GAT.createResourceBroker(preferences, new URI("any://" + host));
} catch (GATObjectCreationException e) {
e.printStackTrace();
System.exit(1);
} catch (URISyntaxException e) {
e.printStackTrace();
System.exit(1);
}
Job job = null;
try {
job = broker.submitJob(new JobDescription(sd));
} catch (GATInvocationException e) {
e.printStackTrace();
System.exit(1);
}
while (job.getState() != Job.JobState.STOPPED && job.getState() != Job.JobState.SUBMISSION_ERROR) {
try {
Thread.sleep(500);
} catch (InterruptedException e) {
// ignored
}
}
}
use of org.gridlab.gat.GATInvocationException in project compss by bsc-wdc.
the class FileAdaptorTest method listTest.
private AdaptorTestResultEntry listTest(GATContext gatContext, Preferences preferences, String host, String filename, int tabs, String... correctValue) {
FileInterface file = null;
try {
file = GAT.createFile(gatContext, preferences, "any://" + host + "/" + filename).getFileInterface();
} catch (GATObjectCreationException e) {
return new AdaptorTestResultEntry(false, 0, e);
}
long start = System.currentTimeMillis();
String[] list;
try {
list = file.list();
} catch (GATInvocationException e) {
return new AdaptorTestResultEntry(false, 0, e);
}
long stop = System.currentTimeMillis();
return new AdaptorTestResultEntry(isCorrect(list, correctValue), (stop - start), null);
}
Aggregations