Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0034499Openbravo ERPA. Platformpublic2016-11-14 17:062016-12-16 18:38
caristu 
caristu 
highminoralways
closedfixed 
5
 
3.0PR17Q1 
alostale
Core
No
0034499: [clustering] CachedPreference feature is not supported on clustered environments
The CachedPreference class is an application scoped which implements a cache that keeps in memory the value of some preferences defined at system level along the application life cycle, avoiding the time spent to compute the preference value.

This cache is invalidated/updated by using an observer called PreferenceEventHandler. This kind of cache invalidation is not valid for clustered environments (multiple JVM)

Currently, it will be necessary to restart Tomcat to retrieve the new value of the preference in every JVM.
In description
Two possible alternatives:

a) Declare CachedPreference as @SessionScoped. This way the cache will be recreated on every new session. This is even more appropriate for the case of preferences as they are being refreshed on every new session. This is the recommended solution for this case.

b) Implement a invalidation mechanism valid for a clustered environment. For example based on a timer: by invalidating the cache every time the timeout is expired.
clustering
related to feature request 0032039 closed caristu Add generic mechanism to have multiple cached preferences 
related to defect 00302043.0PR15Q4 closed caristu prevent unpaged datsource request from manual sources 
related to feature request 0032702 closed AugustoMauch Store server backoffice enablement 
related to feature request 00327283.0PR16Q3 closed inigosanchez Standard datasources should check entity access. 
related to feature request 00326103.0PR16Q3 closed NaroaIriarte standard datasources shouldn't accept where parameter by default 
related to defect 0034536 closed caristu API change required to remove PreferenceEventHandler class 
blocks design defect 0034490 acknowledged Triage Platform Base [clustering] Support clustering 
causes defect 0034514 closed caristu [clustering] CachedPreference should implement Serializable 
Issue History
2016-11-14 17:06caristuNew Issue
2016-11-14 17:06caristuAssigned To => platform
2016-11-14 17:06caristuModules => Core
2016-11-14 17:06caristuTriggers an Emergency Pack => No
2016-11-14 17:06caristuRelationship addedblocks 0034490
2016-11-14 17:07caristuRelationship addedrelated to 0032039
2016-11-14 17:07caristuRelationship addedrelated to 0030204
2016-11-14 17:09caristuRelationship addedrelated to 0032702
2016-11-14 17:10caristuRelationship addedrelated to 0032728
2016-11-14 17:18caristuRelationship addedrelated to 0032610
2016-11-14 17:19caristuProposed Solution updated
2016-11-14 19:15caristuAssigned Toplatform => caristu
2016-11-14 19:15caristuStatusnew => scheduled
2016-11-15 08:37hgbotCheckin
2016-11-15 08:37hgbotNote Added: 0091522
2016-11-15 08:37hgbotStatusscheduled => resolved
2016-11-15 08:37hgbotResolutionopen => fixed
2016-11-15 08:37hgbotFixed in SCM revision => http://code.openbravo.com/erp/devel/pi/rev/48248d89f4bae13423869c9969342943c7f97b1f [^]
2016-11-15 08:38caristuReview Assigned To => alostale
2016-11-15 08:59alostaleTag Attached: clustering
2016-11-15 09:37caristuRelationship addedcauses 0034514
2016-11-15 16:25caristuRelationship addedrelated to 0034536
2016-11-15 16:47hgbotCheckin
2016-11-15 16:47hgbotNote Added: 0091575
2016-11-15 16:47hgbotCheckin
2016-11-15 16:47hgbotNote Added: 0091576
2016-11-25 09:34alostaleNote Added: 0091811
2016-11-25 09:34alostaleStatusresolved => closed
2016-11-25 09:34alostaleFixed in Version => 3.0PR17Q1
2016-12-16 18:38hudsonbotCheckin
2016-12-16 18:38hudsonbotNote Added: 0092622
2016-12-16 18:38hudsonbotCheckin
2016-12-16 18:38hudsonbotNote Added: 0092631
2016-12-16 18:38hudsonbotCheckin
2016-12-16 18:38hudsonbotNote Added: 0092632

Notes
(0091522)
hgbot   
2016-11-15 08:37   
Repository: erp/devel/pi
Changeset: 48248d89f4bae13423869c9969342943c7f97b1f
Author: Carlos Aristu <carlos.aristu <at> openbravo.com>
Date: Tue Nov 15 08:36:29 2016 +0100
URL: http://code.openbravo.com/erp/devel/pi/rev/48248d89f4bae13423869c9969342943c7f97b1f [^]

fixes issue 34499: CachedPreference feature does not support clustering

The CachedPreference was being used as a singleton which was keeping a set of preferences defined at System Level in a cache. Those values can be refreshed with the PreferenceEventHandler every time it detects a change. This mechanism was not valid for clustered environments because changes were being detected just on the node (JVM) where the event handler was executed.

To fix this problem we have modified the scope of the class from application to session. Thus, the cache will be initialized on every new session created on each node of the cluster.

---
M modules/org.openbravo.client.application/src/org/openbravo/client/application/CachedPreference.java
---
(0091575)
hgbot   
2016-11-15 16:47   
Repository: erp/devel/pi
Changeset: 9d2a3ac397418df563ba20c90766b20e9e6635a1
Author: Carlos Aristu <carlos.aristu <at> openbravo.com>
Date: Tue Nov 15 16:45:28 2016 +0100
URL: http://code.openbravo.com/erp/devel/pi/rev/9d2a3ac397418df563ba20c90766b20e9e6635a1 [^]

related to issue 34499: removed PreferenceEventHandler class

PreferenceEventHandler class was being used to detect changes on the preference values cached by the CachedPreference class. As CachedPreference now declared the @SessionScoped is no longer a singleton therefore the cached values will persist along the life cycle of a session.

As preferences are refreshed with every new session this handler is no longer required. Besides, the injection of the @SessionScoped bean in this handler was causing WELD-001303 error.

---
R modules/org.openbravo.client.application/src/org/openbravo/client/application/event/PreferenceEventHandler.java
---
(0091576)
hgbot   
2016-11-15 16:47   
Repository: erp/devel/pi
Changeset: 7ce6ca92bcbe89c1bd88c213b7e0dfa680160d9f
Author: Carlos Aristu <carlos.aristu <at> openbravo.com>
Date: Tue Nov 15 16:45:52 2016 +0100
URL: http://code.openbravo.com/erp/devel/pi/rev/7ce6ca92bcbe89c1bd88c213b7e0dfa680160d9f [^]

related to issue 34499: updated comment

---
M modules/org.openbravo.client.application/src/org/openbravo/client/application/CachedPreference.java
---
(0091811)
alostale   
2016-11-25 09:34   
code reviewed + tested
(0092622)
hudsonbot   
2016-12-16 18:38   
A changeset related to this issue has been promoted main and to the
Central Repository, after passing a series of tests.

Promotion changeset: https://code.openbravo.com/erp/devel/main/rev/dc8bf00badd0 [^]
Maturity status: Test
(0092631)
hudsonbot   
2016-12-16 18:38   
A changeset related to this issue has been promoted main and to the
Central Repository, after passing a series of tests.

Promotion changeset: https://code.openbravo.com/erp/devel/main/rev/dc8bf00badd0 [^]
Maturity status: Test
(0092632)
hudsonbot   
2016-12-16 18:38   
A changeset related to this issue has been promoted main and to the
Central Repository, after passing a series of tests.

Promotion changeset: https://code.openbravo.com/erp/devel/main/rev/dc8bf00badd0 [^]
Maturity status: Test