This is an automated email from the ASF dual-hosted git repository. rohit pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/cloudstack.git
The following commit(s) were added to refs/heads/master by this push: new c5f0844 server: deactivate ehcache (#2913) c5f0844 is described below commit c5f0844f804c5ac1da6e5802013fcb6513b4084d Author: Marc-Aurèle Brothier <m...@brothier.org> AuthorDate: Wed Jun 5 12:58:18 2019 +0200 server: deactivate ehcache (#2913) This PR is for deactivating Ehcache in CloudStack since it is not usable. The first commit remove the default RMI cache peering configured for multicast which most of the time cannot work. It also requires to have an interface up which is not always the case while developing offline. The second commits remove the configuration to activate caching on some DAOs. Problems The code in CS does not seem to fit any caching mechanism especially due to the homemade DAO code. The main 3 flaws are the following: Entities are not expected to be shared There is quite a lot of code with method calls passing entity IDs value as long, which does some object fetching. Without caching, this behavior will create distinct objects each time an entity with the same ID is fetched. With the cache enabled, the same object will be shared among those methods. It has been seen that it does generate some side effects where code still expected unchanged entity attributes after calling different methods thus generating exception/bugs. DAO update operations are using search queries Some part of the code are updating entities based on a search query, therefore the whole cache must be invalidated (see GenericDaoBase: public int update(UpdateBuilder ub, final SearchCriteria<?> sc, Integer rows);). Entities based on views joining multiple tables There are quite a lot of entities based on SQL views joining multiple entities in a same object. Enabling caching on those would require a mechanism to link and cross-remove related objects whenever one of the sub-entity is changed. Final word Based on the previously discussed points, the best approach IMHO would be to move out of the custom DAO framework in CS and use a well known one (out of scope of this change of course). It will handle caching well and the joins made by the views in the code. It's not an easy change, but it will fix along a lot of issues and add a proven / robust framework to an important part of the code. --- client/conf/ehcache.xml.in | 11 --- .../spring-engine-schema-core-daos-context.xml | 92 +++------------------- 2 files changed, 9 insertions(+), 94 deletions(-) diff --git a/client/conf/ehcache.xml.in b/client/conf/ehcache.xml.in index 19bfd0f..4f25978 100755 --- a/client/conf/ehcache.xml.in +++ b/client/conf/ehcache.xml.in @@ -163,14 +163,6 @@ under the License. used. --> - <cacheManagerPeerProviderFactory - class="net.sf.ehcache.distribution.RMICacheManagerPeerProviderFactory" - properties="peerDiscovery=automatic, - multicastGroupAddress=230.0.0.1, - multicastGroupPort=4446, timeToLive=1" - propertySeparator="," - /> - <!-- CacheManagerPeerListener @@ -209,9 +201,6 @@ under the License. If not specified it defaults 120000ms. --> - <cacheManagerPeerListenerFactory - class="net.sf.ehcache.distribution.RMICacheManagerPeerListenerFactory"/> - <!-- Cache configuration diff --git a/engine/schema/src/main/resources/META-INF/cloudstack/core/spring-engine-schema-core-daos-context.xml b/engine/schema/src/main/resources/META-INF/cloudstack/core/spring-engine-schema-core-daos-context.xml index 84c2758..b7a4fe8 100644 --- a/engine/schema/src/main/resources/META-INF/cloudstack/core/spring-engine-schema-core-daos-context.xml +++ b/engine/schema/src/main/resources/META-INF/cloudstack/core/spring-engine-schema-core-daos-context.xml @@ -28,91 +28,17 @@ > <!-- - DAO with customized configuration - --> - <bean id="serviceOfferingDaoImpl" class="com.cloud.service.dao.ServiceOfferingDaoImpl"> - <property name="configParams"> - <map> - <entry key="cache.size" value="50" /> - <entry key="cache.time.to.live" value="600" /> - </map> - </property> - </bean> - - <bean id="diskOfferingDaoImpl" class="com.cloud.storage.dao.DiskOfferingDaoImpl"> - <property name="configParams"> - <map> - <entry key="cache.size" value="50" /> - <entry key="cache.time.to.live" value="600" /> - </map> - </property> - </bean> - - <bean id="dataCenterDaoImpl" class="com.cloud.dc.dao.DataCenterDaoImpl"> - <property name="configParams"> - <map> - <entry key="cache.size" value="50" /> - <entry key="cache.time.to.live" value="600" /> - </map> - </property> - </bean> - - <bean id="hostPodDaoImpl" class="com.cloud.dc.dao.HostPodDaoImpl"> - <property name="configParams"> - <map> - <entry key="cache.size" value="50" /> - <entry key="cache.time.to.live" value="600" /> - </map> - </property> - </bean> - - <bean id="vlanDaoImpl" class="com.cloud.dc.dao.VlanDaoImpl"> - <property name="configParams"> - <map> - <entry key="cache.size" value="30" /> - <entry key="cache.time.to.live" value="3600" /> - </map> - </property> - </bean> - - <bean id="userDaoImpl" class="com.cloud.user.dao.UserDaoImpl"> - <property name="configParams"> - <map> - <entry key="cache.size" value="5000" /> - <entry key="cache.time.to.live" value="300" /> - </map> - </property> - </bean> - - <bean id="VMTemplateDaoImpl" class="com.cloud.storage.dao.VMTemplateDaoImpl"> - <property name="configParams"> - <map> - <entry key="cache.size" value="100" /> - <entry key="cache.time.to.live" value="600" /> - </map> - </property> - </bean> - - <bean id="hypervisorCapabilitiesDaoImpl" class="com.cloud.hypervisor.dao.HypervisorCapabilitiesDaoImpl"> - <property name="configParams"> - <map> - <entry key="cache.size" value="100" /> - <entry key="cache.time.to.live" value="600" /> - </map> - </property> - </bean> - <bean id="dedicatedResourceDaoImpl" class="com.cloud.dc.dao.DedicatedResourceDaoImpl"> - <property name="configParams"> - <map> - <entry key="cache.size" value="30" /> - <entry key="cache.time.to.live" value="3600" /> - </map> - </property> - </bean> - - <!-- DAOs with default configuration --> + <bean id="serviceOfferingDaoImpl" class="com.cloud.service.dao.ServiceOfferingDaoImpl" /> + <bean id="diskOfferingDaoImpl" class="com.cloud.storage.dao.DiskOfferingDaoImpl" /> + <bean id="dataCenterDaoImpl" class="com.cloud.dc.dao.DataCenterDaoImpl" /> + <bean id="hostPodDaoImpl" class="com.cloud.dc.dao.HostPodDaoImpl" /> + <bean id="vlanDaoImpl" class="com.cloud.dc.dao.VlanDaoImpl" /> + <bean id="userDaoImpl" class="com.cloud.user.dao.UserDaoImpl" /> + <bean id="VMTemplateDaoImpl" class="com.cloud.storage.dao.VMTemplateDaoImpl" /> + <bean id="hypervisorCapabilitiesDaoImpl" class="com.cloud.hypervisor.dao.HypervisorCapabilitiesDaoImpl" /> + <bean id="dedicatedResourceDaoImpl" class="com.cloud.dc.dao.DedicatedResourceDaoImpl" /> <bean id="roleDaoImpl" class="org.apache.cloudstack.acl.dao.RoleDaoImpl" /> <bean id="rolePermissionsDaoImpl" class="org.apache.cloudstack.acl.dao.RolePermissionsDaoImpl" /> <bean id="accountDaoImpl" class="com.cloud.user.dao.AccountDaoImpl" />