[jira] [Commented] (IGNITE-2786) SpringCache doesn't survive client reconnect
[ https://issues.apache.org/jira/browse/IGNITE-2786?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16170957#comment-16170957 ] Valentin Kulichenko commented on IGNITE-2786: - [~bbarin] * https://apacheignite.readme.io/docs/events * https://apacheignite.readme.io/docs/clients-vs-servers#client-reconnection > SpringCache doesn't survive client reconnect > > > Key: IGNITE-2786 > URL: https://issues.apache.org/jira/browse/IGNITE-2786 > Project: Ignite > Issue Type: Improvement > Components: cache >Affects Versions: 1.5.0.final >Reporter: Valentin Kulichenko > > After a client disconnects and reconnects with new ID, Spring caching can't > be used, because existing cache instance are closed. -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Commented] (IGNITE-2786) SpringCache doesn't survive client reconnect
[ https://issues.apache.org/jira/browse/IGNITE-2786?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16170880#comment-16170880 ] Bruno Barin commented on IGNITE-2786: - CacheErrorHandler is the Spring's interface to handle cache errors. This could be instantiated and included in the ApplicationContext in SpringCacheManager class. If we only cleanup caches at SpringCacheManager class, the AbstractCacheInvoker will still hold a reference to cache map. Could you please point me to an example to listen to Ignite events? Cheers > SpringCache doesn't survive client reconnect > > > Key: IGNITE-2786 > URL: https://issues.apache.org/jira/browse/IGNITE-2786 > Project: Ignite > Issue Type: Improvement > Components: cache >Affects Versions: 1.5.0.final >Reporter: Valentin Kulichenko > > After a client disconnects and reconnects with new ID, Spring caching can't > be used, because existing cache instance are closed. -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Commented] (IGNITE-2786) SpringCache doesn't survive client reconnect
[ https://issues.apache.org/jira/browse/IGNITE-2786?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16170575#comment-16170575 ] Valentin Kulichenko commented on IGNITE-2786: - [~bbarin] Are you saying that Spring does it's own caching anyway? If so, then I believe {{caches}} map can be removed altogether. As for you solution: do I understand correctly that {{CacheErrorHandler}} has to be configured as a separate bean? If that's the case, I don't like it, as the discussed case has to be handled by {{SpringCacheManager}} automatically. I think it can be easily done in {{SpringCache}} class. > SpringCache doesn't survive client reconnect > > > Key: IGNITE-2786 > URL: https://issues.apache.org/jira/browse/IGNITE-2786 > Project: Ignite > Issue Type: Improvement > Components: cache >Affects Versions: 1.5.0.final >Reporter: Valentin Kulichenko > > After a client disconnects and reconnects with new ID, Spring caching can't > be used, because existing cache instance are closed. -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Commented] (IGNITE-2786) SpringCache doesn't survive client reconnect
[ https://issues.apache.org/jira/browse/IGNITE-2786?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16170507#comment-16170507 ] Bruno Barin commented on IGNITE-2786: - [~vkulichenko], if you really uses SpringCache with annotations, it will end up using AbstractCacheInvoker which holds references to the caches as well, as you can see in this stack trace on my application: java.lang.IllegalStateException: Cache has been closed or destroyed: XYZ …gnite.internal.processors.cache.GridCacheGateway.enter(GridCacheGateway.java:164) …ite.internal.processors.cache.IgniteCacheProxy.onEnter(IgniteCacheProxy.java:2727) ….ignite.internal.processors.cache.IgniteCacheProxy.get(IgniteCacheProxy.java:1189) org.apache.ignite.cache.spring.SpringCache.get(SpringCache.java:57) …framework.cache.interceptor.AbstractCacheInvoker.doGet(AbstractCacheInvoker.java:71) …work.cache.interceptor.CacheAspectSupport.findInCaches(CacheAspectSupport.java:537) …rk.cache.interceptor.CacheAspectSupport.findCachedItem(CacheAspectSupport.java:503) …framework.cache.interceptor.CacheAspectSupport.execute(CacheAspectSupport.java:389) …framework.cache.interceptor.CacheAspectSupport.execute(CacheAspectSupport.java:327) …ingframework.cache.interceptor.CacheInterceptor.invoke(CacheInterceptor.java:61) > SpringCache doesn't survive client reconnect > > > Key: IGNITE-2786 > URL: https://issues.apache.org/jira/browse/IGNITE-2786 > Project: Ignite > Issue Type: Improvement > Components: cache >Affects Versions: 1.5.0.final >Reporter: Valentin Kulichenko > > After a client disconnects and reconnects with new ID, Spring caching can't > be used, because existing cache instance are closed. -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Commented] (IGNITE-2786) SpringCache doesn't survive client reconnect
[ https://issues.apache.org/jira/browse/IGNITE-2786?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16170392#comment-16170392 ] Valentin Kulichenko commented on IGNITE-2786: - [~bbarin], node restart is not needed because Ignite client reconnects automatically. The only issue here is that {{IgniteCache}} instance acquired before the disconnection can't be used after the reconnect. So in my view the only thing required is to clean up {{SpringCacheManager#caches}} map if disconnect happens (Ignite provides special event for this, so it's easy to create a listener). > SpringCache doesn't survive client reconnect > > > Key: IGNITE-2786 > URL: https://issues.apache.org/jira/browse/IGNITE-2786 > Project: Ignite > Issue Type: Improvement > Components: cache >Affects Versions: 1.5.0.final >Reporter: Valentin Kulichenko > > After a client disconnects and reconnects with new ID, Spring caching can't > be used, because existing cache instance are closed. -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Commented] (IGNITE-2786) SpringCache doesn't survive client reconnect
[ https://issues.apache.org/jira/browse/IGNITE-2786?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16170087#comment-16170087 ] Bruno Barin commented on IGNITE-2786: - Hey, Wouldn't be enough to implement CacheErrorHandler with something like this: {code:java} public class IgniteCacheErrorHandler implements CacheErrorHandler { private final SpringCacheManager springCacheManager; public IgniteCacheErrorHandler(SpringCacheManager springCacheManager) { this.springCacheManager = springCacheManager; } @Override public void handleCacheGetError(RuntimeException e, Cache cache, Object o) { if (e instanceof IllegalStateException) { logger.error("Failed to retrieve value from Cache, node seems to be in an inconsistent state. Restarting node.", e); springCacheManager.restartNode(); } else { throw e; } } @Override public void handleCachePutError(RuntimeException e, Cache cache, Object o, Object o1) { throw e; } @Override public void handleCacheEvictError(RuntimeException e, Cache cache, Object o) { throw e; } @Override public void handleCacheClearError(RuntimeException e, Cache cache) { throw e; } {code} And on SpringCacheManager add a restart method: {code:java} public void restartNode() { caches.entrySet().forEach(entry -> { caches.get(entry.getKey()).clear(); caches.remove(entry.getKey()); ignite.destroyCache(entry.getKey()); }); try { restart(); } catch (IgniteCheckedException e) { logger.error("Failed to restart ignite node",e); } } private void restart() throws IgniteCheckedException { stop(); start(); } private void start() throws IgniteCheckedException { if (cfgPath != null && cfg != null) { throw new IllegalArgumentException("Both 'configurationPath' and 'configuration' are " + "provided. Set only one of these properties if you need to start a Ignite node inside of " + "SpringCacheManager. If you already have a node running, omit both of them and set" + "'igniteInstanceName' property."); } if (cfgPath != null) ignite = IgniteSpring.start(cfgPath, springCtx); else if (cfg != null) ignite = IgniteSpring.start(cfg, springCtx); else ignite = Ignition.ignite(igniteInstanceName); } private void stop() { ignite.close(); } {code} > SpringCache doesn't survive client reconnect > > > Key: IGNITE-2786 > URL: https://issues.apache.org/jira/browse/IGNITE-2786 > Project: Ignite > Issue Type: Improvement > Components: cache >Affects Versions: 1.5.0.final >Reporter: Valentin Kulichenko > > After a client disconnects and reconnects with new ID, Spring caching can't > be used, because existing cache instance are closed. -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Commented] (IGNITE-2786) SpringCache doesn't survive client reconnect
[ https://issues.apache.org/jira/browse/IGNITE-2786?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16075449#comment-16075449 ] Valentin Kulichenko commented on IGNITE-2786: - [~ryagnik], do you have plans to finish this ticket? > SpringCache doesn't survive client reconnect > > > Key: IGNITE-2786 > URL: https://issues.apache.org/jira/browse/IGNITE-2786 > Project: Ignite > Issue Type: Improvement > Components: cache >Affects Versions: 1.5.0.final >Reporter: Valentin Kulichenko >Assignee: Rishi > Fix For: 2.1 > > > After a client disconnects and reconnects with new ID, Spring caching can't > be used, because existing cache instance are closed. -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Commented] (IGNITE-2786) SpringCache doesn't survive client reconnect
[ https://issues.apache.org/jira/browse/IGNITE-2786?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15952020#comment-15952020 ] Valentin Kulichenko commented on IGNITE-2786: - [~ryagnik], can you please explain the fix? Why do you destroy the caches? In my understanding we just need to clear {{caches}} map in {{SpringCacheManager}} on {{DISCONNECTED}} event. This way if it reconnects, it will create new {{SpringCache}} when needed. Agree? Also you should add tests to reproduce the issue and then make sure that it is fixed by your change. BTW, when you create a PR, please move the ticket to Patch Available. Please refer to the development process description on our wiki for more details. > SpringCache doesn't survive client reconnect > > > Key: IGNITE-2786 > URL: https://issues.apache.org/jira/browse/IGNITE-2786 > Project: Ignite > Issue Type: Improvement > Components: cache >Affects Versions: 1.5.0.final >Reporter: Valentin Kulichenko >Assignee: Rishi > Fix For: 2.0 > > > After a client disconnects and reconnects with new ID, Spring caching can't > be used, because existing cache instance are closed. -- This message was sent by Atlassian JIRA (v6.3.15#6346)
[jira] [Commented] (IGNITE-2786) SpringCache doesn't survive client reconnect
[ https://issues.apache.org/jira/browse/IGNITE-2786?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15946460#comment-15946460 ] ASF GitHub Bot commented on IGNITE-2786: GitHub user ryagnik opened a pull request: https://github.com/apache/ignite/pull/1688 IGNITE-2786 : SpringCache doesn't survive client reconnect The fix can be applied as follows with SpringCacheManager - 1) Design was to listen for ignite re connect event 2) And clear the cache on reconnect 3) Added logger to log reconnect information See the following code below and let us know if this is helpful - In afterPropertiesSet - //Handles the reconnect event, on server crashes OR network failure, client connects to server and // destroy the cache IgnitePredicate lsnr = iEvt -> { U.warn(log,"Received discovery event [iEvt=" + iEvt.name() + ", discovery=" + iEvt.shortDisplay() + ']'); caches.keySet().forEach(key -> { ignite.destroyCache(key); caches.remove(key); } ); You can merge this pull request into a Git repository by running: $ git pull https://github.com/ryagnik/ignite IGNITE-2786 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/ignite/pull/1688.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #1688 commit 9cb6a2cc722989d9e9752aad67f5843d028e07f1 Author: Rishi YagnikDate: 2017-03-29T02:44:21Z IGNITE-2786 : Fix Spring Client reconnect issue using reconnect event mechanism. > SpringCache doesn't survive client reconnect > > > Key: IGNITE-2786 > URL: https://issues.apache.org/jira/browse/IGNITE-2786 > Project: Ignite > Issue Type: Improvement > Components: cache >Affects Versions: 1.5.0.final >Reporter: Valentin Kulichenko >Assignee: Rishi > Fix For: 2.0 > > > After a client disconnects and reconnects with new ID, Spring caching can't > be used, because existing cache instance are closed. -- This message was sent by Atlassian JIRA (v6.3.15#6346)
[jira] [Commented] (IGNITE-2786) SpringCache doesn't survive client reconnect
[ https://issues.apache.org/jira/browse/IGNITE-2786?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15942510#comment-15942510 ] Rishi commented on IGNITE-2786: --- The fix can be applied as follows with SpringCacheManager - 1) Design was to listen for ignite re connect event 2) And clear the cache on reconnect See the following code below and let us know if this is helpful - In afterPropertiesSet - //Handles the reconnect event, on server crashes OR network failure, client connects to server and // destroy the cache IgnitePredicate lsnr = iEvt -> { LOGGER.info("Received discovery event [iEvt=" + iEvt.name() + ", discovery=" + iEvt.shortDisplay() + ']'); caches.keySet().forEach(key -> { ignite.destroyCache(key); caches.remove(key); } ); Let me know if you see any side effects with the fix. > SpringCache doesn't survive client reconnect > > > Key: IGNITE-2786 > URL: https://issues.apache.org/jira/browse/IGNITE-2786 > Project: Ignite > Issue Type: Improvement > Components: cache >Affects Versions: 1.5.0.final >Reporter: Valentin Kulichenko > Fix For: 2.0 > > > After a client disconnects and reconnects with new ID, Spring caching can't > be used, because existing cache instance are closed. -- This message was sent by Atlassian JIRA (v6.3.15#6346)