[英]Infinispan JGROUPS force Change View
I'm working with Wildfly 9.x , with Infinispan 7.2.3. 我正在使用Wildfly 9.x和Infinispan 7.2.3。 I'm facing up to the problem of forcing a jgroups change_view event in order to elect a different coordinator in a "predestroy" phase.
我正面临着强制执行jgroups change_view事件以在“前毁灭”阶段选择其他协调器的问题。
This snippet code : 此代码段代码:
Address localAddr=cacheManager.getAddress();
Address coord=cacheManager.getMembers().get(0);
if(!localAddr.equals(coord)) {
logger.error("View can only be changed on coordinator");
return;
}
if(cacheManager.getTransport().getMembers().size() == 1) {
logger.error("Coordinator cannot change as view only has a single member");
return;
}
long newId= cacheManager.getTransport().getViewId() + 1;
List<Address> mbrs = cacheManager.getMembers();
Address tmpCoord=mbrs.remove(0);
gives me this error: 给我这个错误:
10:13:28,688 WARN [org.jboss.as.ee] (ServerService Thread Pool -- 95) WFLYEE0006: Failed to destroy component instance org.jboss.as.ejb3.component.singleton.SingletonComponentInstance@5d8d8b5c: javax.ejb.EJBException: java.lang.UnsupportedOperationException
at org.jboss.as.ejb3.tx.CMTTxInterceptor.handleExceptionInOurTx(CMTTxInterceptor.java:187)
at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:277)
at org.jboss.as.ejb3.tx.CMTTxInterceptor.requiresNew(CMTTxInterceptor.java:349)
at org.jboss.as.ejb3.tx.LifecycleCMTTxInterceptor.processInvocation(LifecycleCMTTxInterceptor.java:66)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)
at org.jboss.as.ejb3.component.interceptors.CurrentInvocationContextInterceptor.processInvocation(CurrentInvocationContextInterceptor.java:41)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)
at org.jboss.as.ee.concurrent.ConcurrentContextInterceptor.processInvocation(ConcurrentContextInterceptor.java:45)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)
at org.jboss.invocation.ContextClassLoaderInterceptor.processInvocation(ContextClassLoaderInterceptor.java:64)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)
at org.jboss.invocation.InterceptorContext.run(InterceptorContext.java:356)
at org.jboss.invocation.PrivilegedWithCombinerInterceptor.processInvocation(PrivilegedWithCombinerInterceptor.java:80)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)
at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)
at org.jboss.as.ee.component.BasicComponentInstance.destroy(BasicComponentInstance.java:125)
at org.jboss.as.ejb3.component.singleton.SingletonComponent.destroySingletonInstance(SingletonComponent.java:185)
at org.jboss.as.ejb3.component.singleton.SingletonComponent.done(SingletonComponent.java:142)
at org.jboss.as.ejb3.component.EJBComponent.stop(EJBComponent.java:559)
at org.jboss.as.ee.component.ComponentStartService$2.run(ComponentStartService.java:78)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
at org.jboss.threads.JBossThread.run(JBossThread.java:320)
Caused by: java.lang.UnsupportedOperationException
at java.util.Collections$UnmodifiableList.remove(Collections.java:1317)
at com.klopotek.core.session.job.SessionsHooverScheduler.changeView(SessionsHooverScheduler.java:219)
at com.klopotek.core.session.job.SessionsHooverScheduler.stopJobs(SessionsHooverScheduler.java:192)
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:497)
at org.jboss.as.ee.component.ManagedReferenceLifecycleMethodInterceptor.processInvocation(ManagedReferenceLifecycleMethodInterceptor.java:96)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)
at org.jboss.as.weld.ejb.Jsr299BindingsInterceptor.doLifecycleInterception(Jsr299BindingsInterceptor.java:114)
at org.jboss.as.weld.ejb.Jsr299BindingsInterceptor.processInvocation(Jsr299BindingsInterceptor.java:98)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)
at org.jboss.as.ee.component.ManagedReferenceReleaseInterceptor.processInvocation(ManagedReferenceReleaseInterceptor.java:56)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)
at org.jboss.as.ee.component.NamespaceContextInterceptor.processInvocation(NamespaceContextInterceptor.java:50)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)
at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:275)
... 24 more
Is there a way to force the set of a new view using infinispan? 有没有办法使用infinispan强制设置新视图?
If you manage to get access to the JGroups channel, then [1] might work. 如果您设法访问JGroups通道,则[1]可能有效。 IIRC the channel can be retrieved via
cache.getAdvancedCache().getRpcManager().getChannel()
, or some similar call... IIRC通道可以通过
cache.getAdvancedCache().getRpcManager().getChannel()
或类似的调用来检索...
[1] https://github.com/belaban/JGroups/wiki/Changing-the-coordinator-of-a-cluster [1] https://github.com/belaban/JGroups/wiki/Changing-the-coordinator-of-a-cluster
I'm not sure, but change the coordinator for Infinispan might cause another change and maybe another rebalancing if you do so. 我不确定,但是如果更改Infinispan的协调器,则可能会导致另一次更改,甚至可能导致重新平衡。 Also this behaviour might change with the next version.
同样,此行为在下一版本中可能会更改。
Why you want to do it? 为什么要这么做? If you shutdonw the node the coordinator is changed according to the policy and the caches are rebalanced (for distributed) to match the number of owners for a key.
如果关闭节点,则根据策略更改协调器,并重新平衡缓存(用于分布式)以匹配密钥的所有者数。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.