我正在使用Wildfly 9.x和Infinispan 7.2.3。我正面临着强制执行jgroups change_view事件以在“前毁灭”阶段选择其他协调器的问题。
此代码段代码:
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);
给我这个错误:
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
有没有办法使用infinispan强制设置新视图?
最佳答案
如果您设法访问JGroups通道,则[1]可能有效。 IIRC频道可以通过cache.getAdvancedCache().getRpcManager().getChannel()
或类似的调用来检索...
[1] https://github.com/belaban/JGroups/wiki/Changing-the-coordinator-of-a-cluster