Author: trang_vu
Date: 2011-11-02 03:12:52 -0400 (Wed, 02 Nov 2011)
New Revision: 5141
Added:
kernel/branches/2.2.x/patch/2.2.11-GA/KER-178/readme.txt
Modified:
kernel/branches/2.2.x/exo.kernel.commons/src/main/java/org/exoplatform/commons/utils/ISO8601ASF.java
kernel/branches/2.2.x/exo.kernel.commons/src/main/java/org/exoplatform/commons/utils/Tools.java
Log:
KER-178: Provide a Util method to give an alternative to TimeZone.getTimeZone with less
contention
Fix description
* Avoid the usage of method java.util.TimeZone.getTimeZone(String ID). We use now a less
synchronized method implemented in kernel project instead.
Modified:
kernel/branches/2.2.x/exo.kernel.commons/src/main/java/org/exoplatform/commons/utils/ISO8601ASF.java
===================================================================
---
kernel/branches/2.2.x/exo.kernel.commons/src/main/java/org/exoplatform/commons/utils/ISO8601ASF.java 2011-11-01
15:50:49 UTC (rev 5140)
+++
kernel/branches/2.2.x/exo.kernel.commons/src/main/java/org/exoplatform/commons/utils/ISO8601ASF.java 2011-11-02
07:12:52 UTC (rev 5141)
@@ -187,7 +187,7 @@
return null;
}
- TimeZone tz = TimeZone.getTimeZone(tzID);
+ TimeZone tz = Tools.getTimeZone(tzID);
// verify id of returned time zone (getTimeZone defaults to "GMT")
if (!tz.getID().equals(tzID))
{
Modified:
kernel/branches/2.2.x/exo.kernel.commons/src/main/java/org/exoplatform/commons/utils/Tools.java
===================================================================
---
kernel/branches/2.2.x/exo.kernel.commons/src/main/java/org/exoplatform/commons/utils/Tools.java 2011-11-01
15:50:49 UTC (rev 5140)
+++
kernel/branches/2.2.x/exo.kernel.commons/src/main/java/org/exoplatform/commons/utils/Tools.java 2011-11-02
07:12:52 UTC (rev 5141)
@@ -23,6 +23,7 @@
import java.util.Map;
import java.util.Properties;
import java.util.Set;
+import java.util.TimeZone;
/**
* @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
@@ -30,8 +31,12 @@
*/
public class Tools
{
-
/**
+ * All the time zones already registered
+ */
+ private static volatile Map<String, TimeZone> TIME_ZONES = new
HashMap<String, TimeZone>();
+
+ /**
* Instantiates a {@link HashSet} object and fills it with the provided element
array.
*
* @param elements the list of elements to add
@@ -155,4 +160,35 @@
String suffix = s.substring(s.length() - end.length());
return suffix.equalsIgnoreCase(end);
}
+
+ /**
+ * This method is similar to {@link TimeZone#getTimeZone(String)} with less
contention
+ */
+ public static TimeZone getTimeZone(String ID)
+ {
+ if (ID == null)
+ {
+ throw new NullPointerException("ID of the timezone cannot be null");
+ }
+ if (ID.length() == 0)
+ {
+ throw new IllegalArgumentException("ID of the timezone cannot be
empty");
+ }
+ TimeZone tz = TIME_ZONES.get(ID);
+ if (tz == null)
+ {
+ synchronized (TimeZone.class)
+ {
+ tz = TIME_ZONES.get(ID);
+ if (tz == null)
+ {
+ tz = TimeZone.getTimeZone(ID);
+ Map<String, TimeZone> tzs = new HashMap<String,
TimeZone>(TIME_ZONES);
+ tzs.put(ID, tz);
+ TIME_ZONES = tzs;
+ }
+ }
+ }
+ return tz;
+ }
}
Added: kernel/branches/2.2.x/patch/2.2.11-GA/KER-178/readme.txt
===================================================================
--- kernel/branches/2.2.x/patch/2.2.11-GA/KER-178/readme.txt (rev
0)
+++ kernel/branches/2.2.x/patch/2.2.11-GA/KER-178/readme.txt 2011-11-02 07:12:52 UTC (rev
5141)
@@ -0,0 +1,63 @@
+Summary
+
+ * Status: Provide a Util method to give an alternative to TimeZone.getTimeZone with
less contention
+ * CCP Issue: CCP-1118. Product Jira Issue: KER-178.
+ * Complexity: Low
+
+The Proposal
+Problem description
+
+What is the problem to fix?
+Under heavy load we realized that the method java.util.TimeZone.getTimeZone(String ID)
becomes a bottleneck so it is necessary to give an alternative with less contention as
possible.
+
+Fix description
+
+How is the problem fixed?
+
+* Avoid the usage of method java.util.TimeZone.getTimeZone(String ID). We use now a less
synchronized method implemented in kernel project instead.
+
+Patch file: KER-178.patch
+
+Tests to perform
+
+Reproduction test
+ * Activate the Concurrent GC during run of benchmark
+
+Tests performed at DevLevel
+ * Functional testing for all projects (kernel, core, ws, jcr)
+
+Tests performed at QA/Support Level
+*
+
+Documentation changes
+
+Documentation changes:
+ * No
+
+Configuration changes
+
+Configuration changes:
+ * No
+
+Will previous configuration continue to work?
+ * Yes
+
+Risks and impacts
+
+Can this bug fix have any side effects on current client projects?
+
+ * No
+
+Is there a performance risk/cost?
+ * No
+
+Validation (PM/Support/QA)
+
+PM Comment
+* PM validated
+
+Support Comment
+*
+
+QA Feedbacks
+*
Show replies by date