Search in sources :

Example 16 with Preferences

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

the class FileOutputStreamAdaptorTest 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 17 with Preferences

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

the class RandomAccessFileAdaptorTest method test.

public AdaptorTestResult test(String adaptor, String host) {
    AdaptorTestResult adaptorTestResult = new AdaptorTestResult(adaptor, host);
    GATContext gatContext = new GATContext();
    Preferences preferences = new Preferences();
    preferences.put("randomaccessfile.adaptor.name", adaptor);
    RandomAccessFile randomAccessFile = null;
    try {
        randomAccessFile = GAT.createRandomAccessFile(gatContext, preferences, "any://" + host + "/JavaGAT-random-accessfile", "rw");
    } catch (GATObjectCreationException e) {
        e.printStackTrace();
        GAT.end();
        System.exit(1);
    }
    adaptorTestResult.put("length             ", lengthTest(gatContext, preferences, randomAccessFile, 0));
    adaptorTestResult.put("write 'lorem ipsum'", writeTest(gatContext, preferences, randomAccessFile, "lorem ipsum"));
    adaptorTestResult.put("length after write", lengthTest(gatContext, preferences, randomAccessFile, 13));
    adaptorTestResult.put("seek              ", seekTest(gatContext, preferences, randomAccessFile, 0));
    adaptorTestResult.put("read              ", readTest(gatContext, preferences, randomAccessFile, "lorem ipsum"));
    adaptorTestResult.put("write 'lorem ipsum' 2", writeTest(gatContext, preferences, randomAccessFile, "lorem ipsum"));
    adaptorTestResult.put("length after write 2", lengthTest(gatContext, preferences, randomAccessFile, 26));
    adaptorTestResult.put("seek 2              ", seekTest(gatContext, preferences, randomAccessFile, 0));
    adaptorTestResult.put("read 2              ", readTest(gatContext, preferences, randomAccessFile, "lorem ipsum"));
    adaptorTestResult.put("read 3              ", readTest(gatContext, preferences, randomAccessFile, "lorem ipsum"));
    return adaptorTestResult;
}
Also used : GATContext(org.gridlab.gat.GATContext) RandomAccessFile(org.gridlab.gat.io.RandomAccessFile) GATObjectCreationException(org.gridlab.gat.GATObjectCreationException) Preferences(org.gridlab.gat.Preferences)

Example 18 with Preferences

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

the class SubmitRemoteJob method main.

public static void main(String[] args) throws Exception {
    SoftwareDescription sd = new SoftwareDescription();
    sd.setExecutable("/bin/hostname");
    File stdout = GAT.createFile("hostname.txt");
    sd.setStdout(stdout);
    JobDescription jd = new JobDescription(sd);
    Preferences prefs = new Preferences();
    /*
        prefs.put("VirtualOrganisation", "pvier");
        prefs.put("vomsServerURL", "voms.grid.sara.nl");
        prefs.put("vomsServerPort", "30000");
        prefs.put("vomsHostDN", "/O=dutchgrid/O=hosts/OU=sara.nl/CN=voms.grid.sara.nl");
        */
    CertificateSecurityContext ctxt = new CertificateSecurityContext(new URI(System.getProperty("user.home") + "/.globus/userkey.pem"), new URI(System.getProperty("user.home") + "/.globus/usercert.pem"), getPassphrase());
    GATContext context = new GATContext();
    context.addPreferences(prefs);
    context.addSecurityContext(ctxt);
    ResourceBroker broker = GAT.createResourceBroker(context, new URI(args[0]));
    Job job = broker.submitJob(jd);
    while ((job.getState() != JobState.STOPPED) && (job.getState() != JobState.SUBMISSION_ERROR)) {
        System.out.println("State: " + job.getState());
        Thread.sleep(1000);
    }
}
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) Job(org.gridlab.gat.resources.Job) File(org.gridlab.gat.io.File) URI(org.gridlab.gat.URI) SoftwareDescription(org.gridlab.gat.resources.SoftwareDescription)

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