[jboss-svn-commits] JBL Code SVN: r31582 - in labs/jbosstm/workspace/whitingjr/trunk/performance/src/test/java/org/jboss/jbossts/performance: task and 1 other directory.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Thu Feb 11 15:10:58 EST 2010


Author: whitingjr
Date: 2010-02-11 15:10:57 -0500 (Thu, 11 Feb 2010)
New Revision: 31582

Modified:
   labs/jbosstm/workspace/whitingjr/trunk/performance/src/test/java/org/jboss/jbossts/performance/resource/SynchronizeTask.java
   labs/jbosstm/workspace/whitingjr/trunk/performance/src/test/java/org/jboss/jbossts/performance/task/RecursiveTask.java
Log:
UPdated.


Modified: labs/jbosstm/workspace/whitingjr/trunk/performance/src/test/java/org/jboss/jbossts/performance/resource/SynchronizeTask.java
===================================================================
--- labs/jbosstm/workspace/whitingjr/trunk/performance/src/test/java/org/jboss/jbossts/performance/resource/SynchronizeTask.java	2010-02-11 20:10:25 UTC (rev 31581)
+++ labs/jbosstm/workspace/whitingjr/trunk/performance/src/test/java/org/jboss/jbossts/performance/resource/SynchronizeTask.java	2010-02-11 20:10:57 UTC (rev 31582)
@@ -29,7 +29,6 @@
  */
 public class SynchronizeTask extends RecursiveTask
 {
-   
    public SynchronizeTask(final ConcurrentTaskConfiguration taskConfiguration)
    {
       super(taskConfiguration);
@@ -43,12 +42,10 @@
    public void task(final int iteration)
       throws Exception
    {
-      EntityManagerImpl emA = null;
-      EntityManagerImpl emB = null;
-      emA = (EntityManagerImpl) getEMFactoryA().createEntityManager();
-      emB = (EntityManagerImpl) getEMFactoryB().createEntityManager();
-      Transaction transaction =emA.getSession().beginTransaction();
-      TransactionLocal session = new TransactionLocal();
+      final EntityManagerImpl emA  = (EntityManagerImpl) getEMFactoryA().createEntityManager();
+      final EntityManagerImpl emB = (EntityManagerImpl) getEMFactoryB().createEntityManager();
+      final Transaction transaction =emA.getSession().beginTransaction();
+      final TransactionLocal session = new TransactionLocal();
       
       /* emA automatically has a synch established because it is associated with the em factory A.
        * Whereas emB isn't and therefore the EM persistence context for B needs a synch added to 
@@ -61,27 +58,28 @@
        * B read
        * B write
        */
-      UserDAOBeanMultiResource userDAO_A = new UserDAOBeanMultiResource();
+      final UserDAOBeanMultiResource userDAO_A = new UserDAOBeanMultiResource();
       userDAO_A.setEntityManagerA(emA);
-      UserDAOBeanMultiResource  userDAO_B = new UserDAOBeanMultiResource ();
+      final UserDAOBeanMultiResource  userDAO_B = new UserDAOBeanMultiResource ();
       userDAO_B.setEntityManagerB(emB);
 
       // Prepare a user object
       session.set(emA);
-      User userA = findUsingResourceA(userDAO_A);
-
-      long time = System.currentTimeMillis();
+      String name = String.format("Ben[%1$d][%2$d]", this.threadId, System.currentTimeMillis()) ;
       
+      final User userA = findUsingResourceA(userDAO_A);
+      Assert.assertNotNull(userA, String.format( "User A should not be null.[%1$d][%2$d]", this.threadId, iteration));
+       
       if (this.isOptionalWriteEnabled)
       {
-         userA.setFirstname("Ben"+time);
+         userA.setFirstname(name);
          emA.merge(userA);
       }
       session.set(emB);
       // Don't forget to take the return value, this is basically a merge()
-      User userB = findUsingResourceB(userDAO_B);
-      Assert.assertNotNull(userB);
-      userB.setFirstname("Ben"+time);
+      final User userB = findUsingResourceB(userDAO_B);
+      Assert.assertNotNull(userB, "The userB object was null.");
+      userB.setFirstname(name);
       emB.merge(userB);
       /*Need to flush here to avoid profiling on the class SessionImpl. Otherwise the
        * profiler generates Mb of profiling data not needed including all methods of
@@ -89,7 +87,7 @@
       resourceAFlush(emA);
       
       /* want to detatch the entities in emA persistence context to avoid 
-       * expensive flush on later. */
+       * expensive flush later. */
       emA.clear(); 
       
       /* the commit call will cause hibernate to check for changes to entities, 
@@ -140,6 +138,6 @@
    private void performWrite(final EntityManager em, final String sql)
    {
       Query query = em.createNativeQuery(sql);
-      Assert.assertEquals(1, query.executeUpdate()) ;
+      Assert.assertEquals(1, query.executeUpdate(), "The expected modification count was not 1.") ;
    }
 }

Modified: labs/jbosstm/workspace/whitingjr/trunk/performance/src/test/java/org/jboss/jbossts/performance/task/RecursiveTask.java
===================================================================
--- labs/jbosstm/workspace/whitingjr/trunk/performance/src/test/java/org/jboss/jbossts/performance/task/RecursiveTask.java	2010-02-11 20:10:25 UTC (rev 31581)
+++ labs/jbosstm/workspace/whitingjr/trunk/performance/src/test/java/org/jboss/jbossts/performance/task/RecursiveTask.java	2010-02-11 20:10:57 UTC (rev 31582)
@@ -95,7 +95,7 @@
       }
       finally
       {
-         NDC.clear();
+         NDC.remove();
       }
    }
    protected abstract void task(final int iteration) throws Exception;
@@ -117,7 +117,7 @@
          } catch (Exception e)
          {
             this.completionBarrier.reset();
-            logger.error(String.format("Failed profiled run of testbody for thread [%1$d] count [$2$d].", this.threadId, i ));
+            logger.error(String.format("Failed profiled run of testbody for thread [%1$d] count [%2$d].", this.threadId, i ));
             Assert.fail(e.getMessage(), e);
          }
       }



More information about the jboss-svn-commits mailing list