Search in sources :

Example 21 with GATObjectCreationException

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

the class LogicalFileAdaptorTest method test.

public AdaptorTestResult test(String adaptor, String[] hosts) throws URISyntaxException {
    if (hosts.length != 4) {
        System.out.println("please provide 4 hosts (comma separated, no spaces)");
        System.exit(1);
    }
    AdaptorTestResult adaptorTestResult = new AdaptorTestResult(adaptor, hosts[0]);
    GATContext gatContext = new GATContext();
    Preferences preferences = new Preferences();
    preferences.put("logicalfile.adaptor.name", adaptor);
    LogicalFile logicalFile = null;
    try {
        logicalFile = GAT.createLogicalFile(gatContext, preferences, "test-logical-file", LogicalFile.CREATE);
    } catch (GATObjectCreationException e) {
        e.printStackTrace();
        GAT.end();
        System.exit(1);
    }
    adaptorTestResult.put("replicate [0]", replicateTest(gatContext, preferences, logicalFile, new URI("any://" + hosts[0] + "/JavaGAT-test-logical-file"), false));
    adaptorTestResult.put("add       [0]", addTest(gatContext, preferences, logicalFile, new URI("any://" + hosts[0] + "/JavaGAT-test-logical-file"), true));
    adaptorTestResult.put("add false [1]", addTest(gatContext, preferences, logicalFile, new URI("any://" + hosts[1] + "/JavaGAT-test-logical-file"), false));
    adaptorTestResult.put("replicate [1]", replicateTest(gatContext, preferences, logicalFile, new URI("any://" + hosts[1] + "/JavaGAT-test-logical-file"), true));
    adaptorTestResult.put("remove    [1]", removeTest(gatContext, preferences, logicalFile, new URI("any://" + hosts[1] + "/JavaGAT-test-logical-file"), true));
    adaptorTestResult.put("add true  [1]", addTest(gatContext, preferences, logicalFile, new URI("any://" + hosts[1] + "/JavaGAT-test-logical-file"), true));
    adaptorTestResult.put("replicate2[1]", replicateTest(gatContext, preferences, logicalFile, new URI("any://" + hosts[1] + "/JavaGAT-test-logical-file"), false));
    adaptorTestResult.put("replicate [2]", replicateTest(gatContext, preferences, logicalFile, new URI("any://" + hosts[2] + "/JavaGAT-test-logical-file"), true));
    adaptorTestResult.put("closest   [3]", closestTest(gatContext, preferences, logicalFile, new URI("any://" + hosts[3] + "/JavaGAT-test-logical-file"), true));
    return adaptorTestResult;
}
Also used : GATContext(org.gridlab.gat.GATContext) GATObjectCreationException(org.gridlab.gat.GATObjectCreationException) LogicalFile(org.gridlab.gat.io.LogicalFile) Preferences(org.gridlab.gat.Preferences) URI(org.gridlab.gat.URI)

Example 22 with GATObjectCreationException

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

the class ResourceBrokerAdaptorTest method submitJobStateConsistency.

private AdaptorTestResultEntry submitJobStateConsistency(GATContext gatContext, Preferences preferences, String host) {
    SoftwareDescription sd = new SoftwareDescription();
    sd.setExecutable("/bin/sleep");
    sd.setArguments("2");
    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);
    }
    JobStateMetricListener listener = new JobStateMetricListener(this);
    long start = System.currentTimeMillis();
    try {
        broker.submitJob(jd, listener, "job.status");
    } catch (GATInvocationException e) {
        return new AdaptorTestResultEntry(false, 0L, e);
    }
    waitForJob();
    long stop = System.currentTimeMillis();
    return new AdaptorTestResultEntry(listener.getException() == null, (stop - start), listener.getException());
}
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 23 with GATObjectCreationException

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

the class ResourceBrokerAdaptorTest method submitJobEnvironment.

private AdaptorTestResultEntry submitJobEnvironment(GATContext gatContext, Preferences preferences, String host) {
    SoftwareDescription sd = new SoftwareDescription();
    Map<String, Object> env = new HashMap<String, Object>();
    env.put("JAVAGAT_TEST_KEY", "javagat-test-value");
    sd.setEnvironment(env);
    sd.setExecutable("/usr/bin/env");
    try {
        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();
    boolean success = false;
    try {
        BufferedReader reader = new BufferedReader(new InputStreamReader(new java.io.FileInputStream("stdout")));
        while (true) {
            String result = reader.readLine();
            if (result == null) {
                break;
            }
            if (result.contains("JAVAGAT_TEST_KEY") && result.contains("javagat-test-value")) {
                success = true;
            }
        }
        reader.close();
    } catch (Exception e) {
        return new AdaptorTestResultEntry(false, 0L, e);
    }
    return new AdaptorTestResultEntry(success, (stop - start), null);
}
Also used : GATObjectCreationException(org.gridlab.gat.GATObjectCreationException) InputStreamReader(java.io.InputStreamReader) 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) 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 24 with GATObjectCreationException

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

the class ResourceBrokerAdaptorTest method submitJobGetInfo.

private AdaptorTestResultEntry submitJobGetInfo(GATContext gatContext, Preferences preferences, String host) {
    SoftwareDescription sd = new SoftwareDescription();
    sd.setExecutable("/bin/sleep");
    sd.setArguments("2");
    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);
    }
    Job job = null;
    Exception exception = null;
    long start = System.currentTimeMillis();
    try {
        job = broker.submitJob(jd);
    } catch (GATInvocationException e) {
        return new AdaptorTestResultEntry(false, 0L, e);
    }
    while (job.getState() != Job.JobState.STOPPED) {
        Map<String, Object> info = null;
        try {
            info = job.getInfo();
        } catch (GATInvocationException e) {
            exception = e;
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e1) {
            // ignored
            }
            continue;
        }
        if (info == null) {
            exception = new Exception("getInfo returns null");
        } else {
            if (!info.containsKey("state")) {
                exception = new Exception("getInfo doesn't contain a key 'state'");
            }
            if (!info.containsKey("hostname")) {
                exception = new Exception("getInfo doesn't contain a key 'hostname'");
            } else {
                if (info.get("state").equals(Job.JobState.RUNNING) && info.get("hostname") == null) {
                    exception = new Exception("inconsistent getInfo: state=RUNNING, hostname=null");
                }
            }
            if (!info.containsKey("submissiontime")) {
                exception = new Exception("getInfo doesn't contain a key 'submissiontime'");
            }
            if (!info.containsKey("starttime")) {
                exception = new Exception("getInfo doesn't contain a key 'starttime'");
            }
            if (!info.containsKey("stoptime")) {
                exception = new Exception("getInfo doesn't contain a key 'stoptime'");
            }
            if (!info.containsKey("poststage.exception")) {
                exception = new Exception("getInfo doesn't contain a key 'poststage.exception'");
            }
        }
        try {
            Thread.sleep(500);
        } catch (InterruptedException e) {
            exception = e;
        }
    }
    long stop = System.currentTimeMillis();
    return new AdaptorTestResultEntry(exception == null, (stop - start), exception);
}
Also used : GATObjectCreationException(org.gridlab.gat.GATObjectCreationException) 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) Job(org.gridlab.gat.resources.Job)

Example 25 with GATObjectCreationException

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

Aggregations

GATObjectCreationException (org.gridlab.gat.GATObjectCreationException)47 GATInvocationException (org.gridlab.gat.GATInvocationException)39 URI (org.gridlab.gat.URI)18 JobDescription (org.gridlab.gat.resources.JobDescription)18 URISyntaxException (java.net.URISyntaxException)17 SoftwareDescription (org.gridlab.gat.resources.SoftwareDescription)17 ResourceBroker (org.gridlab.gat.resources.ResourceBroker)16 FileInterface (org.gridlab.gat.io.FileInterface)14 Job (org.gridlab.gat.resources.Job)14 IOException (java.io.IOException)11 Preferences (org.gridlab.gat.Preferences)9 BufferedReader (java.io.BufferedReader)5 File (java.io.File)5 InputStreamReader (java.io.InputStreamReader)5 FileOutputStream (java.io.FileOutputStream)4 PrintWriter (java.io.PrintWriter)4 StringWriter (java.io.StringWriter)4 AdaptorNotApplicableException (org.gridlab.gat.AdaptorNotApplicableException)4 GATContext (org.gridlab.gat.GATContext)4 InputStream (java.io.InputStream)3