Search in sources :

Example 1 with AdvertService

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

the class AdvertServiceAdaptorTest method test.

public AdaptorTestResult test(String adaptor, String host) {
    AdaptorTestResult adaptorTestResult = new AdaptorTestResult(adaptor, host);
    Preferences preferences = new Preferences();
    preferences.put("advertservice.adaptor.name", adaptor);
    AdvertService advertService = null;
    try {
        advertService = GAT.createAdvertService(preferences);
    } catch (GATObjectCreationException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    MetaData meta = new MetaData();
    meta.put("version", "5.0");
    meta.put("price", "2000");
    adaptorTestResult.put("put object '1' at path 'a'", addTest(advertService, "1", meta, "a"));
    adaptorTestResult.put("getMetaData 'a'             ", getMetaDataTest(advertService, "a", meta));
    meta = new MetaData();
    meta.put("version", "5.0");
    meta.put("price", "50");
    adaptorTestResult.put("put object '2' at path 'b'", addTest(advertService, "2", meta, "b"));
    adaptorTestResult.put("test path 'a' (CORRECT)   ", getAdvertisableTest(advertService, "a", "1", true));
    adaptorTestResult.put("test path 'a' (INCORRECT) ", getAdvertisableTest(advertService, "a", "2", false));
    adaptorTestResult.put("test path 'b' (CORRECT)   ", getAdvertisableTest(advertService, "b", "2", true));
    adaptorTestResult.put("export                    ", exportTest(advertService, "any://" + host + "/exported-advert-database"));
    meta = new MetaData();
    meta.put("version", "9.1");
    meta.put("price", "50");
    adaptorTestResult.put("put object '3' at path 'c'", addTest(advertService, "3", meta, "c"));
    adaptorTestResult.put("test path 'c' (CORRECT)   ", getAdvertisableTest(advertService, "c", "3", true));
    adaptorTestResult.put("import                    ", importTest(advertService, "any://" + host + "/exported-advert-database"));
    adaptorTestResult.put("test path 'c' (INCORRECT) ", getAdvertisableTest(advertService, "c", null, true));
    meta = new MetaData();
    meta.put("price", "50");
    adaptorTestResult.put("find price=50             ", findTest(advertService, meta, new String[] { "/b" }, true));
    meta = new MetaData();
    meta.put("version", "5.0");
    adaptorTestResult.put("find version=5.0          ", findTest(advertService, meta, new String[] { "/b", "/a" }, true));
    adaptorTestResult.put("delete 'b'                ", deleteTest(advertService, "b"));
    adaptorTestResult.put("setPWD 'test'             ", setPWDTest(advertService, "/test"));
    adaptorTestResult.put("getPWD 'test'             ", getPWDTest(advertService, "/test"));
    return adaptorTestResult;
}
Also used : GATObjectCreationException(org.gridlab.gat.GATObjectCreationException) MetaData(org.gridlab.gat.advert.MetaData) AdvertService(org.gridlab.gat.advert.AdvertService) Preferences(org.gridlab.gat.Preferences)

Example 2 with AdvertService

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

the class EndpointExample method remote.

public void remote() throws GATObjectCreationException, GATInvocationException, URISyntaxException, IOException, InterruptedException {
    System.err.println("Starting the 'remote' instance.");
    AdvertService advert = GAT.createAdvertService();
    advert.importDataBase(new URI("any://localhost/example-advert.db"));
    System.err.println("Advert database imported from 'any://localhost/example-advert.db'.");
    Endpoint endpoint = (Endpoint) advert.getAdvertisable("examples/endpoint");
    System.err.println("Endpoint retrieved from the advert service.");
    Pipe p = endpoint.connect();
    System.err.println("Connection established. Writing 'hello world'.");
    BufferedWriter out = new BufferedWriter(new OutputStreamWriter(p.getOutputStream()));
    out.write("hello world\n");
    out.flush();
    Thread.sleep(10 * 1000);
    p.close();
}
Also used : Endpoint(org.gridlab.gat.io.Endpoint) AdvertService(org.gridlab.gat.advert.AdvertService) OutputStreamWriter(java.io.OutputStreamWriter) Pipe(org.gridlab.gat.io.Pipe) URI(org.gridlab.gat.URI) BufferedWriter(java.io.BufferedWriter)

Example 3 with AdvertService

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

the class EndpointExample method local.

public void local(String remoteHost) throws GATObjectCreationException, GATInvocationException, URISyntaxException, IOException {
    System.err.println("Starting the 'local' instance.");
    Endpoint endpoint = GAT.createEndpoint();
    AdvertService advert = GAT.createAdvertService();
    advert.add(endpoint, null, "examples/endpoint");
    advert.exportDataBase(new URI("any://" + remoteHost + "/example-advert.db"));
    System.err.println("Advert database exported to: '" + "any://" + remoteHost + "/example-advert.db" + "'.");
    System.err.println("Setup ready. Listening for incoming connection from 'remote' instance");
    Pipe p = endpoint.listen();
    System.err.println("Connection established. Trying to read a line.");
    BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream()));
    System.out.println("read: " + in.readLine());
    p.close();
}
Also used : Endpoint(org.gridlab.gat.io.Endpoint) InputStreamReader(java.io.InputStreamReader) BufferedReader(java.io.BufferedReader) AdvertService(org.gridlab.gat.advert.AdvertService) Pipe(org.gridlab.gat.io.Pipe) URI(org.gridlab.gat.URI)

Example 4 with AdvertService

use of org.gridlab.gat.advert.AdvertService 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 5 with AdvertService

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

the class ConnectToAdvertJob method main.

public static void main(String[] args) throws Exception {
    GATContext c = new GATContext();
    Preferences prefs = new Preferences();
    prefs.put("File.adaptor.name", "local");
    AdvertService a = GAT.createAdvertService(c, prefs);
    a.importDataBase(new URI("file:///mydb"));
    c = new GATContext();
    prefs = new Preferences();
    // prefs.put("Resourcebroker.adaptor.name", "sshsge");
    prefs.put("File.adaptor.name", "local, commandlinessh");
    c.addPreferences(prefs);
    Job other = (Job) a.getAdvertisable(c, "/rob/testJob");
    System.err.println("got job back: " + other);
    while ((other.getState() != Job.JobState.STOPPED) && (other.getState() != Job.JobState.SUBMISSION_ERROR)) {
        System.err.println("job state = " + other.getInfo());
        Thread.sleep(1000);
    }
    System.err.println("job DONE, state = " + other.getInfo());
    GAT.end();
}
Also used : GATContext(org.gridlab.gat.GATContext) AdvertService(org.gridlab.gat.advert.AdvertService) Preferences(org.gridlab.gat.Preferences) Job(org.gridlab.gat.resources.Job) URI(org.gridlab.gat.URI)

Aggregations

AdvertService (org.gridlab.gat.advert.AdvertService)5 URI (org.gridlab.gat.URI)4 Preferences (org.gridlab.gat.Preferences)3 GATContext (org.gridlab.gat.GATContext)2 MetaData (org.gridlab.gat.advert.MetaData)2 Endpoint (org.gridlab.gat.io.Endpoint)2 Pipe (org.gridlab.gat.io.Pipe)2 Job (org.gridlab.gat.resources.Job)2 BufferedReader (java.io.BufferedReader)1 BufferedWriter (java.io.BufferedWriter)1 InputStreamReader (java.io.InputStreamReader)1 OutputStreamWriter (java.io.OutputStreamWriter)1 GATObjectCreationException (org.gridlab.gat.GATObjectCreationException)1 File (org.gridlab.gat.io.File)1 HardwareResourceDescription (org.gridlab.gat.resources.HardwareResourceDescription)1 JobDescription (org.gridlab.gat.resources.JobDescription)1 ResourceBroker (org.gridlab.gat.resources.ResourceBroker)1 ResourceDescription (org.gridlab.gat.resources.ResourceDescription)1 SoftwareDescription (org.gridlab.gat.resources.SoftwareDescription)1