简体   繁体   中英

Infinispan JGROUPS force Change View

I'm working with Wildfly 9.x , with 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.

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?

If you manage to get access to the JGroups channel, then [1] might work. IIRC the channel can be retrieved via cache.getAdvancedCache().getRpcManager().getChannel() , or some similar call...

[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. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM