Return-Path: Delivered-To: apmail-db-jdo-dev-archive@www.apache.org Received: (qmail 92890 invoked from network); 8 Jun 2005 16:10:00 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 8 Jun 2005 16:10:00 -0000 Received: (qmail 37289 invoked by uid 500); 8 Jun 2005 16:10:00 -0000 Mailing-List: contact jdo-dev-help@db.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: jdo-dev@db.apache.org Delivered-To: mailing list jdo-dev@db.apache.org Received: (qmail 37130 invoked by uid 99); 8 Jun 2005 16:09:55 -0000 X-ASF-Spam-Status: No, hits=0.6 required=10.0 tests=HTML_20_30,HTML_MESSAGE,HTML_TITLE_EMPTY X-Spam-Check-By: apache.org Received-SPF: pass (hermes.apache.org: local policy) Received: from brmea-mail-4.Sun.COM (HELO brmea-mail-4.sun.com) (192.18.98.36) by apache.org (qpsmtpd/0.28) with ESMTP; Wed, 08 Jun 2005 09:09:54 -0700 Received: from phys-mpk-1 ([129.146.11.81]) by brmea-mail-4.sun.com (8.12.10/8.12.9) with ESMTP id j58G9aau013002 for ; Wed, 8 Jun 2005 10:09:36 -0600 (MDT) Received: from conversion-daemon.mpk-mail1.sfbay.sun.com by mpk-mail1.sfbay.sun.com (iPlanet Messaging Server 5.2 HotFix 1.24 (built Dec 19 2003)) id <0IHR00901VH2ZK@mpk-mail1.sfbay.sun.com> (original mail from Michelle.Caisse@Sun.COM) for jdo-dev@db.apache.org; Wed, 08 Jun 2005 09:09:36 -0700 (PDT) Received: from [129.150.28.157] (vpn-129-150-28-157.SFBay.Sun.COM [129.150.28.157]) by mpk-mail1.sfbay.sun.com (iPlanet Messaging Server 5.2 HotFix 1.24 (built Dec 19 2003)) with ESMTP id <0IHR00HMCWRQ4L@mpk-mail1.sfbay.sun.com> for jdo-dev@db.apache.org; Wed, 08 Jun 2005 09:07:03 -0700 (PDT) Date: Wed, 08 Jun 2005 09:12:50 -0700 From: Michelle Caisse Subject: Re: Patch for JIRA JDO-13 In-reply-to: <42A6EAD0.3030808@spree.de> To: jdo-dev@db.apache.org Message-id: <42A71902.70200@sun.com> MIME-version: 1.0 Content-type: multipart/alternative; boundary="Boundary_(ID_crLE2SpUnbDE3lj1Iz/nAQ)" X-Accept-Language: en-us, en User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.2) Gecko/20040803 References: <42A6EAD0.3030808@spree.de> X-Virus-Checked: Checked X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N --Boundary_(ID_crLE2SpUnbDE3lj1Iz/nAQ) Content-type: text/plain; charset=us-ascii; format=flowed Content-transfer-encoding: 7BIT I have checked in this patch. Thank you! -- Michelle Michael Watzek wrote: > Hi, > > please find the patch for JIRA JDO-13 attached. I ran the TCK > including this patch and including the changes checked in by Michelle > yesterday: > > Datastore identity: > Tests run: 345, Failures: 12, Errors: 78 (783 seconds) > > Application identity: > Tests run: 345, Failures: 12, Errors: 79 (745 seconds) > > This is a big performance improvement! Before setting > "org.jpox.autoStartMechanism=None" each TCK run took about 6000 seconds. > > Thanks, > Michael > > Below, I listed the changes of this patch: > > 0) schema1.sql > 0.1) The PK constraint name "ICNP_PK" of table "STATETRANSITIONOBJ" is > changed. This constraint name existed already. > > 1) PMsCanSharePCClassesButNotPCInstances.java > 1.1) Method "test" is split into two methods "testSharedPC()" and > "testNonSharedPC()". > 1.2) A check for uncaught exceptions is added causing a test to fail > or throw a JDOFatalException in case of failures or errors. Without > this check both tests would always succeed, even if there are failures > and/or errors. > 1.3) The call for increasing the counter for thread synchronization is > moved into a finally block. > 1.4) The call "pm.getExtent" is executed inside a transaction due to > non-transactional read exception. > > 2) StateTransitionObj.java > 2.1) A private static field "counter" is added. > 2.2) A private field "id" is added. This is the PK field in case of > application identity. > 2.3) The no-arg constructor sets field "id to "++counter". > 2.4) The second constructor calls "this()"; > 2.5) Getter/setter for field "id" are added. > 2.6) A public static class "Oid" is added. This class is the object id > class in case of application identity. > > 3) alltests.list > 3.1) Class "PMsCanSharePCClassesButNotPCInstances" is added. > > 4) StateTransitionObj.jdo (for application identity) > 4.1) An attribute "objectid-class" is added to class > "StateTransitionObj". > > >------------------------------------------------------------------------ > >Index: test/sql/derby/schema1.sql >=================================================================== >--- test/sql/derby/schema1.sql (revision 189565) >+++ test/sql/derby/schema1.sql (working copy) >@@ -7082,7 +7082,7 @@ > CREATE TABLE STATETRANSITIONOBJ ( > ID INTEGER NOT NULL, > INT_FIELD INTEGER NOT NULL, >- CONSTRAINT ICNP_PK PRIMARY KEY (ID) >+ CONSTRAINT STOBJ_PK PRIMARY KEY (ID) > ); > > disconnect; >Index: test/java/org/apache/jdo/tck/lifecycle/PMsCanSharePCClassesButNotPCInstances.java >=================================================================== >--- test/java/org/apache/jdo/tck/lifecycle/PMsCanSharePCClassesButNotPCInstances.java (revision 189565) >+++ test/java/org/apache/jdo/tck/lifecycle/PMsCanSharePCClassesButNotPCInstances.java (working copy) >@@ -16,9 +16,20 @@ > > package org.apache.jdo.tck.lifecycle; > >-import java.util.*; >-import javax.jdo.*; >+import java.util.Collection; >+import java.util.Iterator; >+import java.util.Map; > >+import javax.jdo.Extent; >+import javax.jdo.JDOException; >+import javax.jdo.JDOFatalException; >+import javax.jdo.JDOHelper; >+import javax.jdo.PersistenceManager; >+import javax.jdo.PersistenceManagerFactory; >+import javax.jdo.Transaction; >+ >+import junit.framework.AssertionFailedError; >+ > import org.apache.jdo.tck.JDO_Test; > import org.apache.jdo.tck.pc.lifecycle.StateTransitionObj; > import org.apache.jdo.tck.util.BatchTestRunner; >@@ -74,14 +85,16 @@ > addTearDownClass(StateTransitionObj.class); > } > >- public void test() { >+ public void testSharedPC() { > // test shared PC - only one PM should succeed to insert the shared PC > threads = 0; > attempts = 0; > insertedCount = 0; > insertedCountExpected = 1; > insertObjects(true); >- >+ } >+ >+ public void testNonSharedPC() { > // test non-shared PCs - each PM should succeed to insert its own non-shared PC > threads = 0; > attempts = 0; >@@ -125,6 +138,19 @@ > logger.debug("interrupted while waiting for threads to finish"); > } > } >+ >+ Collection exceptions = threadGroup.getAllUncaughtExceptions(); >+ for (Iterator i = exceptions.iterator(); i.hasNext(); ) { >+ Map.Entry entry = (Map.Entry) i.next(); >+ Thread thread = (Thread)entry.getKey(); >+ Throwable throwable = (Throwable)entry.getValue(); >+ String message = "Uncaught exception " + throwable + " in thread " + thread; >+ if( throwable instanceof AssertionFailedError ) >+ fail(ASSERTION_FAILED, message); >+ else >+ throw new JDOFatalException(message, throwable); >+ } >+ > } > > synchronized void signal() { >@@ -176,10 +202,10 @@ > throw ex; > } > finally { >+ incrAttempts(); > if (tx != null && tx.isActive()) > tx.rollback(); > } >- incrAttempts(); > > while (!attemptsComplete()) { > try { >@@ -201,11 +227,13 @@ > int objCount = 0; > if (debug) > logger.debug("getting Extent of " + instanceClass.getName()); >+ tx.begin(); > Extent e = pm.getExtent(instanceClass, false); > for (Iterator i = e.iterator(); i.hasNext();) { > Object instance = (Object)i.next(); > objCount++; > } >+ tx.commit(); > > //Verify that the number of inserted objects matches the number of objects in the extent > if (insertedCount!=objCount) >Index: test/java/org/apache/jdo/tck/pc/lifecycle/StateTransitionObj.java >=================================================================== >--- test/java/org/apache/jdo/tck/pc/lifecycle/StateTransitionObj.java (revision 189565) >+++ test/java/org/apache/jdo/tck/pc/lifecycle/StateTransitionObj.java (working copy) >@@ -17,16 +17,23 @@ > > package org.apache.jdo.tck.pc.lifecycle; > >+import java.io.Serializable; >+ > public class StateTransitionObj { >+ private static int counter = 0; >+ >+ private int id; > private int int_field; > private transient int nonmanaged_field; > > public StateTransitionObj() > { >+ id = ++counter; > int_field = 0; > } > public StateTransitionObj(int v) > { >+ this(); > int_field = v; > } > public int readField() >@@ -46,4 +53,73 @@ > { > nonmanaged_field = value; > } >+ /** >+ * @return Returns the id. >+ */ >+ public int getId() { >+ return id; >+ } >+ /** >+ * @param id The id to set. >+ */ >+ public void setId(int id) { >+ this.id = id; >+ } >+ >+ /** >+ * The class to be used as the application identifier >+ * for the StateTransitionObj class. >+ */ >+ public static class Oid implements Serializable, Comparable { >+ >+ /** >+ * This field is part of the identifier and should match in name >+ * and type with a field in the StateTransitionObj class. >+ */ >+ public int id; >+ >+ /** The required public no-arg constructor. */ >+ public Oid() { } >+ >+ /** >+ * Initialize the identifier. >+ * @param companyid The id of the company. >+ */ >+ public Oid(int id) { >+ this.id = id; >+ } >+ >+ public Oid(String s) { id = Integer.parseInt(justTheId(s)); } >+ >+ public String toString() { return this.getClass().getName() + ": " + id;} >+ >+ >+ /** */ >+ public boolean equals(Object obj) { >+ if (obj==null || !this.getClass().equals(obj.getClass())) >+ return false; >+ Oid o = (Oid) obj; >+ if (this.id != o.id) >+ return false; >+ return true; >+ } >+ >+ /** */ >+ public int hashCode() { >+ return id; >+ } >+ >+ protected static String justTheId(String str) { >+ return str.substring(str.indexOf(':') + 1); >+ } >+ >+ /** */ >+ public int compareTo(Object obj) { >+ // may throw ClassCastException which the user must handle >+ Oid other = (Oid) obj; >+ return id - other.id; >+ } >+ >+ } >+ > } >Index: test/conf/alltests.list >=================================================================== >--- test/conf/alltests.list (revision 189565) >+++ test/conf/alltests.list (working copy) >@@ -171,6 +171,7 @@ > org.apache.jdo.tck.lifecycle.MultiplePMsReturnInstancesRepresentingSamePC \ > org.apache.jdo.tck.lifecycle.ObjectIdNotModifiedWhenObjectIdInstanceModified \ > org.apache.jdo.tck.lifecycle.PMReturnsIdenticalInstancesForEqualObjIds \ >+org.apache.jdo.tck.lifecycle.PMsCanSharePCClassesButNotPCInstances \ > org.apache.jdo.tck.lifecycle.StateTransitions \ > org.apache.jdo.tck.lifecycle.TransientTransactionalStateCommit \ > org.apache.jdo.tck.lifecycle.TransientTransactionalStateRollback \ >Index: test/jdo/applicationidentity/org/apache/jdo/tck/pc/lifecycle/StateTransitionObj.jdo >=================================================================== >--- test/jdo/applicationidentity/org/apache/jdo/tck/pc/lifecycle/StateTransitionObj.jdo (revision 189565) >+++ test/jdo/applicationidentity/org/apache/jdo/tck/pc/lifecycle/StateTransitionObj.jdo (working copy) >@@ -3,8 +3,10 @@ > > > >- >- >- >+ + identity-type="application" >+ objectid-class="org.apache.jdo.tck.pc.lifecycle.StateTransitionObj$Oid"> >+ >+ > > > > --Boundary_(ID_crLE2SpUnbDE3lj1Iz/nAQ)--