use of org.gridlab.gat.URI 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.URI in project compss by bsc-wdc.
the class GATWorkerNode method setInternalURI.
@Override
public void setInternalURI(MultiURI uri) {
String scheme = uri.getScheme();
String user = this.config.getUser().isEmpty() ? "" : this.config.getUser() + "@";
String host = this.config.getHost();
String filePath = uri.getPath();
String s = (scheme + user + host + File.separator + filePath);
org.gridlab.gat.URI gat;
try {
gat = new org.gridlab.gat.URI(s);
uri.setInternalURI(GATAdaptor.ID, gat);
} catch (URISyntaxException e) {
LOGGER.error(URI_CREATION_ERR, e);
}
}
use of org.gridlab.gat.URI 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.URI in project compss by bsc-wdc.
the class GATTracer method generatePackage.
public static boolean generatePackage(GATWorkerNode node) {
LinkedList<URI> traceScripts = new LinkedList<>();
LinkedList<String> traceParams = new LinkedList<>();
String host = node.getHost();
String installDir = node.getInstallDir();
String workingDir = node.getWorkingDir();
String user = node.getUser();
if (user == null || user.isEmpty()) {
user = "";
} else {
user += "@";
}
try {
traceScripts.add(new URI(Protocol.ANY_URI.getSchema() + user + host + File.separator + installDir + TRACE_SCRIPT_PATH));
} catch (URISyntaxException e) {
LOGGER.error("Error deleting tracing host", e);
return false;
}
String pars = "package " + workingDir + " " + host;
traceParams.add(pars);
// Use cleaner to run the trace script and generate the package
return new GATScriptExecutor(node).executeScript(traceScripts, traceParams, "trace_packaging_" + host);
}
use of org.gridlab.gat.URI 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