Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 16E30200C01 for ; Thu, 5 Jan 2017 00:04:00 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 15AD6160B3A; Wed, 4 Jan 2017 23:04:00 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 72A55160B4A for ; Thu, 5 Jan 2017 00:03:59 +0100 (CET) Received: (qmail 10000 invoked by uid 500); 4 Jan 2017 23:03:58 -0000 Mailing-List: contact issues-help@ambari.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ambari.apache.org Delivered-To: mailing list issues@ambari.apache.org Received: (qmail 9955 invoked by uid 99); 4 Jan 2017 23:03:58 -0000 Received: from arcas.apache.org (HELO arcas) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 04 Jan 2017 23:03:58 +0000 Received: from arcas.apache.org (localhost [127.0.0.1]) by arcas (Postfix) with ESMTP id 6B0E12C1F5A for ; Wed, 4 Jan 2017 23:03:58 +0000 (UTC) Date: Wed, 4 Jan 2017 23:03:58 +0000 (UTC) From: "Hudson (JIRA)" To: issues@ambari.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (AMBARI-19364) Investigate Changing the Default Container Policy in JPA From Vector to ArrayList MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Wed, 04 Jan 2017 23:04:00 -0000 [ https://issues.apache.org/jira/browse/AMBARI-19364?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15799633#comment-15799633 ] Hudson commented on AMBARI-19364: --------------------------------- SUCCESS: Integrated in Jenkins build Ambari-trunk-Commit #6355 (See [https://builds.apache.org/job/Ambari-trunk-Commit/6355/]) AMBARI-19364 - Investigate Changing the Default Container Policy in JPA (jhurley: [http://git-wip-us.apache.org/repos/asf?p=ambari.git&a=commit&h=82a64e4985607a961857d74773362e6bf7eb9858]) * (edit) ambari-server/src/main/java/org/apache/ambari/server/orm/EclipseLinkSessionCustomizer.java > Investigate Changing the Default Container Policy in JPA From Vector to ArrayList > --------------------------------------------------------------------------------- > > Key: AMBARI-19364 > URL: https://issues.apache.org/jira/browse/AMBARI-19364 > Project: Ambari > Issue Type: Task > Components: ambari-server > Affects Versions: trunk > Reporter: Jonathan Hurley > Assignee: Jonathan Hurley > Fix For: trunk > > Attachments: AMBARI-19364.patch > > > Recently I noticed that collections coming back from JPA were using a {{Vector}} as their concrete collection. This seems very wrong as {{Vector}} is a completely synchronized collection. > Tracing through EclipseLink, it seems like this really only affects [ReadAllQuery|http://grepcode.com/file/repo1.maven.org/maven2/org.eclipse.persistence/eclipselink/2.5.2/org/eclipse/persistence/queries/ReadAllQuery.java/#68]. Essentially, EclipseLink uses a [ContainerPolicy|http://grepcode.com/file/repo1.maven.org/maven2/org.eclipse.persistence/eclipselink/2.5.2/org/eclipse/persistence/internal/queries/ContainerPolicy.java#ContainerPolicy] to determine how the result set should be collected. There are policies for {{Vector}}, {{ArrayList}}, {{HashSet}}, etc. > The interesting part here is that this really only affects the {{ReadAllQuery}} which is used by JPA's {{Query#getResultList()}} ... anytime it needs to create a collection of entities, it's going to use a {{Vector}}. > There's actually very little documentation on this. In fact, the only way to change this is either set a global value for the default container policy, or set a per-query policy. An example of setting the global policy would be: > {code} > public class EclipseLinkSessionCustomizer implements SessionCustomizer { > /** > * {@inheritDoc} > *

> * This class exists for quick customization purposes. > */ > @Override > public void customize(Session session) throws Exception { > // ensure db behavior is same as shared cache > DatabaseLogin databaseLogin = (DatabaseLogin) session.getDatasourceLogin(); > databaseLogin.setTransactionIsolation(DatabaseLogin.TRANSACTION_READ_COMMITTED); > // for some reason, 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 > ContainerPolicy.setDefaultContainerClass(CoreClassConstants.ArrayList_class); > } > } > {code} > This indeed causes collections returned by queries to be backed by ArrayLists. > There is some discussion on this topic already: > https://bugs.eclipse.org/bugs/show_bug.cgi?id=255634 > It seems like this was kept as a {{Vector}} purely for backward compatibility reasons. -- This message was sent by Atlassian JIRA (v6.3.4#6332)