[jboss-svn-commits] JBL Code SVN: r31818 - in labs/jbosstm/workspace/whitingjr/trunk/performance/src: test/java/org/jboss/jbossts/performance and 1 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Wed Feb 24 05:39:17 EST 2010
Author: whitingjr
Date: 2010-02-24 05:39:17 -0500 (Wed, 24 Feb 2010)
New Revision: 31818
Added:
labs/jbosstm/workspace/whitingjr/trunk/performance/src/main/resources/ack.properties
Modified:
labs/jbosstm/workspace/whitingjr/trunk/performance/src/test/java/org/jboss/jbossts/performance/MultiThreadedTest.java
labs/jbosstm/workspace/whitingjr/trunk/performance/src/test/java/org/jboss/jbossts/performance/jdbc/JDBCTask.java
Log:
Updated JDBC test to remove unwanted setting of values.
Change timing to use overall timing.
Refactored writing of data into methods for profiling.
Added: labs/jbosstm/workspace/whitingjr/trunk/performance/src/main/resources/ack.properties
===================================================================
--- labs/jbosstm/workspace/whitingjr/trunk/performance/src/main/resources/ack.properties (rev 0)
+++ labs/jbosstm/workspace/whitingjr/trunk/performance/src/main/resources/ack.properties 2010-02-24 10:39:17 UTC (rev 31818)
@@ -0,0 +1,4 @@
+ack.to.address=whitingjr at hotmail.com
+ack.from.address=jwhiting at redhat.com
+ack.host=smtp.redhat.com
+ack.port=587
Modified: labs/jbosstm/workspace/whitingjr/trunk/performance/src/test/java/org/jboss/jbossts/performance/MultiThreadedTest.java
===================================================================
--- labs/jbosstm/workspace/whitingjr/trunk/performance/src/test/java/org/jboss/jbossts/performance/MultiThreadedTest.java 2010-02-24 09:25:10 UTC (rev 31817)
+++ labs/jbosstm/workspace/whitingjr/trunk/performance/src/test/java/org/jboss/jbossts/performance/MultiThreadedTest.java 2010-02-24 10:39:17 UTC (rev 31818)
@@ -32,18 +32,33 @@
for (int count = 1; count <= configuration.getThreadCount(); count += 1)
{
Executor executor = new ThreadPerTestWorkerExecutor();
- /* Here we use the count value as the threadIdentity. This allows each thread to
+ /* Here we use the 'count' value as the threadIdentity. This allows each thread to
* use (read/write) a record in the database that does not overlap with other threads.
* Avoiding deadlocking in the database. */
executor.execute(getTask( new MultithreadedTestConfiguration(configuration.getIterationCount(), completionBarrier, new Long(count), configuration.getThreadResults()) ));
}
+
+ while(completionBarrier.getNumberWaiting() < configuration.getThreadCount())
+ {
+ Thread.sleep(100);
+ }
+ long start = System.currentTimeMillis();
completionBarrier.await();// start all the threads processing
- long start = System.currentTimeMillis();
- logger.info("All threads have started warmup.");
+
+ logger.info("All threads have started processing.");
if (!completionBarrier.isBroken())
- {// good, worked so far, now wait for completion of tests
+ {
+ // good, worked so far, now wait for completion of tests
+
completionBarrier.await();// all threads fall out, either by assertion error or all iterations completing
- logger.info(String.format("Duration of phase was :%1$dms", (System.currentTimeMillis() - start)));
+
+ long duration = System.currentTimeMillis() - start;
+ float timeInSecs = duration / 1000;
+ float txPerSec = (configuration.getThreadCount() * configuration.getIterationCount()) / timeInSecs;
+ logger.info(String.format("TxPerSec:%1$.0f", txPerSec));
+ logger.info(String.format("TimeInSecs:%1$.2f", timeInSecs));
+ logger.info(String.format("Tx:%1$d", (configuration.getThreadCount() * configuration.getIterationCount())));
+
// wait for all to finish profiled run
}
else
Modified: labs/jbosstm/workspace/whitingjr/trunk/performance/src/test/java/org/jboss/jbossts/performance/jdbc/JDBCTask.java
===================================================================
--- labs/jbosstm/workspace/whitingjr/trunk/performance/src/test/java/org/jboss/jbossts/performance/jdbc/JDBCTask.java 2010-02-24 09:25:10 UTC (rev 31817)
+++ labs/jbosstm/workspace/whitingjr/trunk/performance/src/test/java/org/jboss/jbossts/performance/jdbc/JDBCTask.java 2010-02-24 10:39:17 UTC (rev 31818)
@@ -62,70 +62,51 @@
boolean completed = false;
try
{
- getTaskConfiguration().getUserTransaction().begin();
- connectionA = getTaskConfiguration().getDataSourceA().getConnection();
- pStatementARead = connectionA.prepareStatement("select user0_.USER_ID , user0_.CREATED , user0_.DEFAULT_BILLING_DETAILS_ID , user0_.EMAIL , user0_.FIRSTNAME , user0_.HOME_CITY , user0_.HOME_STREET as HOME6_4_1_, user0_.HOME_ZIPCODE , user0_.LASTNAME , user0_.PASSWD , user0_.RANK , user0_.USERNAME , user0_.OBJ_VERSION , user0_1_.CITY , user0_1_.STREET , user0_1_.ZIPCODE , addressent1_.ADDRESS_ID , addressent1_.CITY , addressent1_.STREET , addressent1_.OBJ_VERSION , addressent1_.ZIPCODE from USERS user0_ left outer join BILLING_ADDRESS user0_1_ on user0_.USER_ID=user0_1_.USER_ID left outer join ADDRESS addressent1_ on user0_.USER_ID=addressent1_.ADDRESS_ID where user0_.USER_ID=?");
- resultA = findUsingResourceA(pStatementARead, this.getTaskConfiguration().getTestConfiguration().getThreadIdentity());
- Assert.assertTrue(resultA.next());
- int version = resultA.getInt(13);
long time = System.currentTimeMillis();
-
- if (this.isOptionalWriteEnabled)
+ try
{
- pStatementAWrite = connectionA.prepareStatement("update USERS set DEFAULT_BILLING_DETAILS_ID=?, EMAIL=?, FIRSTNAME=?, HOME_CITY=?, HOME_STREET=?, HOME_ZIPCODE=?, LASTNAME=?, PASSWD=?, RANK=?, USERNAME=?, OBJ_VERSION=? where USER_ID=? and OBJ_VERSION=?");
- pStatementAWrite.setNull(1, Types.NUMERIC);
- pStatementAWrite.setString(2, "anotheruser at mail.tld");
- pStatementAWrite.setString(3, String.format("Ben%1$d", time));
- pStatementAWrite.setString(4, "Foocity");
- pStatementAWrite.setString(5, "Foostreet");
- pStatementAWrite.setString(6, "22222");
- pStatementAWrite.setString(7, "User");
- pStatementAWrite.setString(8, "secret");
- pStatementAWrite.setInt(9, 0);
- pStatementAWrite.setString(10, String.format("anotheruser%1$d", this.getTaskConfiguration().getTestConfiguration().getThreadIdentity().intValue()));
- pStatementAWrite.setInt(11, (version+1));
- pStatementAWrite.setInt(12, this.getTaskConfiguration().getTestConfiguration().getThreadIdentity().intValue());
- pStatementAWrite.setInt(13, version);
- Assert.assertEquals(pStatementAWrite.executeUpdate(), 1) ;
+ getTaskConfiguration().getUserTransaction().begin();
+ connectionA = getTaskConfiguration().getDataSourceA().getConnection();
+ pStatementARead = connectionA.prepareStatement("select user0_.USER_ID , user0_.CREATED , user0_.DEFAULT_BILLING_DETAILS_ID , user0_.EMAIL , user0_.FIRSTNAME , user0_.HOME_CITY , user0_.HOME_STREET as HOME6_4_1_, user0_.HOME_ZIPCODE , user0_.LASTNAME , user0_.PASSWD , user0_.RANK , user0_.USERNAME , user0_.OBJ_VERSION , user0_1_.CITY , user0_1_.STREET , user0_1_.ZIPCODE , addressent1_.ADDRESS_ID , addressent1_.CITY , addressent1_.STREET , addressent1_.OBJ_VERSION , addressent1_.ZIPCODE from USERS user0_ left outer join BILLING_ADDRESS user0_1_ on user0_.USER_ID=user0_1_.USER_ID left outer join ADDRESS addressent1_ on user0_.USER_ID=addressent1_.ADDRESS_ID where user0_.USER_ID=?");
+ resultA = findUsingResourceA(pStatementARead, this.getTaskConfiguration().getTestConfiguration().getThreadIdentity());
+ Assert.assertTrue(resultA.next());
+ int version = resultA.getInt(13);
+
+ if (this.isOptionalWriteEnabled)
+ {
+ pStatementAWrite = connectionA.prepareStatement("update USERS set FIRSTNAME=?, OBJ_VERSION=? where USER_ID=? and OBJ_VERSION=?");
+ writeUsingResourceA(pStatementAWrite, time, version);
+ }
}
-
- connectionB= getTaskConfiguration().getDataSourceB().getConnection();
- pStatementBRead = connectionB.prepareStatement("select user0_.USER_ID , user0_.CREATED , user0_.DEFAULT_BILLING_DETAILS_ID , user0_.EMAIL , user0_.FIRSTNAME , user0_.HOME_CITY , user0_.HOME_STREET as HOME6_4_1_, user0_.HOME_ZIPCODE , user0_.LASTNAME , user0_.PASSWD , user0_.RANK , user0_.USERNAME , user0_.OBJ_VERSION , user0_1_.CITY , user0_1_.STREET , user0_1_.ZIPCODE , addressent1_.ADDRESS_ID , addressent1_.CITY , addressent1_.STREET , addressent1_.OBJ_VERSION , addressent1_.ZIPCODE from USERS user0_ left outer join BILLING_ADDRESS user0_1_ on user0_.USER_ID=user0_1_.USER_ID left outer join ADDRESS addressent1_ on user0_.USER_ID=addressent1_.ADDRESS_ID where user0_.USER_ID=?");
- resultB = findUsingResourceB(pStatementBRead, this.getTaskConfiguration().getTestConfiguration().getThreadIdentity());
- Assert.assertTrue(resultB.next());
- version = resultB.getInt(13);
-
- pStatementBWrite = connectionB.prepareStatement("update USERS set DEFAULT_BILLING_DETAILS_ID=?, EMAIL=?, FIRSTNAME=?, HOME_CITY=?, HOME_STREET=?, HOME_ZIPCODE=?, LASTNAME=?, PASSWD=?, RANK=?, USERNAME=?, OBJ_VERSION=? where USER_ID=? and OBJ_VERSION=?");
- pStatementBWrite.setNull(1, Types.NUMERIC);
- pStatementBWrite.setString(2, "anotheruser at mail.tld");
- pStatementBWrite.setString(3, String.format("Ben%1$d", time));
- pStatementBWrite.setString(4, "Foocity");
- pStatementBWrite.setString(5, "Foostreet");
- pStatementBWrite.setString(6, "22222");
- pStatementBWrite.setString(7, "User");
- pStatementBWrite.setString(8, "secret");
- pStatementBWrite.setInt(9, 0);
- pStatementBWrite.setString(10, String.format("anotheruser%1$d", this.getTaskConfiguration().getTestConfiguration().getThreadIdentity().intValue()));
- pStatementBWrite.setInt(11, (version+1));
- pStatementBWrite.setInt(12, this.getTaskConfiguration().getTestConfiguration().getThreadIdentity().intValue());
- pStatementBWrite.setInt(13, version);
- Assert.assertEquals(pStatementBWrite.executeUpdate(), 1) ;
-
- completed = true;
+ finally
+ {
+ DbUtils.closeQuietly(resultA);
+ DbUtils.closeQuietly(pStatementARead) ;
+ DbUtils.closeQuietly(pStatementAWrite);
+ DbUtils.closeQuietly(connectionA);
+ }
+ try
+ {
+ connectionB= getTaskConfiguration().getDataSourceB().getConnection();
+ pStatementBRead = connectionB.prepareStatement("select user0_.USER_ID , user0_.CREATED , user0_.DEFAULT_BILLING_DETAILS_ID , user0_.EMAIL , user0_.FIRSTNAME , user0_.HOME_CITY , user0_.HOME_STREET as HOME6_4_1_, user0_.HOME_ZIPCODE , user0_.LASTNAME , user0_.PASSWD , user0_.RANK , user0_.USERNAME , user0_.OBJ_VERSION , user0_1_.CITY , user0_1_.STREET , user0_1_.ZIPCODE , addressent1_.ADDRESS_ID , addressent1_.CITY , addressent1_.STREET , addressent1_.OBJ_VERSION , addressent1_.ZIPCODE from USERS user0_ left outer join BILLING_ADDRESS user0_1_ on user0_.USER_ID=user0_1_.USER_ID left outer join ADDRESS addressent1_ on user0_.USER_ID=addressent1_.ADDRESS_ID where user0_.USER_ID=?");
+ resultB = findUsingResourceB(pStatementBRead, this.getTaskConfiguration().getTestConfiguration().getThreadIdentity());
+ Assert.assertTrue(resultB.next());
+ int version = resultB.getInt(13);
+
+ pStatementBWrite = connectionB.prepareStatement("update USERS set FIRSTNAME=?, OBJ_VERSION=? where USER_ID=? and OBJ_VERSION=?");
+ writeUsingResourceB(pStatementBWrite, time, version);
+ completed = true;
+ }
+ finally
+ {
+ DbUtils.closeQuietly(resultB);
+ DbUtils.closeQuietly(pStatementBRead) ;
+ DbUtils.closeQuietly(pStatementBWrite);
+ DbUtils.closeQuietly(connectionB);
+ }
}
finally
{
- DbUtils.closeQuietly(resultA);
- DbUtils.closeQuietly(pStatementARead) ;
- DbUtils.closeQuietly(pStatementAWrite);
-
- DbUtils.closeQuietly(resultB);
- DbUtils.closeQuietly(pStatementBRead) ;
- DbUtils.closeQuietly(pStatementBWrite);
-
- DbUtils.closeQuietly(connectionA);
- DbUtils.closeQuietly(connectionB);
-
if (completed)
{
this.getTaskConfiguration().getUserTransaction().commit();
@@ -134,7 +115,6 @@
{
getTaskConfiguration().getUserTransaction().rollback();
}
-
}
}
private ResultSet findUsingResourceA(final PreparedStatement preparedStatement, final Long id)
@@ -153,4 +133,26 @@
statement.setLong(1, id);
return statement.executeQuery();
}
+
+ private void writeUsingResourceA(PreparedStatement pStatement, long time, int version)
+ throws SQLException
+ {
+ writeUsingResource(pStatement, time, version);
+ }
+
+ private void writeUsingResourceB(PreparedStatement pStatement, long time, int version)
+ throws SQLException
+ {
+ writeUsingResource(pStatement, time, version);
+ }
+
+ private void writeUsingResource(PreparedStatement pStatement, long time, int version)
+ throws SQLException
+ {
+ pStatement.setString(1, String.format("Ben%1$d", time));
+ pStatement.setInt(2, (version+1));
+ pStatement.setInt(3, this.getTaskConfiguration().getTestConfiguration().getThreadIdentity().intValue());
+ pStatement.setInt(4, version);
+ Assert.assertEquals(pStatement.executeUpdate(), 1) ;
+ }
}
\ No newline at end of file
More information about the jboss-svn-commits
mailing list