Search in sources :

Example 11 with ResourceBroker

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

Example 12 with ResourceBroker

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

Example 13 with ResourceBroker

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();
}
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 14 with ResourceBroker

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;
}
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 15 with ResourceBroker

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();
    }
}
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)26 JobDescription (org.gridlab.gat.resources.JobDescription)26 ResourceBroker (org.gridlab.gat.resources.ResourceBroker)26 SoftwareDescription (org.gridlab.gat.resources.SoftwareDescription)24 Job (org.gridlab.gat.resources.Job)19 GATInvocationException (org.gridlab.gat.GATInvocationException)18 URISyntaxException (java.net.URISyntaxException)17 GATObjectCreationException (org.gridlab.gat.GATObjectCreationException)16 Preferences (org.gridlab.gat.Preferences)8 IOException (java.io.IOException)6 File (org.gridlab.gat.io.File)6 BufferedReader (java.io.BufferedReader)4 InputStreamReader (java.io.InputStreamReader)4 GATContext (org.gridlab.gat.GATContext)3 HashMap (java.util.HashMap)2 WrapperJobDescription (org.gridlab.gat.resources.WrapperJobDescription)2 CertificateSecurityContext (org.gridlab.gat.security.CertificateSecurityContext)2 File (java.io.File)1 InputStream (java.io.InputStream)1 AdvertService (org.gridlab.gat.advert.AdvertService)1