首页 > 解决方案 > 基于常规和 Spring 数据的缓存操作因 CacheStoppedException 手动重新连接而失败,clientReconnectDisabled 为 true

问题描述

我们正在运行 2.4 版并使用 Spring IgniteSpringBeanSpring Data存储库进行集群和缓存访问。

由于我们遇到了很多与 IgniteClientDisconnectedException 相关的问题,因此我正在编写一个手动分段解析器(通过禁用自动客户端重新连接并将 clientReconnectDisabled 设置为 true)来检测这种情况(使用定期运行的简单缓存查询)并启动断开连接通过IgniteSpringBean#close然后重新连接下面的代码片段(非常类似于这个讨论,http: //apache-ignite-users.70518.x6.nabble.com/SPI-has-already-been-started-always- create-new-configuration-instance-for-each-starting-Ignite-instar-td7360.html),

bean DCMIgniteSpringBean#reconnect() 中的代码片段在 XML 配置中引用如下:

public final void reconnect(final IgniteConfiguration specifiedIgniteConfiguration) {
  LOGGER.info("Initiating reconnect..");
  try {
    close();
    //destroy();
  } catch (Exception e) {
    LOGGER.warn("Error while disconnecting", e);
  }
  LOGGER.info("Disconnected..");
  try {
    Thread.sleep(1000);
  } catch (Exception e) {
    LOGGER.warn("Error while pausing to reconnect", e);
  }
  setConfiguration(specifiedIgniteConfiguration);
  afterSingletonsInstantiated();
  final CacheConfiguration[] cfgArray = specifiedIgniteConfiguration.getCacheConfiguration();
  LOGGER.info("Cache configuration is : {}", cfgArray);
  getOrCreateCaches(Arrays.asList(cfgArray));
  LOGGER.info("Reconnected..");
}

XML bean 配置片段:

<bean id="igniteInstance" class="com.brocade.dcm.configuration.DCMIgniteSpringBean">
        <property name="configuration" ref="grid.cfg"/>
</bean>
<bean id="grid.cfg.provider" class="com.brocade.dcm.configuration.ClientHealthBasedReconnectWrapper">
        <lookup-method name="createIgniteConfiguration" bean="grid.cfg"/>
</bean>
<bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration" scope="prototype">
...
...
</bean>

通过上面的操作,我得到了这个工作并看到我的扩展 IgniteSpringBean 客户端正确重新连接并启动了所有缓存。

然而,问题是即使客户端已连接并且缓存已启动,对任何IgniteCacheIgniteRepository实例的所有后续调用/查询都失败,并出现 CacheStoppedException(如下)并且呈现不可用。

有人可以建议我可以做些什么来刷新这些参考资料。我知道当客户端自动重新连接后断开连接时,引用继续正常工作,这告诉我有一种方法可以刷新它们并且我没有这样做。

关于如何实现这一点的任何专家想法......感觉我很接近但仍然很远,因为我正在做黑客:-(

以下是我分别获得的 IgniteCache#query() 和 IgniteRepository#findByXXX() 调用的例外情况,

class org.apache.ignite.internal.processors.cache.CacheStoppedException: Failed to perform cache operation (cache is stopped): FabricInfoCache
    at org.apache.ignite.internal.processors.cache.GridCacheGateway.enter(GridCacheGateway.java:164)
    at org.apache.ignite.internal.processors.cache.GatewayProtectedCacheProxy.onEnter(GatewayProtectedCacheProxy.java:1684)
    at org.apache.ignite.internal.processors.cache.GatewayProtectedCacheProxy.query(GatewayProtectedCacheProxy.java:365)
    at com.brocade.dcm.configuration.ClientHealthBasedReconnectWrapper.monitorHealth(ClientHealthBasedReconnectWrapper.java:110)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.springframework.scheduling.support.ScheduledMethodRunnable.run(ScheduledMethodRunnable.java:65)
    at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)

.

[Request processing failed; nested exception is java.lang.IllegalStateException: class org.apache.ignite.internal.processors.cache.CacheStoppedException: Failed to perform cache operation (cache is stopped): WebsocketCacheInfo] with root cause
class org.apache.ignite.internal.processors.cache.CacheStoppedException: Failed to perform cache operation (cache is stopped): WebsocketCacheInfo
    at org.apache.ignite.internal.processors.cache.GridCacheGateway.enter(GridCacheGateway.java:164)
    at org.apache.ignite.internal.processors.cache.GatewayProtectedCacheProxy.onEnter(GatewayProtectedCacheProxy.java:1684)
    at org.apache.ignite.internal.processors.cache.GatewayProtectedCacheProxy.query(GatewayProtectedCacheProxy.java:365)
    at org.apache.ignite.springdata.repository.query.IgniteRepositoryQuery.execute(IgniteRepositoryQuery.java:117)
    at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.doInvoke(RepositoryFactorySupport.java:483)
    at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:461)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    at org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:61)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    at org.springframework.data.repository.core.support.SurroundingTransactionDetectorMethodInterceptor.invoke(SurroundingTransactionDetectorMethodInterceptor.java:57)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:213)
    at com.sun.proxy.$Proxy182.findByWebsocketSessionId(Unknown Source)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:333)
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207)
    at com.sun.proxy.$Proxy124.findByWebsocketSessionId(Unknown Source)

谢谢穆图

标签: springspring-dataignitegridgain

解决方案


我相信这应该在 2.5 中修复:

https://issues.apache.org/jira/browse/IGNITE-2766

请试试这个版本。


推荐阅读