Client<->Server communication

classic Classic list List threaded Threaded
2 messages Options
abondar abondar
Reply | Threaded
Open this post in threaded view

Client<->Server communication

There is already running Ignite cluster on remote hosts. default-config.xml contains:
- peerClassLoadingEnabled=true
- TcpDiscoveryVmIpFinder.addresses contains list of all host IPs

I am going to create the tool which performs tasks on remote hosts.
Is the code below right way to perform such communication:

Ignite ignite = Ignition.start();
IgniteCompute compute = ignite.compute(ignite.cluster().forRemotes());

 () -> {
   System.out.println("info request from client");
   final String currentDirOnRemoteHost = new File("./").getAbsolutePath();
   Ignite ignite1 = Ignition.ignite();
      () -> {
         //sending a response to client
         System.out.println("info response: currentDirOnRemoteHost=" + currentDirOnRemoteHost);
Denis Magda Denis Magda
Reply | Threaded
Open this post in threaded view

Re: Client<->Server communication


There is no need to send a reply to the client in a way you do.

There are versions of Ignite Compute's broadcast and other methods that return computation result to the caller.

In your particular case you can send the broadcast and process the response this way

        Collection<String> result = compute.broadcast(new IgniteCallable<String>() {
            Ignite ignite;

            @Override public String call() throws Exception {
                return new File("./").getAbsolutePath();

        for (String res : result)
            //process result

Please refer to additional Ignite Compute examples [1] that showcase how this API can be used in an optimal way.