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;
}
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();
}
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();
}
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();
}
}
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();
}
Aggregations