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.
This commit is contained in:
Marc-Aurèle Brothier 2019-06-05 12:58:18 +02:00 committed by Rohit Yadav
parent 4d9206aef5
commit c5f0844f80
2 changed files with 9 additions and 94 deletions

View File

@ -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

View File

@ -27,92 +27,18 @@
http://www.springframework.org/schema/context/spring-context.xsd"
>
<!--
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" />