java - Hazelcast: distributed execution and local member info -


i'm looking way lookup local hazelcast member in task execution. version i'm working 2.5-snapshot. snippet tutorial doesn't seem working:

public class echo implements callable<string>, serializable {     public string call() {         return hazelcast.getcluster().getlocalmember().tostring() + ":" + input;     } } 

calling getcluster() deprecated triggers new member created , connected.

at moment managed via hazelcastinstance.getcluster().getlocalmember() not complicate callables kind of injection.

could please suggest proper way lookup local member?

the callable should implement hazelcastinstanceaware.

here example:

public class echoexample {      public static void main(string[] args) throws executionexception, interruptedexception {         config config = new config();         hazelcastinstance instance1 = hazelcast.newhazelcastinstance(config);         hazelcastinstance instance2 = hazelcast.newhazelcastinstance(config);         executorservice executorservice = instance1.getexecutorservice("exec1");         future<string> future = executorservice.submit(new echo());         system.out.println(future.get());      }      static class echo implements hazelcastinstanceaware, serializable, callable<string> {         transient hazelcastinstance localinstance;          public string call() throws exception {             return localinstance.tostring();         }          @override         public void sethazelcastinstance(hazelcastinstance hazelcastinstance) {             this.localinstance = hazelcastinstance;         }     }  } 

Comments

Popular posts from this blog

Delphi XE2 Indy10 udp client-server interchange using SendBuffer-ReceiveBuffer -

Qt ActiveX WMI QAxBase::dynamicCallHelper: ItemIndex(int): No such property in -

Enable autocomplete or intellisense in Atom editor for PHP -