You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by jo...@apache.org on 2017/01/04 21:50:30 UTC

[2/2] ambari git commit: AMBARI-19364 - Investigate Changing the Default Container Policy in JPA From Vector to ArrayList (jonathanhurley)

AMBARI-19364 - Investigate Changing the Default Container Policy in JPA From Vector to ArrayList (jonathanhurley)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/82a64e49
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/82a64e49
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/82a64e49

Branch: refs/heads/trunk
Commit: 82a64e4985607a961857d74773362e6bf7eb9858
Parents: f207b95
Author: Jonathan Hurley <jh...@hortonworks.com>
Authored: Wed Jan 4 11:49:23 2017 -0500
Committer: Jonathan Hurley <jh...@hortonworks.com>
Committed: Wed Jan 4 16:18:19 2017 -0500

----------------------------------------------------------------------
 .../server/orm/EclipseLinkSessionCustomizer.java    | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/82a64e49/ambari-server/src/main/java/org/apache/ambari/server/orm/EclipseLinkSessionCustomizer.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/orm/EclipseLinkSessionCustomizer.java b/ambari-server/src/main/java/org/apache/ambari/server/orm/EclipseLinkSessionCustomizer.java
index 6717e01..50ed09e 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/orm/EclipseLinkSessionCustomizer.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/orm/EclipseLinkSessionCustomizer.java
@@ -17,9 +17,13 @@
  */
 package org.apache.ambari.server.orm;
 
+import java.util.ArrayList;
+
 import javax.activation.DataSource;
 
+import org.eclipse.persistence.config.PersistenceUnitProperties;
 import org.eclipse.persistence.config.SessionCustomizer;
+import org.eclipse.persistence.internal.queries.ContainerPolicy;
 import org.eclipse.persistence.sessions.DatabaseLogin;
 import org.eclipse.persistence.sessions.JNDIConnector;
 import org.eclipse.persistence.sessions.Session;
@@ -57,5 +61,17 @@ public class EclipseLinkSessionCustomizer implements SessionCustomizer {
     // ensure db behavior is same as shared cache
     DatabaseLogin databaseLogin = (DatabaseLogin) session.getDatasourceLogin();
     databaseLogin.setTransactionIsolation(DatabaseLogin.TRANSACTION_READ_COMMITTED);
+
+    // read-all queries use a Vector as their container for
+    // result items - this seems like an unnecessary performance hit since
+    // Vectors are synchronized and there's no apparent reason to provide a
+    // thread-safe collection on a read all query
+    // see: https://bugs.eclipse.org/bugs/show_bug.cgi?id=255634
+    Object ddlGeneration = session.getProperty(PersistenceUnitProperties.DDL_GENERATION);
+    if (null == ddlGeneration || PersistenceUnitProperties.NONE.equals(ddlGeneration)) {
+      // only set this when not using DDL generation - Sequence generation hard
+      // codes Vector
+      ContainerPolicy.setDefaultContainerClass(ArrayList.class);
+    }
   }
 }