Re: How to identify stale ignite client in case of data grid restart and auto reconnect to cluster

2018-02-06 Thread dkarachentsev
Hi,

This exception says that client node was stopped, but by default it should
wait for servers. In other words, wait for reconnect, in this case it throws
IgniteClientDisconnectedException that contains future on which you may wait
for reconnect event.
You may locally listen for EventType.EVT_CLIENT_NODE_DISCONNECTED to be
notified that client node was disconnected [1].

But STOPPED state means that node was actually stopped. To get node status
you may use Ignition.state() method and/or register your LifecycleBean
implementation (IgniteConfiguration.setLifecycleBeans()).

[1] https://apacheignite.readme.io/docs/events#section-local-events

Thanks!



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/


How to identify stale ignite client in case of data grid restart and auto reconnect to cluster

2018-02-05 Thread aMark
Hi,

We are using Ignite cache version 2.1 . We are using it as persistent store
in Partitioned Mode having 6 data node running.  Atomicity mode is 
ATOMIC, and Rebalance mode is ASYNC while CacheWriteSynchronizationMode is
FULL_SYNC. 

We have ignite client which does read/write to ignite data grid.

In certain scenario, we might have to restart data grid, in that case client
connection to datagrid becomes stale.

Is there a way at client (apart from IllegalStateException ) to know that
its no longer part of cluster and has to restablish connection to data grid
? 

Following is the code which is being used to connect to data grid: 

  Ignition.setClientMode(true);  
  Ignite ignite = Ignition.start("etc/config/" + fileName);
  ignite.active(true);

We use *ignite* instance above to read and write to grid. But when client
becomes stale (in case of datagrid restart)  we get following exception at
client end : 
Caused by: java.lang.IllegalStateException: Grid is in invalid state to
perform this operation. It either not started yet or has already being or
have stopped [igniteInstanceName=8cd92f6f-8b7a-45ae-8c2f-9386
83e67a40, state=STOPPED]
at
org.apache.ignite.internal.GridKernalGatewayImpl.illegalState(GridKernalGatewayImpl.java:201)
at
org.apache.ignite.internal.GridKernalGatewayImpl.readLock(GridKernalGatewayImpl.java:95)
at
org.apache.ignite.internal.IgniteKernal.guard(IgniteKernal.java:3693)
at
org.apache.ignite.internal.IgniteKernal.cache(IgniteKernal.java:2729)
at com..datagrid.DataGridClient.cache(DataGridClient.java:277)
at
com..datagrid.DataGridClient.readFromGrid(DataGridClient.java:160)


Please note that we are using Ignite 2.1 version and will soon upgrade to
Ignite 2.3.


Thanks,



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/