Running multiple NEAR_ONLY caches in same JVM for production redeployment
asked by eric broyles
We have run into a strange issue that is preventing us from moving forward with Ignite in our application at this time. We are using the Data Grid feature (strictly) running a single grid (currently composed of four standalone nodes on four separate systems) with a partitioned cache and one backup configured. Then we have a web application that is configured to use a NEAR_ONLY cache that connects to that grid. This is all working fine … except when we redeploy our application.
We are running on WebLogic Server 10.3 which supports production redeployment such that you can deploy a new version of your application at the same time as the old version. When this happens, WebLogic will route all new sessions to the new version and any old sessions will remain on the old version until they timeout, at which time the old version is decommissioned. This works fine (we’ve been doing it for years) but not with Ignite. Ignite complains upon startup with the error "MBean was already registered: org.apache:group=Kernal,name=Ignition”.
We have tried several things to get around this but to no avail. Essentially it is trying to start another Ignite instance in the same JVM with the same configuration as the already running NEAR_CACHE instance. I see that the IgnitionEx.registerFactoryMbean method is checking to ensure that there is no Mbean registered , but oddly it is using effectively a hard-code value based upon the string "Kernal" and the simple class name of Ignition.
I don't profess to fully understand why it wants no existing MBeans, but it does strike me as odd that it is using a hard-coded value.
I have seen in the docs that multiple instances can run in the same JVM, but I haven't seen how to make it work (at least not within the context of a web application container where ManagementFactory.getPlatformMBeanServer() is going to return the same value as the first Ignite node that was started).
I also tried calling Ignition.ignite(configuration) but that results in the following exception: org.apache.ignite.IgniteIllegalStateException: Grid instance was not properly started or was already stopped.
I am very happy with Ignite, but unfortunately this issue is preventing me from being able to move forward with it. I hope I'm just missing something simple. I appreciate any help or guidance anyone can offer.
Re: Running multiple NEAR_ONLY caches in same JVM for production redeployment
This post was updated on .
commented by eric broyles
Thank you very much for this solution! I have confirmed that this does indeed resolve the issue. My previous workaround was to create a new MBeanServer instance and set it on the IgniteConfiguration manually. That worked, but it was merely a workaround. This flag is much better.
I had scoured the Ignite code related to creating these MBean names and somehow I completely missed this. I have found it now that you pointed it out. Is this documented anywhere? I see that it's in the IgniteUtils class which is within the internal package - does that mean this class is subject to change without notice?
I am still curious why IgnitionEx.registerFactoryMBean calls IgniteUtils.makeMBeanName with a null first value (which should be the name of the grid). Seems to me that the IgnitionEx.registerFactoryMbean method should take the grid name as the second parameter and that value should be used to make the MBean name (and to register it when it calls IgniteUtils.registerMBean).