Search in sources :

Example 1 with Endpoint

use of org.gridlab.gat.io.Endpoint 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 2 with Endpoint

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

Aggregations

URI (org.gridlab.gat.URI)2 AdvertService (org.gridlab.gat.advert.AdvertService)2 Endpoint (org.gridlab.gat.io.Endpoint)2 Pipe (org.gridlab.gat.io.Pipe)2 BufferedReader (java.io.BufferedReader)1 BufferedWriter (java.io.BufferedWriter)1 InputStreamReader (java.io.InputStreamReader)1 OutputStreamWriter (java.io.OutputStreamWriter)1