use of org.gridlab.gat.resources.ResourceBroker in project compss by bsc-wdc.
the class TestSubmitGlobus method test.
public void test(final String host) throws Exception {
final SoftwareDescription sd = new SoftwareDescription();
sd.setExecutable("/bin/sleep");
sd.setArguments("10");
final JobDescription jd = new JobDescription(sd);
Preferences prefs = new Preferences();
prefs.put("resourcebroker.adaptor.name", "wsgt4new");
prefs.put("file.adaptor.name", "local,gridftp");
CertificateSecurityContext ctxt = new CertificateSecurityContext(new URI(System.getProperty("user.home") + "/.globus/userkey.pem"), new URI(System.getProperty("user.home") + "/.globus/usercert.pem"), getPassphrase());
final GATContext context = new GATContext();
context.addPreferences(prefs);
context.addSecurityContext(ctxt);
File[] files = new File[NFILES];
for (int i = 0; i < files.length; i++) {
files[i] = GAT.createFile(context, "file" + i);
files[i].createNewFile();
}
for (File f : files) {
sd.addPreStagedFile(f);
sd.addPostStagedFile(f);
}
final ResourceBroker broker = GAT.createResourceBroker(context, new URI(host));
for (int j = 0; j < NBATCHES; j++) {
logger.info("Starting a batch of " + NJOBS + " jobs");
for (int i = 0; i < NJOBS; i++) {
Thread t = new Thread() {
public void run() {
try {
broker.submitJob(jd, TestSubmitGlobus.this, "job.status");
} catch (Throwable e) {
System.out.println("Submit failed");
e.printStackTrace();
synchronized (TestSubmitGlobus.this) {
finished++;
TestSubmitGlobus.this.notifyAll();
}
}
}
};
t.start();
}
synchronized (this) {
while (finished < NJOBS * (j - BACK)) {
logger.info("Waiting until at least " + (NJOBS * (j - BACK)) + " jobs are finished");
try {
wait();
} catch (Throwable e) {
// ignore
}
}
}
}
synchronized (this) {
while (finished != NJOBS * NBATCHES) {
try {
wait();
} catch (Throwable e) {
// ignore
}
}
}
}
use of org.gridlab.gat.resources.ResourceBroker in project compss by bsc-wdc.
the class SubmitJobCallback method start.
public void start(String brokerURI) throws GATObjectCreationException, URISyntaxException, GATInvocationException {
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(brokerURI));
broker.submitJob(jd, this, "job.status");
synchronized (this) {
try {
wait();
} catch (InterruptedException e) {
// ignore
}
}
}
use of org.gridlab.gat.resources.ResourceBroker in project compss by bsc-wdc.
the class SubmitJobWithMultipleInputs method main.
public static void main(String[] args) throws Exception {
ResourceBroker broker = GAT.createResourceBroker(new URI(args[0]));
SoftwareDescription sd = new SoftwareDescription();
sd.setExecutable(args[1]);
sd.setStdout(GAT.createFile("stdout.txt"));
sd.setStderr(GAT.createFile("stderr.txt"));
String[] arguments = new String[args.length - 2];
for (int i = 2; i < args.length; i++) {
File tmp = GAT.createFile(args[i]);
sd.addPreStagedFile(tmp);
arguments[i - 2] = tmp.getName();
}
sd.setArguments(arguments);
Job job = broker.submitJob(new JobDescription(sd));
while ((job.getState() != JobState.STOPPED) && (job.getState() != JobState.SUBMISSION_ERROR)) {
Thread.sleep(1000);
}
GAT.end();
}
use of org.gridlab.gat.resources.ResourceBroker in project compss by bsc-wdc.
the class GATTracer method startTracing.
public static Job startTracing(GATWorkerNode worker) {
if (DEBUG) {
LOGGER.debug("Starting trace for woker " + worker.getHost());
}
tracingLevel = 1;
int numTasks = worker.getTotalComputingUnits();
if (numTasks <= 0) {
if (DEBUG) {
LOGGER.debug("Resource " + worker.getName() + " has 0 slots, it won't appear in the trace");
}
return null;
}
int hostId = Tracer.registerHost(worker.getName(), numTasks);
String user;
if (worker.getUser() == null || worker.getUser().isEmpty()) {
user = "";
} else {
user = worker.getUser() + "@";
}
SoftwareDescription sd = new SoftwareDescription();
String uriString = Protocol.ANY_URI.getSchema() + user + worker.getHost();
sd.addAttribute("uri", uriString);
sd.setExecutable(worker.getInstallDir() + Tracer.TRACE_SCRIPT_PATH);
sd.setArguments(new String[] { "init", worker.getWorkingDir(), String.valueOf(hostId), String.valueOf(numTasks) });
if (DEBUG) {
try {
org.gridlab.gat.io.File outFile = GAT.createFile(worker.getContext(), Protocol.ANY_URI.getSchema() + File.separator + System.getProperty(COMPSsConstants.APP_LOG_DIR) + traceOutRelativePath);
sd.setStdout(outFile);
org.gridlab.gat.io.File errFile = GAT.createFile(worker.getContext(), Protocol.ANY_URI.getSchema() + File.separator + System.getProperty(COMPSsConstants.APP_LOG_DIR) + traceErrRelativePath);
sd.setStderr(errFile);
} catch (Exception e) {
ErrorManager.warn("Error initializing tracing system in node " + worker.getHost(), e);
return null;
}
}
sd.addAttribute(SoftwareDescription.SANDBOX_ROOT, File.separator + "tmp" + File.separator);
sd.addAttribute(SoftwareDescription.SANDBOX_USEROOT, "true");
sd.addAttribute(SoftwareDescription.SANDBOX_DELETE, "false");
Job job = null;
try {
URI brokerURI = new URI(uriString);
ResourceBroker broker = GAT.createResourceBroker(worker.getContext(), brokerURI);
LOGGER.debug("Starting tracer init job for worker " + uriString + " submited.");
job = broker.submitJob(new JobDescription(sd));
} catch (Exception e) {
ErrorManager.warn("Error initializing tracing system in node " + worker.getHost(), e);
return null;
}
return job;
}
use of org.gridlab.gat.resources.ResourceBroker in project compss by bsc-wdc.
the class AdvertJob method main.
public static void main(String[] args) throws Exception {
try {
GATContext c = new GATContext();
Preferences prefs = new Preferences();
prefs.put("File.adaptor.name", "local,commandlinessh");
prefs.put("job.stop.on.exit", "false");
c.addPreferences(prefs);
SoftwareDescription sd = new SoftwareDescription();
sd.setExecutable("/bin/sleep");
sd.setArguments("100");
// stdout & stderr
File stdout = GAT.createFile(c, "std.out");
File stderr = GAT.createFile(c, "std.err");
sd.setStderr(stderr);
sd.setStdout(stdout);
ResourceDescription rd = new HardwareResourceDescription();
JobDescription jd = new JobDescription(sd, rd);
ResourceBroker broker = GAT.createResourceBroker(c, new URI("sshsge://fs0.das3.cs.vu.nl"));
Job job = broker.submitJob(jd);
AdvertService a = GAT.createAdvertService(c);
MetaData m = new MetaData();
m.put("name", "testJob");
a.add(job, m, "/rob/testJob");
a.exportDataBase(new URI("file:///mydb"));
GAT.end();
System.exit(0);
} catch (Throwable e) {
e.printStackTrace();
}
}
Aggregations