Hi all,
While I'm using the Ignite Service Grid, I found a weird behavior in
which values of local variables are getting overridden.
I have two ignite nodes and I deployed the service in node singleton
approach. When the second node comes up and joins the cluster, it's local
variable values are getting overridden by the values in the first node.
*Sample Code*
*import org.apache.ignite.Ignite;import org.apache.ignite.Ignition;import
org.apache.ignite.services.Service;import
org.apache.ignite.services.ServiceContext;public class DummyService
implements Service { private static final long serialVersionUID = 1L;
private final String server_id = System.getProperty("SERVER_ID", "1");
// Local variable value differ from one node to another public
DummyService() { System.out.printf("S : %s, Dummy Service
instantiated%n", server_id); } @Override public void
cancel(ServiceContext context) { System.out.printf("S : %s,
Distributed Service : %s cancelled%n", server_id, context.name
<http://context.name>()); // server_id value overridden }
@Override public void execute(ServiceContext context) throws Exception
{ System.out.printf("S : %s, Distributed Service : %s executed%n",
server_id, context.name <http://context.name>()); // server_id value
overridden } @Override public void init(ServiceContext context)
throws Exception { System.out.printf("S : %s, Distributed Service :
%s inited%n", server_id, context.name <http://context.name>()); //
server_id value overridden } public static void main(String[] args)
{ String server_id = "200"; // Replace the server_id with
300 while starting the second node System.setProperty("SERVER_ID",
server_id); Ignite ignite =
Ignition.start("examples/config/example-ignite.xml"); DummyService
service = new DummyService();
ignite.services().deployNodeSingleton("DummyService", service);
System.out.printf("S : %s, Dummy service deployed successfully%n",
server_id); }}*
In the above code, *server_id *values gets overridden while starting second
node. I've tried it by enabling and disabling peer-to-peer class loading.
But, the behavior is still same.
How to preserve the value of local variables?
--Kamal