Skip to content

Commit c5f0844

Browse files
marcaureleyadvr
authored andcommitted
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.
1 parent 4d9206a commit c5f0844

2 files changed

Lines changed: 9 additions & 94 deletions

File tree

client/conf/ehcache.xml.in

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -163,14 +163,6 @@ under the License.
163163
used.
164164

165165
-->
166-
<cacheManagerPeerProviderFactory
167-
class="net.sf.ehcache.distribution.RMICacheManagerPeerProviderFactory"
168-
properties="peerDiscovery=automatic,
169-
multicastGroupAddress=230.0.0.1,
170-
multicastGroupPort=4446, timeToLive=1"
171-
propertySeparator=","
172-
/>
173-
174166

175167
<!--
176168
CacheManagerPeerListener
@@ -209,9 +201,6 @@ under the License.
209201
If not specified it defaults 120000ms.
210202

211203
-->
212-
<cacheManagerPeerListenerFactory
213-
class="net.sf.ehcache.distribution.RMICacheManagerPeerListenerFactory"/>
214-
215204

216205
<!--
217206
Cache configuration

engine/schema/src/main/resources/META-INF/cloudstack/core/spring-engine-schema-core-daos-context.xml

Lines changed: 9 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -27,92 +27,18 @@
2727
http://www.springframework.org/schema/context/spring-context.xsd"
2828
>
2929

30-
<!--
31-
DAO with customized configuration
32-
-->
33-
<bean id="serviceOfferingDaoImpl" class="com.cloud.service.dao.ServiceOfferingDaoImpl">
34-
<property name="configParams">
35-
<map>
36-
<entry key="cache.size" value="50" />
37-
<entry key="cache.time.to.live" value="600" />
38-
</map>
39-
</property>
40-
</bean>
41-
42-
<bean id="diskOfferingDaoImpl" class="com.cloud.storage.dao.DiskOfferingDaoImpl">
43-
<property name="configParams">
44-
<map>
45-
<entry key="cache.size" value="50" />
46-
<entry key="cache.time.to.live" value="600" />
47-
</map>
48-
</property>
49-
</bean>
50-
51-
<bean id="dataCenterDaoImpl" class="com.cloud.dc.dao.DataCenterDaoImpl">
52-
<property name="configParams">
53-
<map>
54-
<entry key="cache.size" value="50" />
55-
<entry key="cache.time.to.live" value="600" />
56-
</map>
57-
</property>
58-
</bean>
59-
60-
<bean id="hostPodDaoImpl" class="com.cloud.dc.dao.HostPodDaoImpl">
61-
<property name="configParams">
62-
<map>
63-
<entry key="cache.size" value="50" />
64-
<entry key="cache.time.to.live" value="600" />
65-
</map>
66-
</property>
67-
</bean>
68-
69-
<bean id="vlanDaoImpl" class="com.cloud.dc.dao.VlanDaoImpl">
70-
<property name="configParams">
71-
<map>
72-
<entry key="cache.size" value="30" />
73-
<entry key="cache.time.to.live" value="3600" />
74-
</map>
75-
</property>
76-
</bean>
77-
78-
<bean id="userDaoImpl" class="com.cloud.user.dao.UserDaoImpl">
79-
<property name="configParams">
80-
<map>
81-
<entry key="cache.size" value="5000" />
82-
<entry key="cache.time.to.live" value="300" />
83-
</map>
84-
</property>
85-
</bean>
86-
87-
<bean id="VMTemplateDaoImpl" class="com.cloud.storage.dao.VMTemplateDaoImpl">
88-
<property name="configParams">
89-
<map>
90-
<entry key="cache.size" value="100" />
91-
<entry key="cache.time.to.live" value="600" />
92-
</map>
93-
</property>
94-
</bean>
95-
96-
<bean id="hypervisorCapabilitiesDaoImpl" class="com.cloud.hypervisor.dao.HypervisorCapabilitiesDaoImpl">
97-
<property name="configParams">
98-
<map>
99-
<entry key="cache.size" value="100" />
100-
<entry key="cache.time.to.live" value="600" />
101-
</map>
102-
</property>
103-
</bean>
104-
<bean id="dedicatedResourceDaoImpl" class="com.cloud.dc.dao.DedicatedResourceDaoImpl">
105-
<property name="configParams">
106-
<map>
107-
<entry key="cache.size" value="30" />
108-
<entry key="cache.time.to.live" value="3600" />
109-
</map>
110-
</property>
111-
</bean>
112-
11330
<!--
11431
DAOs with default configuration
11532
-->
33+
<bean id="serviceOfferingDaoImpl" class="com.cloud.service.dao.ServiceOfferingDaoImpl" />
34+
<bean id="diskOfferingDaoImpl" class="com.cloud.storage.dao.DiskOfferingDaoImpl" />
35+
<bean id="dataCenterDaoImpl" class="com.cloud.dc.dao.DataCenterDaoImpl" />
36+
<bean id="hostPodDaoImpl" class="com.cloud.dc.dao.HostPodDaoImpl" />
37+
<bean id="vlanDaoImpl" class="com.cloud.dc.dao.VlanDaoImpl" />
38+
<bean id="userDaoImpl" class="com.cloud.user.dao.UserDaoImpl" />
39+
<bean id="VMTemplateDaoImpl" class="com.cloud.storage.dao.VMTemplateDaoImpl" />
40+
<bean id="hypervisorCapabilitiesDaoImpl" class="com.cloud.hypervisor.dao.HypervisorCapabilitiesDaoImpl" />
41+
<bean id="dedicatedResourceDaoImpl" class="com.cloud.dc.dao.DedicatedResourceDaoImpl" />
11642
<bean id="roleDaoImpl" class="org.apache.cloudstack.acl.dao.RoleDaoImpl" />
11743
<bean id="rolePermissionsDaoImpl" class="org.apache.cloudstack.acl.dao.RolePermissionsDaoImpl" />
11844
<bean id="accountDaoImpl" class="com.cloud.user.dao.AccountDaoImpl" />

0 commit comments

Comments
 (0)