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".
--
-------------------------------------------------------------------
Michael Watzek [EMAIL PROTECTED] Engineering GmbH
mailto:[EMAIL PROTECTED] Buelowstr. 66
Tel.: ++49/30/235 520 36 10783 Berlin - Germany
Fax.: ++49/30/217 520 12 http://www.spree.de/
-------------------------------------------------------------------
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 <code>StateTransitionObj</code> 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 <code>StateTransitionObj</code> 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 @@
<jdo>
<package name="org.apache.jdo.tck.pc.lifecycle">
- <class name="StateTransitionObj" identity-type="application">
- <field name="int_field" primary-key="true"/>
- </class>
+ <class name="StateTransitionObj"
+ identity-type="application"
+
objectid-class="org.apache.jdo.tck.pc.lifecycle.StateTransitionObj$Oid">
+ <field name="id" primary-key="true"/>
+ </class>
</package>
</jdo>