Search in sources :

Example 11 with SoftwareDescription

use of org.gridlab.gat.resources.SoftwareDescription in project compss by bsc-wdc.

the class ResourceBrokerAdaptorTest method submitJobParallel.

private AdaptorTestResultEntry submitJobParallel(GATContext gatContext, Preferences preferences, String host) {
    SoftwareDescription sd = new SoftwareDescription();
    sd.setExecutable("/bin/echo");
    sd.setArguments("test", "1", "2", "3");
    try {
        sd.setStdout(GAT.createFile(gatContext, preferences, "parallel-stdout"));
    } catch (GATObjectCreationException e) {
        return new AdaptorTestResultEntry(false, 0L, e);
    }
    JobDescription jd = new JobDescription(sd);
    jd.setProcessCount(2);
    jd.setResourceCount(1);
    ResourceBroker broker;
    try {
        broker = GAT.createResourceBroker(gatContext, preferences, new URI(host));
    } catch (GATObjectCreationException e) {
        return new AdaptorTestResultEntry(false, 0L, e);
    } catch (URISyntaxException e) {
        return new AdaptorTestResultEntry(false, 0L, e);
    }
    long start = System.currentTimeMillis();
    try {
        broker.submitJob(jd, this, "job.status");
    } catch (GATInvocationException e) {
        return new AdaptorTestResultEntry(false, 0L, e);
    }
    waitForJob();
    long stop = System.currentTimeMillis();
    return new AdaptorTestResultEntry(true, (stop - start), null);
}
Also used : JobDescription(org.gridlab.gat.resources.JobDescription) GATObjectCreationException(org.gridlab.gat.GATObjectCreationException) GATInvocationException(org.gridlab.gat.GATInvocationException) ResourceBroker(org.gridlab.gat.resources.ResourceBroker) URISyntaxException(java.net.URISyntaxException) URI(org.gridlab.gat.URI) SoftwareDescription(org.gridlab.gat.resources.SoftwareDescription)

Example 12 with SoftwareDescription

use of org.gridlab.gat.resources.SoftwareDescription in project compss by bsc-wdc.

the class ResourceBrokerAdaptorTest method submitJobStderr.

private AdaptorTestResultEntry submitJobStderr(GATContext gatContext, Preferences preferences, String host) {
    SoftwareDescription sd = new SoftwareDescription();
    sd.setExecutable("/bin/ls");
    sd.setArguments("floep");
    try {
        sd.setStderr(GAT.createFile(gatContext, preferences, "stderr"));
    } catch (GATObjectCreationException e) {
        return new AdaptorTestResultEntry(false, 0L, e);
    }
    JobDescription jd = new JobDescription(sd);
    ResourceBroker broker;
    try {
        broker = GAT.createResourceBroker(gatContext, preferences, new URI(host));
    } catch (GATObjectCreationException e) {
        return new AdaptorTestResultEntry(false, 0L, e);
    } catch (URISyntaxException e) {
        return new AdaptorTestResultEntry(false, 0L, e);
    }
    long start = System.currentTimeMillis();
    Job job;
    try {
        job = broker.submitJob(jd, this, "job.status");
    } catch (GATInvocationException e) {
        return new AdaptorTestResultEntry(false, 0L, e);
    }
    waitForJob();
    try {
        Map<String, Object> info = job.getInfo();
        Throwable ex = (Throwable) info.get("poststage.exception");
        if (ex != null) {
            return new AdaptorTestResultEntry(false, 0L, ex);
        }
    } catch (GATInvocationException e) {
        return new AdaptorTestResultEntry(false, 0L, e);
    }
    long stop = System.currentTimeMillis();
    String result;
    try {
        BufferedReader reader = new BufferedReader(new InputStreamReader(new java.io.FileInputStream("stderr")));
        result = reader.readLine();
        reader.close();
    } catch (Exception e) {
        return new AdaptorTestResultEntry(false, 0L, e);
    }
    return new AdaptorTestResultEntry(result != null && result.endsWith("floep: No such file or directory"), (stop - start), null);
}
Also used : GATObjectCreationException(org.gridlab.gat.GATObjectCreationException) InputStreamReader(java.io.InputStreamReader) ResourceBroker(org.gridlab.gat.resources.ResourceBroker) URISyntaxException(java.net.URISyntaxException) URI(org.gridlab.gat.URI) SoftwareDescription(org.gridlab.gat.resources.SoftwareDescription) URISyntaxException(java.net.URISyntaxException) GATInvocationException(org.gridlab.gat.GATInvocationException) IOException(java.io.IOException) GATObjectCreationException(org.gridlab.gat.GATObjectCreationException) JobDescription(org.gridlab.gat.resources.JobDescription) GATInvocationException(org.gridlab.gat.GATInvocationException) BufferedReader(java.io.BufferedReader) Job(org.gridlab.gat.resources.Job)

Example 13 with SoftwareDescription

use of org.gridlab.gat.resources.SoftwareDescription in project compss by bsc-wdc.

the class ResourceBrokerCallBackExample method start.

public void start(String brokerURI) {
    ResourceBroker broker = null;
    Preferences prefs = new Preferences();
    try {
        broker = GAT.createResourceBroker(prefs, 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("/bin/hostname");
    try {
        sd.setStdout(GAT.createFile("hostname.txt"));
    } catch (GATObjectCreationException e) {
        System.err.println("Failed to create the stdout file 'hostname.txt': " + e);
        return;
    }
    JobDescription jd = new JobDescription(sd);
    try {
        broker.submitJob(jd, this, "job.status");
    } catch (GATInvocationException e) {
        System.err.println("Failed to submit the job: " + e);
        return;
    }
    synchronized (this) {
        try {
            wait();
        } catch (InterruptedException e) {
        // ignore
        }
    }
}
Also used : JobDescription(org.gridlab.gat.resources.JobDescription) GATObjectCreationException(org.gridlab.gat.GATObjectCreationException) GATInvocationException(org.gridlab.gat.GATInvocationException) ResourceBroker(org.gridlab.gat.resources.ResourceBroker) URISyntaxException(java.net.URISyntaxException) Preferences(org.gridlab.gat.Preferences) URI(org.gridlab.gat.URI) SoftwareDescription(org.gridlab.gat.resources.SoftwareDescription)

Example 14 with SoftwareDescription

use of org.gridlab.gat.resources.SoftwareDescription in project compss by bsc-wdc.

the class ResourceBrokerPollingExample 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("/bin/hostname");
    try {
        sd.setStdout(GAT.createFile("hostname.txt"));
    } catch (GATObjectCreationException e) {
        System.err.println("Failed to create the stdout file 'hostname.txt': " + e);
        return;
    }
    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;
    }
    while (job.getState() != JobState.STOPPED) {
        System.out.println("job is in state: " + job.getState());
        try {
            Thread.sleep(200);
        } catch (InterruptedException e) {
        // ignore
        }
    }
}
Also used : JobDescription(org.gridlab.gat.resources.JobDescription) GATObjectCreationException(org.gridlab.gat.GATObjectCreationException) GATInvocationException(org.gridlab.gat.GATInvocationException) ResourceBroker(org.gridlab.gat.resources.ResourceBroker) URISyntaxException(java.net.URISyntaxException) Job(org.gridlab.gat.resources.Job) URI(org.gridlab.gat.URI) SoftwareDescription(org.gridlab.gat.resources.SoftwareDescription)

Example 15 with SoftwareDescription

use of org.gridlab.gat.resources.SoftwareDescription in project compss by bsc-wdc.

the class ResourceBrokerWrapperJobExample method start.

public void start() throws Exception {
    // First we create a wrapper software description. It describes the
    // executable that's used for the wrapper. We only need to specify the
    // executable, and possibly the stdout and stderr location. The other
    // values (arguments, environment variables, etc.) are automatically
    // filled in by JavaGAT. If there's already a compatible JavaGAT
    // installation on the remote machine, we can use that installation
    // instead of pre staging JavaGAT from the submission machine.
    WrapperSoftwareDescription wsd = new WrapperSoftwareDescription();
    wsd.setStdout(GAT.createFile("wrapper.stdout"));
    wsd.setStderr(GAT.createFile("wrapper.stderr"));
    wsd.setExecutable("/usr/local/package/jdk1.6.0/bin/java");
    wsd.setGATLocation(System.getenv("user.home") + "/JavaGatVersions/JavaGAT-2.0-rc2");
    // Now we create a job description out of the software description.
    WrapperJobDescription wjd = new WrapperJobDescription(wsd);
    // Now we're going to construct 30 wrapped jobs. We add these wrapped
    // jobs to the wrapper job.
    JobDescription[] wrappedJobDescriptions = new JobDescription[30];
    for (int i = 0; i < wrappedJobDescriptions.length; i++) {
        SoftwareDescription sd = new SoftwareDescription();
        sd.setExecutable("/bin/sleep");
        sd.setArguments("" + (int) (30 * Math.random()));
        sd.addPreStagedFile(GAT.createFile("largefile"));
        sd.setStdout(GAT.createFile("stdout." + i));
        Preferences preferences = new Preferences();
        preferences.put("resourcebroker.adaptor.name", "local");
        wrappedJobDescriptions[i] = new JobDescription(sd);
        wjd.add(wrappedJobDescriptions[i], new URI("any://localhost"), preferences);
    }
    // All the wrapped job descriptions are added to the wrapper job
    // description. We're now ready to submit the wrapper job. We create a
    // resource broker, using certain preferences, in order to do this.
    Preferences wrapperPreferences = new Preferences();
    wrapperPreferences.put("resourcebroker.adaptor.name", "globus");
    ResourceBroker broker = GAT.createResourceBroker(wrapperPreferences, new URI("any://fs0.das3.cs.vu.nl/jobmanager-sge"));
    // now we're going to submit this wrapper job description 10 times,
    // which will result in 10 wrapper jobs each holding 30 wrapped jobs. We
    // store the wrapper jobs in an array.
    WrapperJob[] wrapperJobs = new WrapperJob[10];
    for (int i = 0; i < wrapperJobs.length; i++) {
        wrapperJobs[i] = (WrapperJob) broker.submitJob(wjd);
    }
    // All the wrapper jobs are submitted. Let's see what happens. We wait
    // until all wrapper jobs are in the state stopped. And in the meantime
    // we print each second the state of the wrapper job and the state of
    // all of its wrapped jobs. (the first entry of a column is the state of
    // the wrapper job, the other entries are states of the wrapped jobs).
    boolean allwrappersstopped = false;
    while (!allwrappersstopped) {
        allwrappersstopped = true;
        for (int i = 0; i < wrapperJobs.length; i++) {
            System.out.print(wrapperJobs[i].getState().toString().substring(0, 5) + "\t");
            allwrappersstopped = allwrappersstopped & wrapperJobs[i].getState() == JobState.STOPPED;
        }
        System.out.println();
        System.out.println("-----");
        for (int j = 0; j < wrappedJobDescriptions.length; j++) {
            for (int i = 0; i < wrapperJobs.length; i++) {
                System.out.print(wrapperJobs[i].getJob(wrappedJobDescriptions[j]).getState().toString().substring(0, 5) + "\t");
            }
            System.out.println();
        }
        System.out.println();
        Thread.sleep(1000);
    }
    GAT.end();
}
Also used : JobDescription(org.gridlab.gat.resources.JobDescription) WrapperJobDescription(org.gridlab.gat.resources.WrapperJobDescription) ResourceBroker(org.gridlab.gat.resources.ResourceBroker) WrapperJob(org.gridlab.gat.resources.WrapperJob) WrapperJobDescription(org.gridlab.gat.resources.WrapperJobDescription) Preferences(org.gridlab.gat.Preferences) WrapperSoftwareDescription(org.gridlab.gat.resources.WrapperSoftwareDescription) URI(org.gridlab.gat.URI) SoftwareDescription(org.gridlab.gat.resources.SoftwareDescription) WrapperSoftwareDescription(org.gridlab.gat.resources.WrapperSoftwareDescription)

Aggregations

SoftwareDescription (org.gridlab.gat.resources.SoftwareDescription)34 JobDescription (org.gridlab.gat.resources.JobDescription)31 URI (org.gridlab.gat.URI)27 GATInvocationException (org.gridlab.gat.GATInvocationException)24 Job (org.gridlab.gat.resources.Job)24 ResourceBroker (org.gridlab.gat.resources.ResourceBroker)24 GATObjectCreationException (org.gridlab.gat.GATObjectCreationException)17 URISyntaxException (java.net.URISyntaxException)16 IOException (java.io.IOException)11 BufferedReader (java.io.BufferedReader)8 Preferences (org.gridlab.gat.Preferences)8 File (org.gridlab.gat.io.File)8 File (java.io.File)6 WrapperJobDescription (org.gridlab.gat.resources.WrapperJobDescription)5 FileReader (java.io.FileReader)4 InputStreamReader (java.io.InputStreamReader)4 AbstractJobDescription (org.gridlab.gat.resources.AbstractJobDescription)4 InputStream (java.io.InputStream)3 HashMap (java.util.HashMap)3 GATContext (org.gridlab.gat.GATContext)3