Author: norman Date: Mon May 10 12:17:50 2010 New Revision: 942717 URL: http://svn.apache.org/viewvc?rev=942717&view=rev Log: Set the lock timeout via sql because of a bug in openjpa in conjunction with h2 database update h2
Modified: james/imap/trunk/deployment/src/test/java/org/apache/james/imap/functional/AbstractStressTest.java james/imap/trunk/deployment/src/test/java/org/apache/james/imap/functional/jpa/JPAStressTest.java james/imap/trunk/parent/pom.xml Modified: james/imap/trunk/deployment/src/test/java/org/apache/james/imap/functional/AbstractStressTest.java URL: http://svn.apache.org/viewvc/james/imap/trunk/deployment/src/test/java/org/apache/james/imap/functional/AbstractStressTest.java?rev=942717&r1=942716&r2=942717&view=diff ============================================================================== --- james/imap/trunk/deployment/src/test/java/org/apache/james/imap/functional/AbstractStressTest.java (original) +++ james/imap/trunk/deployment/src/test/java/org/apache/james/imap/functional/AbstractStressTest.java Mon May 10 12:17:50 2010 @@ -36,13 +36,15 @@ import org.junit.Test; public abstract class AbstractStressTest { + private final static int APPEND_OPERATIONS = 1000; + protected abstract StoreMailboxManager<?> getMailboxManager(); @Test public void testStessTest() throws InterruptedException, MailboxException { - final CountDownLatch latch = new CountDownLatch(1000); - final ExecutorService pool = Executors.newFixedThreadPool(500); + final CountDownLatch latch = new CountDownLatch(APPEND_OPERATIONS); + final ExecutorService pool = Executors.newFixedThreadPool(APPEND_OPERATIONS/2); MailboxSession session = getMailboxManager().createSystemSession("test", new SimpleLog("Test")); getMailboxManager().startProcessingRequest(session); @@ -52,7 +54,7 @@ public abstract class AbstractStressTest final AtomicBoolean fail = new AtomicBoolean(false); // fire of 1000 append operations - for (int i = 0 ; i < 1000; i++) { + for (int i = 0 ; i < APPEND_OPERATIONS; i++) { pool.execute(new Runnable() { public void run() { Modified: james/imap/trunk/deployment/src/test/java/org/apache/james/imap/functional/jpa/JPAStressTest.java URL: http://svn.apache.org/viewvc/james/imap/trunk/deployment/src/test/java/org/apache/james/imap/functional/jpa/JPAStressTest.java?rev=942717&r1=942716&r2=942717&view=diff ============================================================================== --- james/imap/trunk/deployment/src/test/java/org/apache/james/imap/functional/jpa/JPAStressTest.java (original) +++ james/imap/trunk/deployment/src/test/java/org/apache/james/imap/functional/jpa/JPAStressTest.java Mon May 10 12:17:50 2010 @@ -20,6 +20,7 @@ package org.apache.james.imap.functional import java.util.HashMap; +import javax.persistence.EntityManager; import javax.persistence.EntityManagerFactory; import org.apache.commons.logging.impl.SimpleLog; @@ -41,7 +42,8 @@ public class JPAStressTest extends Abstr private OpenJPAMailboxManager mailboxManager; - + private long locktimeout = 60000; + private EntityManagerFactory entityManagerFactory; @Before public void setUp() { @@ -59,19 +61,27 @@ public class JPAStressTest extends Abstr "org.apache.james.imap.jpa.mail.model.JPAMessage;" + "org.apache.james.imap.jpa.mail.model.JPAProperty;" + "org.apache.james.imap.jpa.user.model.JPASubscription)"); - /* - // persimistic locking.. - properties.put("openjpa.LockManager", "pessimistic"); - properties.put("openjpa.ReadLockLevel", "read"); - properties.put("openjpa.WriteLockLevel", "write"); - properties.put("openjpa.jdbc.TransactionIsolation", "repeatable-read"); - */ - EntityManagerFactory entityManagerFactory = OpenJPAPersistence.getEntityManagerFactory(properties); + properties.put("openjpa.LockTimeout", locktimeout + ""); + + entityManagerFactory = OpenJPAPersistence.getEntityManagerFactory(properties); MailboxSessionEntityManagerFactory emf = new MailboxSessionEntityManagerFactory(entityManagerFactory); mailboxManager = new OpenJPAMailboxManager(null, new JPASubscriptionManager(emf), emf); + + // Set the lock timeout via SQL because of a bug in openJPA + // https://issues.apache.org/jira/browse/OPENJPA-1656 + setH2LockTimeout(); } + private void setH2LockTimeout() { + EntityManager manager = entityManagerFactory.createEntityManager(); + manager.getTransaction().begin(); + manager.createNativeQuery("SET DEFAULT_LOCK_TIMEOUT " + locktimeout).executeUpdate(); + manager.getTransaction().commit(); + manager.close(); + } + + @After public void tearDown() { MailboxSession session = mailboxManager.createSystemSession("test", new SimpleLog("Test")); Modified: james/imap/trunk/parent/pom.xml URL: http://svn.apache.org/viewvc/james/imap/trunk/parent/pom.xml?rev=942717&r1=942716&r2=942717&view=diff ============================================================================== --- james/imap/trunk/parent/pom.xml (original) +++ james/imap/trunk/parent/pom.xml Mon May 10 12:17:50 2010 @@ -406,7 +406,7 @@ <dependency> <groupId>com.h2database</groupId> <artifactId>h2</artifactId> - <version>1.0.79</version> + <version>1.2.134</version> <scope>test</scope> </dependency> <dependency> --------------------------------------------------------------------- To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org For additional commands, e-mail: server-dev-h...@james.apache.org