use of org.gridlab.gat.resources.SoftwareDescription in project compss by bsc-wdc.
the class FileOutputStreamAdaptorTest 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.resources.SoftwareDescription in project compss by bsc-wdc.
the class ResourceBrokerStreamingOutExample method start.
public void start(String brokerURI) {
ResourceBroker broker = null;
try {
broker = GAT.createResourceBroker(new URI(brokerURI));
} catch (GATObjectCreationException e) {
System.err.println("Failed to create resource broker at location '" + brokerURI + "': " + e);
return;
} catch (URISyntaxException e) {
System.err.println("Wrong uri '" + brokerURI + "': " + e);
return;
}
SoftwareDescription sd = new SoftwareDescription();
sd.setExecutable("/usr/bin/env");
sd.enableStreamingStdout(true);
JobDescription jd = new JobDescription(sd);
Job job = null;
try {
job = broker.submitJob(jd);
} catch (GATInvocationException e) {
System.err.println("Failed to submit the job: " + e);
return;
}
InputStream in = null;
try {
in = job.getStdout();
} catch (GATInvocationException e) {
System.err.println("Failed to get the stdout stream: " + e);
return;
}
while (true) {
int i = 0;
try {
i = in.read();
} catch (IOException e) {
System.err.println("Failed to read: " + e);
return;
}
if (i == -1) {
break;
} else {
System.out.print((char) i);
}
}
}
use of org.gridlab.gat.resources.SoftwareDescription in project compss by bsc-wdc.
the class SubmitLocalJob method main.
public static void main(String[] args) throws Exception {
SoftwareDescription sd = new SoftwareDescription();
sd.setExecutable("/bin/hostname");
File stdout = GAT.createFile("hostname.txt");
sd.setStdout(stdout);
JobDescription jd = new JobDescription(sd);
ResourceBroker broker = GAT.createResourceBroker(new URI("any://localhost"));
Job job = broker.submitJob(jd);
while ((job.getState() != JobState.STOPPED) && (job.getState() != JobState.SUBMISSION_ERROR)) Thread.sleep(1000);
GAT.end();
}
use of org.gridlab.gat.resources.SoftwareDescription in project compss by bsc-wdc.
the class SubmitRemoteJob method main.
public static void main(String[] args) throws Exception {
SoftwareDescription sd = new SoftwareDescription();
sd.setExecutable("/bin/hostname");
File stdout = GAT.createFile("hostname.txt");
sd.setStdout(stdout);
JobDescription jd = new JobDescription(sd);
Preferences prefs = new Preferences();
/*
prefs.put("VirtualOrganisation", "pvier");
prefs.put("vomsServerURL", "voms.grid.sara.nl");
prefs.put("vomsServerPort", "30000");
prefs.put("vomsHostDN", "/O=dutchgrid/O=hosts/OU=sara.nl/CN=voms.grid.sara.nl");
*/
CertificateSecurityContext ctxt = new CertificateSecurityContext(new URI(System.getProperty("user.home") + "/.globus/userkey.pem"), new URI(System.getProperty("user.home") + "/.globus/usercert.pem"), getPassphrase());
GATContext context = new GATContext();
context.addPreferences(prefs);
context.addSecurityContext(ctxt);
ResourceBroker broker = GAT.createResourceBroker(context, new URI(args[0]));
Job job = broker.submitJob(jd);
while ((job.getState() != JobState.STOPPED) && (job.getState() != JobState.SUBMISSION_ERROR)) {
System.out.println("State: " + job.getState());
Thread.sleep(1000);
}
}
Aggregations