svn commit: r537213 - /incubator/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/TestOptimizeForClause.java
Author: wisneskid Date: Fri May 11 08:44:13 2007 New Revision: 537213 URL: http://svn.apache.org/viewvc?view=revrev=537213 Log: OpenJPA 168 testcase Added: incubator/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/TestOptimizeForClause.java Added: incubator/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/TestOptimizeForClause.java URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/TestOptimizeForClause.java?view=autorev=537213 == --- incubator/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/TestOptimizeForClause.java (added) +++ incubator/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/TestOptimizeForClause.java Fri May 11 08:44:13 2007 @@ -0,0 +1,112 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * License); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.openjpa.persistence.jdbc; + +import javax.persistence.Query; + +import org.apache.openjpa.persistence.test.SQLListenerTestCase; +import org.apache.openjpa.persistence.simple.AllFieldTypes; +import org.apache.openjpa.persistence.OpenJPAPersistence; +import org.apache.openjpa.persistence.OpenJPAEntityManager; +import org.apache.openjpa.persistence.OpenJPAQuery; +import org.apache.openjpa.persistence.InvalidStateException; +import org.apache.openjpa.jdbc.sql.DBDictionary; +import org.apache.openjpa.jdbc.sql.DB2Dictionary; +import org.apache.openjpa.jdbc.sql.HSQLDictionary; +import org.apache.openjpa.jdbc.conf.JDBCConfiguration; + +public class TestOptimizeForClause +extends SQLListenerTestCase { + +public void setUp() { +setUp(AllFieldTypes.class); +} + +public void testOptimizeForClauseViaHint() { +testOptimizeForClause(true,false,false); +} + +public void testOptimizeForClauseViaFind() { +testOptimizeForClause(false,true,false); +} +public void testOptimizeForClauseViaQueryHint() { +testOptimizeForClause(false,true,true); +} +public void testOptimizeForClause(boolean hint, +boolean find, boolean queryHint) { +OpenJPAEntityManager em = +OpenJPAPersistence.cast(emf.createEntityManager()); +DBDictionary dict = ((JDBCConfiguration) em.getConfiguration()) +.getDBDictionaryInstance(); + +// hsql doesn't support optimizing; circumvent the test +if (dict instanceof HSQLDictionary) +return; + +sql.clear(); +try { +em.getTransaction().begin(); +if (hint || queryHint) { +if (hint) { +Query q = em.createQuery( +select o from AllFieldTypes o where o.intField = :p); +q.setParameter(p, 0); +q.setHint(openjpa.hint.OptimizeResultCount + ,new Integer(8)); +q.getResultList(); +} +else { +OpenJPAQuery q = OpenJPAPersistence.cast (em.createQuery +(select o from AllFieldTypes o where o.intField + + = :p)); +q.setParameter(p, 0); +q.setHint(q.HINT_RESULT_COUNT, new Integer(8)); +q.getResultList(); + } + if (dict instanceof DB2Dictionary) { + assertEquals(1, sql.size()); + assertSQL(SELECT t0.id, t0.booleanField, t0.byteField, + +t0.charField, t0.dateField, t0.doubleField, + + t0.floatField, t0.intField, t0.longField, + + t0.shortField, t0.stringField FROM AllFieldTypes + + t0 WHERE \\(t0.intField = \\?\\) optimize for 8 row); + } +} +else { + em.find(AllFieldTypes.class, 0); + if (dict instanceof DB2Dictionary ) { +assertEquals(1, sql.size()); +assertSQL(SELECT
svn commit: r537227 - /incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/event/TCPRemoteCommitProvider.java
Author: pcl Date: Fri May 11 09:37:15 2007 New Revision: 537227 URL: http://svn.apache.org/viewvc?view=revrev=537227 Log: OPENJPA-230. Fixed dependency on not-yet-checked-in class. Modified: incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/event/TCPRemoteCommitProvider.java Modified: incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/event/TCPRemoteCommitProvider.java URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/event/TCPRemoteCommitProvider.java?view=diffrev=537227r1=537226r2=537227 == --- incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/event/TCPRemoteCommitProvider.java (original) +++ incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/event/TCPRemoteCommitProvider.java Fri May 11 09:37:15 2007 @@ -51,7 +51,6 @@ import org.apache.openjpa.util.InternalException; import org.apache.openjpa.util.Serialization; import org.apache.openjpa.lib.util.concurrent.ReentrantLock; -import org.apache.openjpa.lib.util.concurrent.Concurrent; import serp.util.Strings;
svn commit: r537221 - /incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/event/TCPRemoteCommitProvider.java
Author: pcl Date: Fri May 11 09:12:07 2007 New Revision: 537221 URL: http://svn.apache.org/viewvc?view=revrev=537221 Log: OPENJPA-230. Updated patch based on an out-of-band patch from Vishal. This version avoids interrupts while still handling guaranteed delivery of messages in the queue. Modified: incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/event/TCPRemoteCommitProvider.java Modified: incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/event/TCPRemoteCommitProvider.java URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/event/TCPRemoteCommitProvider.java?view=diffrev=537221r1=537220r2=537221 == --- incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/event/TCPRemoteCommitProvider.java (original) +++ incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/event/TCPRemoteCommitProvider.java Fri May 11 09:12:07 2007 @@ -25,7 +25,6 @@ import java.io.InputStream; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; -import java.io.OptionalDataException; import java.io.OutputStream; import java.net.InetAddress; import java.net.ServerSocket; @@ -40,6 +39,8 @@ import java.util.LinkedList; import java.util.Map; import java.util.Set; +import java.util.List; +import java.util.Collections; import org.apache.commons.pool.PoolableObjectFactory; import org.apache.commons.pool.impl.GenericObjectPool; @@ -50,6 +51,7 @@ import org.apache.openjpa.util.InternalException; import org.apache.openjpa.util.Serialization; import org.apache.openjpa.lib.util.concurrent.ReentrantLock; +import org.apache.openjpa.lib.util.concurrent.Concurrent; import serp.util.Strings; @@ -68,14 +70,14 @@ private static final int DEFAULT_PORT = 5636; -private static Localizer s_loc = Localizer.forPackage +private static final Localizer s_loc = Localizer.forPackage (TCPRemoteCommitProvider.class); private static long s_idSequence = System.currentTimeMillis(); // A map of listen ports to listeners in this JVM. We might // want to look into allowing same port, different interface -- // that is not currently possible in a single JVM. -private static Map s_portListenerMap = new HashMap(); +private static final Map s_portListenerMap = new HashMap(); private long _id; private byte[] _localhost; @@ -85,7 +87,8 @@ private int _recoveryTimeMillis = 15000; private TCPPortListener _listener; private BroadcastQueue _broadcastQueue = new BroadcastQueue(); -private LinkedList _broadcastThreads = new LinkedList(); +private final List _broadcastThreads = Collections.synchronizedList( +new LinkedList()); private ArrayList _addresses = new ArrayList(); private ReentrantLock _addressesLock; @@ -177,7 +180,7 @@ // Threads will not end until they send another pk. for (int i = numBroadcastThreads; i cur; i++) { BroadcastWorkerThread worker = (BroadcastWorkerThread) -_broadcastThreads.removeFirst(); +_broadcastThreads.remove(0); worker.setRunning(false); } } else if (cur numBroadcastThreads) { @@ -186,7 +189,7 @@ BroadcastWorkerThread wt = new BroadcastWorkerThread(); wt.setDaemon(true); wt.start(); -_broadcastThreads.addLast(wt); +_broadcastThreads.add(wt); } } } @@ -364,6 +367,18 @@ if (_listener != null) _listener.removeProvider(this); +// Remove Broadcast Threads then close sockets. +_broadcastQueue.close(); + +// Wait for _broadcastThreads to get cleaned up. +while(!_broadcastThreads.isEmpty()) { +try { +Thread.sleep(500); +} catch (InterruptedException ie) { +// Ignore. +} +} + _addressesLock.lock(); try { for (Iterator iter = _addresses.iterator(); iter.hasNext();) @@ -371,16 +386,6 @@ } finally { _addressesLock.unlock(); } - -// We are done transmitting. Interrupt any worker threads. -synchronized (_broadcastThreads) { -Thread worker; -for (Iterator iter = _broadcastThreads.iterator(); -iter.hasNext();) { -worker = (Thread) iter.next(); -worker.interrupt(); -} -} } /** @@ -390,18 +395,38 @@ */ private static class BroadcastQueue { -LinkedList _packetQueue = new LinkedList(); +private LinkedList _packetQueue = new LinkedList(); +private boolean _closed
[continuum] BUILD FAILURE: OpenJPA Kernel
Online report : http://vmbuild.apache.org/continuum/servlet/continuum/target/ProjectBuild.vm/view/ProjectBuild/id/82/buildId/142804 Build statistics: State: Failed Previous State: Ok Started at: Fri, 11 May 2007 09:34:43 -0700 Finished at: Fri, 11 May 2007 09:35:13 -0700 Total time: 30s Build Trigger: Schedule Exit code: 1 Building machine hostname: vmbuild.apache.org Operating system : Linux(unknown) Java version : 1.5.0_06(Sun Microsystems Inc.) Changes pcl OPENJPA-230. Updated patch based on an out-of-band patch from Vishal. This version avoids interrupts while still handling guaranteed delivery of messages in the queue. /incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/event/TCPRemoteCommitProvider.java Output: [INFO] Scanning for projects... [INFO] [INFO] Building OpenJPA Kernel [INFO]task-segment: [clean, install] [INFO] [INFO] [clean:clean] [INFO] Deleting directory /x1/continuum/working-directory/82/target [INFO] Deleting directory /x1/continuum/working-directory/82/target/classes [INFO] Deleting directory /x1/continuum/working-directory/82/target/test-classes [INFO] [javacc:jjtree {execution: jjtree-jpql}] Java Compiler Compiler Version 4.0 (Tree Builder) (type jjtree with no arguments for help) Reading from file /x1/continuum/working-directory/82/src/main/jjtree/org/apache/openjpa/kernel/jpql/JPQL.jjt . . . File /x1/continuum/working-directory/82/target/generated-sources/jjtree/org/apache/openjpa/kernel/jpql/Node.java does not exist. Will create one. Annotated grammar generated successfully in /x1/continuum/working-directory/82/target/generated-sources/jjtree/org/apache/openjpa/kernel/jpql/JPQL.jj [INFO] [javacc:javacc {execution: javacc-jpql}] Java Compiler Compiler Version 4.0 (Parser Generator) (type javacc with no arguments for help) Reading from file /x1/continuum/working-directory/82/target/generated-sources/jjtree/org/apache/openjpa/kernel/jpql/JPQL.jj . . . Warning: Choice conflict in (...)* construct at line 856, column 17. Expansion nested within construct and expansion following construct have common prefixes, one of which is: + Consider using a lookahead of 2 or more for nested expansion. Warning: Choice conflict in (...)* construct at line 865, column 17. Expansion nested within construct and expansion following construct have common prefixes, one of which is: * Consider using a lookahead of 2 or more for nested expansion. File TokenMgrError.java does not exist. Will create one. File ParseException.java does not exist. Will create one. File Token.java does not exist. Will create one. File JavaCharStream.java does not exist. Will create one. Parser generated with 0 errors and 2 warnings. [INFO] snapshot org.apache.openjpa:openjpa-lib:0.9.8-incubating-SNAPSHOT: checking for updates from central [INFO] [antrun:run {execution: default}] [INFO] Executing tasks [delete] Deleting: /x1/continuum/working-directory/82/target/generated-sources/javacc/org/apache/openjpa/kernel/jpql/ParseException.java [INFO] Executed tasks [INFO] [resources:resources] [INFO] Using default encoding to copy filtered resources. [INFO] [compiler:compile] Compiling 388 source files to /x1/continuum/working-directory/82/target/classes [INFO] [ERROR] BUILD FAILURE [INFO] [INFO] Compilation failure /x1/continuum/working-directory/82/src/main/java/org/apache/openjpa/event/TCPRemoteCommitProvider.java:[54,46] cannot find symbol symbol : class Concurrent location: package org.apache.openjpa.lib.util.concurrent [INFO] [INFO] For more information, run Maven with the -e switch [INFO] [INFO] Total time: 27 seconds [INFO] Finished at: Fri May 11 09:35:12 PDT 2007 [INFO] Final Memory: 8M/41M [INFO]
[continuum] BUILD SUCCESSFUL: OpenJPA Kernel
Online report : http://vmbuild.apache.org/continuum/servlet/continuum/target/ProjectBuild.vm/view/ProjectBuild/id/82/buildId/142860 Build statistics: State: Ok Previous State: Failed Started at: Fri, 11 May 2007 10:06:46 -0700 Finished at: Fri, 11 May 2007 10:07:34 -0700 Total time: 47s Build Trigger: Schedule Exit code: 0 Building machine hostname: vmbuild.apache.org Operating system : Linux(unknown) Java version : 1.5.0_06(Sun Microsystems Inc.) Changes pcl OPENJPA-230. Fixed dependency on not-yet-checked-in class. /incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/event/TCPRemoteCommitProvider.java Output: [INFO] Scanning for projects... [INFO] [INFO] Building OpenJPA Kernel [INFO]task-segment: [clean, install] [INFO] [INFO] [clean:clean] [INFO] Deleting directory /x1/continuum/working-directory/82/target [INFO] Deleting directory /x1/continuum/working-directory/82/target/classes [INFO] Deleting directory /x1/continuum/working-directory/82/target/test-classes [INFO] [javacc:jjtree {execution: jjtree-jpql}] Java Compiler Compiler Version 4.0 (Tree Builder) (type jjtree with no arguments for help) Reading from file /x1/continuum/working-directory/82/src/main/jjtree/org/apache/openjpa/kernel/jpql/JPQL.jjt . . . File /x1/continuum/working-directory/82/target/generated-sources/jjtree/org/apache/openjpa/kernel/jpql/Node.java does not exist. Will create one. Annotated grammar generated successfully in /x1/continuum/working-directory/82/target/generated-sources/jjtree/org/apache/openjpa/kernel/jpql/JPQL.jj [INFO] [javacc:javacc {execution: javacc-jpql}] Java Compiler Compiler Version 4.0 (Parser Generator) (type javacc with no arguments for help) Reading from file /x1/continuum/working-directory/82/target/generated-sources/jjtree/org/apache/openjpa/kernel/jpql/JPQL.jj . . . Warning: Choice conflict in (...)* construct at line 856, column 17. Expansion nested within construct and expansion following construct have common prefixes, one of which is: + Consider using a lookahead of 2 or more for nested expansion. Warning: Choice conflict in (...)* construct at line 865, column 17. Expansion nested within construct and expansion following construct have common prefixes, one of which is: * Consider using a lookahead of 2 or more for nested expansion. File TokenMgrError.java does not exist. Will create one. File ParseException.java does not exist. Will create one. File Token.java does not exist. Will create one. File JavaCharStream.java does not exist. Will create one. Parser generated with 0 errors and 2 warnings. [INFO] [antrun:run {execution: default}] [INFO] Executing tasks [delete] Deleting: /x1/continuum/working-directory/82/target/generated-sources/javacc/org/apache/openjpa/kernel/jpql/ParseException.java [INFO] Executed tasks [INFO] [resources:resources] [INFO] Using default encoding to copy filtered resources. [INFO] [compiler:compile] Compiling 388 source files to /x1/continuum/working-directory/82/target/classes [INFO] [antrun:run {execution: add-was-interfaces}] [INFO] Executing tasks [INFO] Executed tasks [INFO] [antrun:run {execution: generate-standard-sco-proxies}] [INFO] Executing tasks org.apache.openjpa.util.java$sql$Date$proxy org.apache.openjpa.util.java$sql$Time$proxy org.apache.openjpa.util.java$sql$Timestamp$proxy org.apache.openjpa.util.java$util$ArrayList$proxy org.apache.openjpa.util.java$util$Date$proxy org.apache.openjpa.util.java$util$GregorianCalendar$proxy org.apache.openjpa.util.java$util$HashMap$proxy org.apache.openjpa.util.java$util$HashSet$proxy org.apache.openjpa.util.java$util$Hashtable$proxy org.apache.openjpa.util.java$util$LinkedList$proxy org.apache.openjpa.util.java$util$Properties$proxy org.apache.openjpa.util.java$util$TreeMap$proxy org.apache.openjpa.util.java$util$TreeSet$proxy org.apache.openjpa.util.java$util$Vector$proxy org.apache.openjpa.util.java$util$EnumMap$proxy org.apache.openjpa.util.java$util$IdentityHashMap$proxy org.apache.openjpa.util.java$util$LinkedHashMap$proxy org.apache.openjpa.util.java$util$LinkedHashSet$proxy org.apache.openjpa.util.java$util$PriorityQueue$proxy [INFO] Executed tasks [INFO] [resources:testResources] [INFO] Using default encoding to copy filtered resources. [INFO] [compiler:testCompile] Compiling 2 source files to /x1/continuum/working-directory/82/target/test-classes [INFO] [surefire:test] [INFO] Surefire report directory: /x1/continuum/working-directory/82/target/surefire-reports --- T E S T S