Search in sources :

Example 6 with Preferences

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

use of org.gridlab.gat.Preferences 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 8 with Preferences

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

Example 9 with Preferences

use of org.gridlab.gat.Preferences 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 10 with Preferences

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

Preferences (org.gridlab.gat.Preferences)18 GATContext (org.gridlab.gat.GATContext)11 URI (org.gridlab.gat.URI)11 GATObjectCreationException (org.gridlab.gat.GATObjectCreationException)9 JobDescription (org.gridlab.gat.resources.JobDescription)8 ResourceBroker (org.gridlab.gat.resources.ResourceBroker)8 SoftwareDescription (org.gridlab.gat.resources.SoftwareDescription)8 Job (org.gridlab.gat.resources.Job)6 URISyntaxException (java.net.URISyntaxException)5 GATInvocationException (org.gridlab.gat.GATInvocationException)4 AdvertService (org.gridlab.gat.advert.AdvertService)3 File (org.gridlab.gat.io.File)3 PasswordSecurityContext (org.gridlab.gat.security.PasswordSecurityContext)3 MetaData (org.gridlab.gat.advert.MetaData)2 CertificateSecurityContext (org.gridlab.gat.security.CertificateSecurityContext)2 FileInputStream (org.gridlab.gat.io.FileInputStream)1 FileOutputStream (org.gridlab.gat.io.FileOutputStream)1 LogicalFile (org.gridlab.gat.io.LogicalFile)1 RandomAccessFile (org.gridlab.gat.io.RandomAccessFile)1 HardwareResourceDescription (org.gridlab.gat.resources.HardwareResourceDescription)1