Search in sources :

Example 36 with URI

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

the class AdvertServiceAdaptorTest method exportTest.

private AdaptorTestResultEntry exportTest(AdvertService advert, String exportLocation) {
    long start = System.currentTimeMillis();
    try {
        advert.exportDataBase(new URI(exportLocation));
    } catch (GATInvocationException e) {
        return new AdaptorTestResultEntry(false, 0, e);
    } catch (URISyntaxException e) {
        return new AdaptorTestResultEntry(false, 0, e);
    }
    long stop = System.currentTimeMillis();
    return new AdaptorTestResultEntry(true, (stop - start), null);
}
Also used : GATInvocationException(org.gridlab.gat.GATInvocationException) URISyntaxException(java.net.URISyntaxException) URI(org.gridlab.gat.URI)

Example 37 with URI

use of org.gridlab.gat.URI 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 38 with URI

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

the class ResourceBrokerAdaptorTest method test.

public AdaptorTestResult test(String adaptor, String host) {
    try {
        URI temp = new URI(host);
        if (temp.getScheme() == null && !host.equals("")) {
            host = "any://" + host;
        }
    } catch (URISyntaxException e) {
    // ignored
    }
    AdaptorTestResult adaptorTestResult = new AdaptorTestResult(adaptor, host);
    GATContext gatContext = new GATContext();
    // CertificateSecurityContext ctxt = new CertificateSecurityContext(null, null, "username", "passphrase");
    // gatContext.addSecurityContext(ctxt);
    // Add security contexts to gatContext here.
    Preferences preferences = new Preferences();
    preferences.put("resourcebroker.adaptor.name", adaptor);
    // preferences.put("file.adaptor.name", "commandlinessh,sshtrilead,local");
    jobFinished = false;
    adaptorTestResult.put("submit job easy  ", submitJobEasy(gatContext, preferences, host));
    jobFinished = false;
    adaptorTestResult.put("submit job parallel", submitJobParallel(gatContext, preferences, host));
    jobFinished = false;
    adaptorTestResult.put("submit job stdout", submitJobStdout(gatContext, preferences, host));
    jobFinished = false;
    adaptorTestResult.put("submit job stderr", submitJobStderr(gatContext, preferences, host));
    jobFinished = false;
    adaptorTestResult.put("submit job prestage", submitJobPreStage(gatContext, preferences, host));
    jobFinished = false;
    adaptorTestResult.put("submit job poststage", submitJobPostStage(gatContext, preferences, host));
    jobFinished = false;
    adaptorTestResult.put("submit job environment", submitJobEnvironment(gatContext, preferences, host));
    jobFinished = false;
    adaptorTestResult.put("job state consistency", submitJobStateConsistency(gatContext, preferences, host));
    jobFinished = false;
    adaptorTestResult.put("job get info        ", submitJobGetInfo(gatContext, preferences, host));
    jobFinished = false;
    return adaptorTestResult;
}
Also used : GATContext(org.gridlab.gat.GATContext) URISyntaxException(java.net.URISyntaxException) Preferences(org.gridlab.gat.Preferences) URI(org.gridlab.gat.URI)

Example 39 with URI

use of org.gridlab.gat.URI 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 40 with URI

use of org.gridlab.gat.URI 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

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