use of org.gridlab.gat.URI in project compss by bsc-wdc.
the class ResourceBrokerAdaptorTest method submitJobStdout.
private AdaptorTestResultEntry submitJobStdout(GATContext gatContext, Preferences preferences, String host) {
SoftwareDescription sd = new SoftwareDescription();
sd.setExecutable("/bin/echo");
// Arguments modified to test against expansion of shell meta characters --Ceriel
sd.setArguments("test", "1", "2", "'*");
try {
sd.setStdout(GAT.createFile(gatContext, preferences, "stdout"));
} catch (GATObjectCreationException e) {
return new AdaptorTestResultEntry(false, 0L, e);
}
JobDescription jd = new JobDescription(sd);
ResourceBroker broker;
try {
broker = GAT.createResourceBroker(gatContext, preferences, new URI(host));
} catch (GATObjectCreationException e) {
return new AdaptorTestResultEntry(false, 0L, e);
} catch (URISyntaxException e) {
return new AdaptorTestResultEntry(false, 0L, e);
}
long start = System.currentTimeMillis();
Job job;
try {
job = broker.submitJob(jd, this, "job.status");
} catch (GATInvocationException e) {
return new AdaptorTestResultEntry(false, 0L, e);
}
waitForJob();
try {
Map<String, Object> info = job.getInfo();
Throwable ex = (Throwable) info.get("poststage.exception");
if (ex != null) {
return new AdaptorTestResultEntry(false, 0L, ex);
}
} catch (GATInvocationException e) {
return new AdaptorTestResultEntry(false, 0L, e);
}
long stop = System.currentTimeMillis();
String result;
try {
BufferedReader reader = new BufferedReader(new InputStreamReader(new java.io.FileInputStream("stdout")));
result = reader.readLine();
reader.close();
} catch (Exception e) {
return new AdaptorTestResultEntry(false, 0L, e);
}
return new AdaptorTestResultEntry("test 1 2 '*".equals(result), (stop - start), null);
}
use of org.gridlab.gat.URI in project compss by bsc-wdc.
the class ResourceBrokerAdaptorTest method submitJobPostStage.
private AdaptorTestResultEntry submitJobPostStage(GATContext gatContext, Preferences preferences, String host) {
SoftwareDescription sd = new SoftwareDescription();
sd.setExecutable("/bin/touch");
sd.setArguments("flap.txt");
try {
sd.addPostStagedFile(GAT.createFile(gatContext, preferences, "flap.txt"));
} catch (GATObjectCreationException e) {
return new AdaptorTestResultEntry(false, 0L, e);
}
JobDescription jd = new JobDescription(sd);
ResourceBroker broker;
try {
broker = GAT.createResourceBroker(gatContext, preferences, new URI(host));
} catch (GATObjectCreationException e) {
return new AdaptorTestResultEntry(false, 0L, e);
} catch (URISyntaxException e) {
return new AdaptorTestResultEntry(false, 0L, e);
}
long start = System.currentTimeMillis();
Job job;
try {
job = broker.submitJob(jd, this, "job.status");
} catch (GATInvocationException e) {
return new AdaptorTestResultEntry(false, 0L, e);
}
waitForJob();
try {
Map<String, Object> info = job.getInfo();
Throwable ex = (Throwable) info.get("poststage.exception");
if (ex != null) {
return new AdaptorTestResultEntry(false, 0L, ex);
}
} catch (GATInvocationException e) {
return new AdaptorTestResultEntry(false, 0L, e);
}
long stop = System.currentTimeMillis();
return new AdaptorTestResultEntry(new java.io.File("flap.txt").exists(), (stop - start), null);
}
use of org.gridlab.gat.URI in project compss by bsc-wdc.
the class SshLsfResourceBrokerAdaptor method subResourceBroker.
static ResourceBroker subResourceBroker(GATContext context, URI broker) throws URISyntaxException, GATObjectCreationException {
String subScheme;
if (context.getPreferences() != null) {
subScheme = (String) context.getPreferences().get(SSHLSF_SUBMITTER_SCHEME, "ssh");
} else {
subScheme = "ssh";
}
URI subBroker = broker.setScheme(subScheme);
return GAT.createResourceBroker(context, subBroker);
}
use of org.gridlab.gat.URI 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.URI in project compss by bsc-wdc.
the class ConnectToAdvertJob method main.
public static void main(String[] args) throws Exception {
GATContext c = new GATContext();
Preferences prefs = new Preferences();
prefs.put("File.adaptor.name", "local");
AdvertService a = GAT.createAdvertService(c, prefs);
a.importDataBase(new URI("file:///mydb"));
c = new GATContext();
prefs = new Preferences();
// prefs.put("Resourcebroker.adaptor.name", "sshsge");
prefs.put("File.adaptor.name", "local, commandlinessh");
c.addPreferences(prefs);
Job other = (Job) a.getAdvertisable(c, "/rob/testJob");
System.err.println("got job back: " + other);
while ((other.getState() != Job.JobState.STOPPED) && (other.getState() != Job.JobState.SUBMISSION_ERROR)) {
System.err.println("job state = " + other.getInfo());
Thread.sleep(1000);
}
System.err.println("job DONE, state = " + other.getInfo());
GAT.end();
}
Aggregations