Search in sources :

Example 21 with JobDescription

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

the class SshLSFJob method kill.

protected void kill(String jobID) {
    try {
        // Create qdel job
        SoftwareDescription sd = new SoftwareDescription();
        sd.setExecutable("bkill");
        sd.setArguments(jobID);
        sd.addAttribute(SoftwareDescription.SANDBOX_USEROOT, "true");
        sd.addAttribute(SoftwareDescription.SANDBOX_ROOT, sandbox.getSandboxPath());
        sd.addAttribute(SoftwareDescription.STOP_ON_EXIT, "false");
        JobDescription jd = new JobDescription(sd);
        Job job = jobHelper.submitJob(jd, this, "job.status");
        synchronized (job) {
            while (job.getState() != Job.JobState.STOPPED && job.getState() != Job.JobState.SUBMISSION_ERROR) {
                try {
                    job.wait();
                } catch (InterruptedException e) {
                // ignore
                }
            }
        }
        if (job.getState() != Job.JobState.STOPPED || job.getExitStatus() != 0) {
            throw new GATInvocationException("Could not submit scancel job");
        }
    } catch (Throwable e) {
        logger.info("Failed to stop sshSlurm job: " + jobID, e);
    }
}
Also used : JobDescription(org.gridlab.gat.resources.JobDescription) GATInvocationException(org.gridlab.gat.GATInvocationException) SshLSFJob(org.gridlab.gat.resources.cpi.sshlsf.SshLSFJob) Job(org.gridlab.gat.resources.Job) SoftwareDescription(org.gridlab.gat.resources.SoftwareDescription)

Example 22 with JobDescription

use of org.gridlab.gat.resources.JobDescription 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)

Example 23 with JobDescription

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

the class FileInputStreamAdaptorTest method run.

private void run(String host, String script) {
    Preferences preferences = new Preferences();
    preferences.put("resourcebroker.adaptor.name", "commandlinessh,sshtrilead,local");
    preferences.put("file.adaptor.name", "commandlinessh,sshtrilead,local");
    SoftwareDescription sd = new SoftwareDescription();
    sd.setExecutable("/bin/bash");
    sd.setArguments(script);
    try {
        sd.addPreStagedFile(GAT.createFile(preferences, "tests" + java.io.File.separator + "src" + java.io.File.separator + "benchmarks" + java.io.File.separator + script));
    } catch (GATObjectCreationException e) {
        e.printStackTrace();
        System.exit(1);
    }
    ResourceBroker broker = null;
    try {
        broker = GAT.createResourceBroker(preferences, new URI("any://" + host));
    } catch (GATObjectCreationException e) {
        e.printStackTrace();
        System.exit(1);
    } catch (URISyntaxException e) {
        e.printStackTrace();
        System.exit(1);
    }
    Job job = null;
    try {
        job = broker.submitJob(new JobDescription(sd));
    } catch (GATInvocationException e) {
        e.printStackTrace();
        System.exit(1);
    }
    while (job.getState() != Job.JobState.STOPPED && job.getState() != Job.JobState.SUBMISSION_ERROR) {
        try {
            Thread.sleep(500);
        } catch (InterruptedException e) {
        // ignored
        }
    }
}
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) Job(org.gridlab.gat.resources.Job) URI(org.gridlab.gat.URI) SoftwareDescription(org.gridlab.gat.resources.SoftwareDescription)

Example 24 with JobDescription

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

the class ResourceBrokerAdaptorTest method submitJobEasy.

private AdaptorTestResultEntry submitJobEasy(GATContext gatContext, Preferences preferences, String host) {
    SoftwareDescription sd = new SoftwareDescription();
    sd.setExecutable("/bin/echo");
    sd.setArguments("test", "1", "2", "3");
    Map<String, Object> attributes = new HashMap<String, Object>();
    sd.setAttributes(attributes);
    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();
    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 : GATObjectCreationException(org.gridlab.gat.GATObjectCreationException) HashMap(java.util.HashMap) ResourceBroker(org.gridlab.gat.resources.ResourceBroker) URISyntaxException(java.net.URISyntaxException) URI(org.gridlab.gat.URI) SoftwareDescription(org.gridlab.gat.resources.SoftwareDescription) JobDescription(org.gridlab.gat.resources.JobDescription) GATInvocationException(org.gridlab.gat.GATInvocationException)

Example 25 with JobDescription

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

the class ResourceBrokerAdaptorTest method submitJobPreStage.

private AdaptorTestResultEntry submitJobPreStage(GATContext gatContext, Preferences preferences, String host) {
    SoftwareDescription sd = new SoftwareDescription();
    sd.setExecutable("/bin/ls");
    sd.setArguments("floep");
    java.io.File floep = new java.io.File("floep");
    if (!floep.exists()) {
        try {
            floep.createNewFile();
        } catch (IOException e) {
            return new AdaptorTestResultEntry(false, 0L, e);
        }
        floep.deleteOnExit();
    }
    java.io.File tmp = new java.io.File("tmp");
    if (!tmp.exists()) {
        tmp.mkdir();
        tmp.deleteOnExit();
    }
    try {
        sd.addPreStagedFile(GAT.createFile(gatContext, preferences, "floep"));
        sd.addPreStagedFile(GAT.createFile(gatContext, preferences, "tmp"));
        sd.setStdout(GAT.createFile(gatContext, preferences, "stdout"));
    } 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("stdout")));
        result = reader.readLine();
        reader.close();
    } catch (Exception e) {
        return new AdaptorTestResultEntry(false, 0L, e);
    }
    return new AdaptorTestResultEntry(result != null, (stop - start), null);
}
Also used : GATObjectCreationException(org.gridlab.gat.GATObjectCreationException) InputStreamReader(java.io.InputStreamReader) ResourceBroker(org.gridlab.gat.resources.ResourceBroker) IOException(java.io.IOException) 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)

Aggregations

JobDescription (org.gridlab.gat.resources.JobDescription)33 SoftwareDescription (org.gridlab.gat.resources.SoftwareDescription)31 URI (org.gridlab.gat.URI)28 ResourceBroker (org.gridlab.gat.resources.ResourceBroker)26 Job (org.gridlab.gat.resources.Job)25 GATInvocationException (org.gridlab.gat.GATInvocationException)24 GATObjectCreationException (org.gridlab.gat.GATObjectCreationException)18 URISyntaxException (java.net.URISyntaxException)17 IOException (java.io.IOException)10 Preferences (org.gridlab.gat.Preferences)8 File (org.gridlab.gat.io.File)8 BufferedReader (java.io.BufferedReader)6 WrapperJobDescription (org.gridlab.gat.resources.WrapperJobDescription)5 InputStreamReader (java.io.InputStreamReader)4 AbstractJobDescription (org.gridlab.gat.resources.AbstractJobDescription)4 File (java.io.File)3 InputStream (java.io.InputStream)3 HashMap (java.util.HashMap)3 GATContext (org.gridlab.gat.GATContext)3 Metric (org.gridlab.gat.monitoring.Metric)3