Message Boards
Override liferay-multi-vm.xml
Pankaj Kumar, modified 3 Years ago.
Override liferay-multi-vm.xml
Regular Member Posts: 101 Join Date: 7/27/14 Recent Posts
Hi All,
I am using Liferay DXP 7.2 .I want to override liferay-multi-vm.xml so that i can add my custom entity configuration and replication can happen in cluster environment I tried to write Fragment using com.liferay.portal.cache.ehcache.impl-2.0.5 module but not able to write.
Can any tell me how we can override liferay-multi-vm.xml
Thanks,Pankaj Semwal
I am using Liferay DXP 7.2 .I want to override liferay-multi-vm.xml so that i can add my custom entity configuration and replication can happen in cluster environment I tried to write Fragment using com.liferay.portal.cache.ehcache.impl-2.0.5 module but not able to write.
Can any tell me how we can override liferay-multi-vm.xml
Thanks,Pankaj Semwal
David H Nebinger, modified 3 Years ago.
RE: Override liferay-multi-vm.xml
Liferay Legend Posts: 14916 Join Date: 9/2/06 Recent Posts
Same way it has always been done...
Create the xml file and then set the ehcache.multi.vm.config.location property in portal-ext.properties as the full path to the file.
Note, however, that I'm guessing you're about to misuse multi-vm caching. Generally there is very little that you want to push in here.
Why? Well the contents are replicated around the entire cluster. Often times you do not need or want this, especially if a node isn't asking for it. Unused but cached data sits in the memory of the application server, consuming resources that you would often be better served using in other ways.
I rarely want to use multi-vm caching. Single-vm is a good bet, if you needed a value on a node, you're likely going to need it on that node again sometime soon. But even then, you have to understand the probability of a cache hit just as much as the impact of a cache miss.
Create the xml file and then set the ehcache.multi.vm.config.location property in portal-ext.properties as the full path to the file.
Note, however, that I'm guessing you're about to misuse multi-vm caching. Generally there is very little that you want to push in here.
Why? Well the contents are replicated around the entire cluster. Often times you do not need or want this, especially if a node isn't asking for it. Unused but cached data sits in the memory of the application server, consuming resources that you would often be better served using in other ways.
I rarely want to use multi-vm caching. Single-vm is a good bet, if you needed a value on a node, you're likely going to need it on that node again sometime soon. But even then, you have to understand the probability of a cache hit just as much as the impact of a cache miss.
Pankaj Kumar, modified 3 Years ago.
RE: Override liferay-multi-vm.xml
Regular Member Posts: 101 Join Date: 7/27/14 Recent Posts
Thanks David for response.You mean i need to create one folder in Liferay home and add liferay-multi-vm.xml file there and read the file as below.ehcache.multi.vm.config.location={Liferay_home}\custom\liferay-multi-vm.xml
Eric D, modified 3 Years ago.
RE: Override liferay-multi-vm.xml
Junior Member Posts: 55 Join Date: 3/25/16 Recent Posts
But now we can do this without restarting our Liferay :
https://issues.liferay.com/browse/LPS-88547
Anyone know if we can do this in 7.1 ? If yes can we do this with Fixpack 11 ? (I never see this LPS-88547 in the change logs of Liferay 7.1 or 7.2)
Thanks,
Eric.
https://issues.liferay.com/browse/LPS-88547
Anyone know if we can do this in 7.1 ? If yes can we do this with Fixpack 11 ? (I never see this LPS-88547 in the change logs of Liferay 7.1 or 7.2)
Thanks,
Eric.
Pankaj Kumar, modified 3 Years ago.
RE: Override liferay-multi-vm.xml
Regular Member Posts: 101 Join Date: 7/27/14 Recent Posts
After giving the location ehcache.multi.vm.config.location={Liferay_home}\custom\liferay-multi-vm.xml i am getting below exception
FrameworkEvent ERROR
com.liferay.portal.kernel.exception.SystemException: Unable to instantiate cache event listener factory com.liferay.portal.cache.ehcache.LiferayCacheEventListenerFactory
at com.liferay.portal.cache.ehcache.internal.event.EhcachePortalCacheListenerFactory.create(EhcachePortalCacheListenerFactory.java:94)
at com.liferay.portal.cache.BasePortalCacheManager._initPortalCacheListeners(BasePortalCacheManager.java:348)
at com.liferay.portal.cache.BasePortalCacheManager.reconfigPortalCache(BasePortalCacheManager.java:317)
at com.liferay.portal.cache.ehcache.internal.EhcachePortalCacheManager.reconfigurePortalCaches(EhcachePortalCacheManager.java:92)
Can any body do i need to any addition change.
Thanks,Pankaj Semwal
FrameworkEvent ERROR
com.liferay.portal.kernel.exception.SystemException: Unable to instantiate cache event listener factory com.liferay.portal.cache.ehcache.LiferayCacheEventListenerFactory
at com.liferay.portal.cache.ehcache.internal.event.EhcachePortalCacheListenerFactory.create(EhcachePortalCacheListenerFactory.java:94)
at com.liferay.portal.cache.BasePortalCacheManager._initPortalCacheListeners(BasePortalCacheManager.java:348)
at com.liferay.portal.cache.BasePortalCacheManager.reconfigPortalCache(BasePortalCacheManager.java:317)
at com.liferay.portal.cache.ehcache.internal.EhcachePortalCacheManager.reconfigurePortalCaches(EhcachePortalCacheManager.java:92)
Can any body do i need to any addition change.
Thanks,Pankaj Semwal
Eric D, modified 3 Years ago.
RE: Override liferay-multi-vm.xml
Junior Member Posts: 55 Join Date: 3/25/16 Recent Posts
I had a similar problem in 7.1.
I have done a new module to do that.
You can follow this link :
https://help.liferay.com/hc/en-us/articles/360018175191-Liferay-DXP-Clustering
Look at the bottom of the page (MODIFYING THE CACHE CONFIGURATION WITH A MODULE)
Eric.
I have done a new module to do that.
You can follow this link :
https://help.liferay.com/hc/en-us/articles/360018175191-Liferay-DXP-Clustering
Look at the bottom of the page (MODIFYING THE CACHE CONFIGURATION WITH A MODULE)
Eric.
Pankaj Kumar, modified 3 Years ago.
RE: Override liferay-multi-vm.xml
Regular Member Posts: 101 Join Date: 7/27/14 Recent Posts
Thanks Eric,Let me try with this approach.I am using Liferay 7.2
Look like this class is deprecated in 7.2.I will try and let my finding.
Look like this class is deprecated in 7.2.I will try and let my finding.
Pankaj Kumar, modified 3 Years ago.
RE: Override liferay-multi-vm.xml
Regular Member Posts: 101 Join Date: 7/27/14 Recent Posts
private static final PortalCache<String,Sring> TEST_CACHE= MultiVMPoolUtil.getPortalCache(Test.class.getClasse()));
I followed the approach define here https://help.liferay.com/hc/en-us/articles/360018175191-Liferay-DXP-Clusteringwhen i debug found its still picks the default location of liferay-mutli-vm.xml instead of mine which is override-liferay-multi-vm-clustered.xml
I followed the approach define here https://help.liferay.com/hc/en-us/articles/360018175191-Liferay-DXP-Clusteringwhen i debug found its still picks the default location of liferay-mutli-vm.xml instead of mine which is override-liferay-multi-vm-clustered.xml
Eric D, modified 3 Years ago.
RE: Override liferay-multi-vm.xml
Junior Member Posts: 55 Join Date: 3/25/16 Recent Posts
David H Nebinger, modified 3 Years ago.
RE: Override liferay-multi-vm.xml
Liferay Legend Posts: 14916 Join Date: 9/2/06 Recent Posts
I know you guys are both still plowing forward with this, but again I have to ask...
Why?
I can't tell you how many times I've gone in to tune a Liferay deployment only to undo this kind of thing. It is absolutely not a "go-to" mechanism, it is only good in certain limited scenarios which many developers don't understand.
Why?
I can't tell you how many times I've gone in to tune a Liferay deployment only to undo this kind of thing. It is absolutely not a "go-to" mechanism, it is only good in certain limited scenarios which many developers don't understand.
Pankaj Kumar, modified 3 Years ago.
RE: Override liferay-multi-vm.xml
Regular Member Posts: 101 Join Date: 7/27/14 Recent Posts
As we are using Liferay Portal in clustered environment and there are certain complex rules based on some rules we include ,exclude content and after that we show final content to accomplish this every 30 min a scheduler runs which refresh the cache and final result shown to user.
David H Nebinger, modified 3 Years ago.
RE: Override liferay-multi-vm.xml
Liferay Legend Posts: 14916 Join Date: 9/2/06 Recent Posts
This already sounds like a disaster.
First, if they need to make a change, it may not take effect for 30 minutes under this plan. That means for 30 minutes someone will see something they shouldn't or won't see something they should.
Second, the Liferay permission system is already established which handles visibility on assets. I'm not sure what you're doing, but if you were using permission assignments (either changing permissions on assets or changing roles for the users), the regular Liferay functionality would just work, it applies across the cluster and doesn't require some kind of whacky multi-vm pool usage.
I don't know what these "complex rules" actually are, but if they are processed when they are changed and either modify permissions on assets or adjust user roles, it would apply immediately and would leverage the normal Liferay OOTB functionality to determine who has permission to see what.
First, if they need to make a change, it may not take effect for 30 minutes under this plan. That means for 30 minutes someone will see something they shouldn't or won't see something they should.
Second, the Liferay permission system is already established which handles visibility on assets. I'm not sure what you're doing, but if you were using permission assignments (either changing permissions on assets or changing roles for the users), the regular Liferay functionality would just work, it applies across the cluster and doesn't require some kind of whacky multi-vm pool usage.
I don't know what these "complex rules" actually are, but if they are processed when they are changed and either modify permissions on assets or adjust user roles, it would apply immediately and would leverage the normal Liferay OOTB functionality to determine who has permission to see what.
Olaf Kock, modified 3 Years ago.
RE: Override liferay-multi-vm.xml
Liferay Legend Posts: 6403 Join Date: 9/23/08 Recent PostsPankaj Kumar:
As we are using Liferay Portal in clustered environment and there are certain complex rules based on some rules we include ,exclude content and after that we show final content to accomplish this every 30 min a scheduler runs which refresh the cache and final result shown to user.
"Complex caching rules" - if that's what you wanted to say - indeed sound like a bad idea. Caches should be dead simple.
From the ticket mentioned above, I've clicked through to https://github.com/dantewang/liferay-docs/pull/7/commits/978ad4e4c22797f0c7c2613a79e670319c9f81a2 (in some indirections). In general: The regular clustered cache-invalidation (e.g. server[1] changes an object and signals server[2..n] that the object in question should be flushed from the cache) is fine - and if you need to configure your cache size accordingly: That's fine.
Complex caching rules that span the cluster sound like a solution on the wrong level of abstraction (without further explanation).
Pankaj Kumar, modified 3 Years ago.
RE: Override liferay-multi-vm.xml
Regular Member Posts: 101 Join Date: 7/27/14 Recent Posts
Sorry for late response.I was able to replicate cache in clustered environment .1.Create module-multi-vm.xml and placed under respective module /resource/META-INF/ folder.2. Insted of using MutliVMPoolUtil we should use @Reference
private MultiVMPool _multiVMPool;3.Add the replicatePutsViaCopy=true value we can check from PortalCacheReplicator.java base on requirement.
private MultiVMPool _multiVMPool;3.Add the replicatePutsViaCopy=true value we can check from PortalCacheReplicator.java base on requirement.
Olaf Kock, modified 3 Years ago.
RE: Override liferay-multi-vm.xml
Liferay Legend Posts: 6403 Join Date: 9/23/08 Recent PostsPankaj Kumar:
Rarely (read: never) have I seen a justification for "replicatePut" based on actual necessity. Always, in what I've seen so far, it was a bad idea: If you need an entity on one server, that doesn't have any effect on the other server. In fact, you limit the capacity of the whole cluster by assuming that you have the same objects in all caches.
3.Add the replicatePutsViaCopy=true value we can check from PortalCacheReplicator.java base on requirement.
If you need an object on another server, it will be fetched from the regular storage (database) anyway - and flushed from the cache if it's modified on any other cluster machine.