Search in sources :

Example 31 with URI

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();
}
Also used : JobDescription(org.gridlab.gat.resources.JobDescription) ResourceBroker(org.gridlab.gat.resources.ResourceBroker) Job(org.gridlab.gat.resources.Job) URI(org.gridlab.gat.URI) File(org.gridlab.gat.io.File) SoftwareDescription(org.gridlab.gat.resources.SoftwareDescription)

Example 32 with URI

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);
    }
}
Also used : URISyntaxException(java.net.URISyntaxException) URI(org.gridlab.gat.URI)

Example 33 with URI

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;
}
Also used : JobDescription(org.gridlab.gat.resources.JobDescription) ResourceBroker(org.gridlab.gat.resources.ResourceBroker) Job(org.gridlab.gat.resources.Job) URI(org.gridlab.gat.URI) SoftwareDescription(org.gridlab.gat.resources.SoftwareDescription) URISyntaxException(java.net.URISyntaxException)

Example 34 with URI

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);
}
Also used : URISyntaxException(java.net.URISyntaxException) URI(org.gridlab.gat.URI) GATScriptExecutor(es.bsc.compss.gat.master.utils.GATScriptExecutor) LinkedList(java.util.LinkedList)

Example 35 with URI

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();
    }
}
Also used : GATContext(org.gridlab.gat.GATContext) ResourceBroker(org.gridlab.gat.resources.ResourceBroker) HardwareResourceDescription(org.gridlab.gat.resources.HardwareResourceDescription) AdvertService(org.gridlab.gat.advert.AdvertService) URI(org.gridlab.gat.URI) SoftwareDescription(org.gridlab.gat.resources.SoftwareDescription) JobDescription(org.gridlab.gat.resources.JobDescription) ResourceDescription(org.gridlab.gat.resources.ResourceDescription) HardwareResourceDescription(org.gridlab.gat.resources.HardwareResourceDescription) MetaData(org.gridlab.gat.advert.MetaData) Preferences(org.gridlab.gat.Preferences) Job(org.gridlab.gat.resources.Job) File(org.gridlab.gat.io.File)

Aggregations

URI (org.gridlab.gat.URI)53 URISyntaxException (java.net.URISyntaxException)28 JobDescription (org.gridlab.gat.resources.JobDescription)28 SoftwareDescription (org.gridlab.gat.resources.SoftwareDescription)27 ResourceBroker (org.gridlab.gat.resources.ResourceBroker)26 GATInvocationException (org.gridlab.gat.GATInvocationException)24 Job (org.gridlab.gat.resources.Job)23 GATObjectCreationException (org.gridlab.gat.GATObjectCreationException)19 Preferences (org.gridlab.gat.Preferences)11 BufferedReader (java.io.BufferedReader)8 File (java.io.File)8 IOException (java.io.IOException)8 GATContext (org.gridlab.gat.GATContext)8 File (org.gridlab.gat.io.File)8 InputStreamReader (java.io.InputStreamReader)5 LinkedList (java.util.LinkedList)4 AdvertService (org.gridlab.gat.advert.AdvertService)4 CertificateSecurityContext (org.gridlab.gat.security.CertificateSecurityContext)4 GATScriptExecutor (es.bsc.compss.gat.master.utils.GATScriptExecutor)3 MultiURI (es.bsc.compss.types.uri.MultiURI)3