[jboss-cvs] JBoss Messaging SVN: r4704 - in trunk/tests/src/org/jboss/messaging/tests/stress/journal: remote and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Jul 21 19:45:02 EDT 2008
Author: clebert.suconic at jboss.com
Date: 2008-07-21 19:45:02 -0400 (Mon, 21 Jul 2008)
New Revision: 4704
Modified:
trunk/tests/src/org/jboss/messaging/tests/stress/journal/ValidateTransactionHealthTest.java
trunk/tests/src/org/jboss/messaging/tests/stress/journal/remote/RemoteJournalAppender.java
Log:
Improving stress tests
Modified: trunk/tests/src/org/jboss/messaging/tests/stress/journal/ValidateTransactionHealthTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/stress/journal/ValidateTransactionHealthTest.java 2008-07-21 23:09:02 UTC (rev 4703)
+++ trunk/tests/src/org/jboss/messaging/tests/stress/journal/ValidateTransactionHealthTest.java 2008-07-21 23:45:02 UTC (rev 4704)
@@ -48,27 +48,42 @@
public void testAIO() throws Exception
{
- internalTest("aio", "/tmp/aiojournal", 100000, 100, true, true);
+ internalTest("aio", "/tmp/aiojournal", 100000, 100, true, true, 1);
}
+ public void testAIOHugeTransaction() throws Exception
+ {
+ internalTest("aio", "/tmp/aiojournal", 100000, 100000, true, true, 1);
+ }
+
+ public void testAIOMultiThread() throws Exception
+ {
+ internalTest("aio", "/tmp/aiojournal", 10000, 100, true, true, 10);
+ }
+
public void testAIONonTransactional() throws Exception
{
- internalTest("aio", "/tmp/aiojournal", 100000, 0, true, true);
+ internalTest("aio", "/tmp/aiojournal", 100000, 0, true, true, 1);
}
public void testAIONonTransactionalNoExternalProcess() throws Exception
{
- internalTest("aio", "/tmp/aiojournal", 100000, 0, true, false);
+ internalTest("aio", "/tmp/aiojournal", 10000, 0, true, false, 10);
}
public void testNIO() throws Exception
{
- internalTest("nio", "/tmp/niojournal", 100000, 100, true, true);
+ internalTest("nio", "/tmp/niojournal", 100000, 100, true, true, 1);
}
+ public void testNIOMultiThread() throws Exception
+ {
+ internalTest("nio", "/tmp/niojournal", 10000, 100, true, true, 10);
+ }
+
public void testNIONonTransactional() throws Exception
{
- internalTest("nio", "/tmp/niojournal", 100000, 0, true, true);
+ internalTest("nio", "/tmp/niojournal", 100000, 0, true, true, 1);
}
// Package protected ---------------------------------------------
@@ -78,7 +93,7 @@
// Private -------------------------------------------------------
private void internalTest(String type, String journalDir,
- long numberOfRecords, int transactionSize, boolean append, boolean externalProcess) throws Exception
+ long numberOfRecords, int transactionSize, boolean append, boolean externalProcess, int numberOfThreads) throws Exception
{
if (type.equals("aio") && !AsynchronousFileImpl.isLoaded())
{
@@ -98,21 +113,21 @@
{
RemoteProcess process = startProcess(true, RemoteJournalAppender.class
.getCanonicalName(), type, journalDir, Long
- .toString(numberOfRecords), Integer.toString(transactionSize));
+ .toString(numberOfRecords), Integer.toString(transactionSize), Integer.toString(numberOfThreads));
process.getProcess().waitFor();
assertEquals(RemoteJournalAppender.OK, process.getProcess().exitValue());
}
else
{
- JournalImpl journal = RemoteJournalAppender.appendData(type, journalDir, numberOfRecords, transactionSize);
+ JournalImpl journal = RemoteJournalAppender.appendData(type, journalDir, numberOfRecords, transactionSize, numberOfThreads);
journal.stop();
}
}
- //reload(type, journalDir, numberOfRecords);
+ reload(type, journalDir, numberOfRecords, numberOfThreads);
}
- private void reload(String type, String journalDir, long numberOfRecords)
+ private void reload(String type, String journalDir, long numberOfRecords, int numberOfThreads)
throws Exception
{
JournalImpl journal = RemoteJournalAppender.createJournal(type,
@@ -121,7 +136,7 @@
journal.start();
Loader loadTest = new Loader(numberOfRecords);
journal.load(loadTest);
- assertEquals(numberOfRecords, loadTest.numberOfAdds);
+ assertEquals(numberOfRecords * numberOfThreads, loadTest.numberOfAdds);
assertEquals(0, loadTest.numberOfPreparedTransactions);
assertEquals(0, loadTest.numberOfUpdates);
assertEquals(0, loadTest.numberOfDeletes);
@@ -160,7 +175,7 @@
public void addRecord(RecordInfo info)
{
- if (info.id - lastID > 1)
+ if (info.id == lastID)
{
System.out.println("id = " + info.id + " last id = " + lastID);
}
@@ -168,7 +183,7 @@
ByteBuffer buffer = ByteBuffer.wrap(info.data);
long recordValue = buffer.getLong();
- if (recordValue != (expectedRecords - info.id))
+ if (recordValue != info.id)
{
ex = new Exception("Content not as expected (" + recordValue
+ " != " + info.id + ")");
Modified: trunk/tests/src/org/jboss/messaging/tests/stress/journal/remote/RemoteJournalAppender.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/stress/journal/remote/RemoteJournalAppender.java 2008-07-21 23:09:02 UTC (rev 4703)
+++ trunk/tests/src/org/jboss/messaging/tests/stress/journal/remote/RemoteJournalAppender.java 2008-07-21 23:45:02 UTC (rev 4704)
@@ -23,6 +23,8 @@
package org.jboss.messaging.tests.stress.journal.remote;
import java.nio.ByteBuffer;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.atomic.AtomicLong;
import org.jboss.messaging.core.journal.LoadManager;
import org.jboss.messaging.core.journal.PreparedTransactionInfo;
@@ -45,26 +47,27 @@
public static void main(String args[]) throws Exception
{
- if (args.length != 4)
+ if (args.length != 5)
{
System.err
.println("Use: java -cp <classpath> "
+ RemoteJournalAppender.class.getCanonicalName()
- + " aio|nio <journalDirectory> <NumberOfElements> <TransactionSize>");
+ + " aio|nio <journalDirectory> <NumberOfElements> <TransactionSize> <NumberOfThreads>");
System.exit(-1);
}
String journalType = args[0];
String journalDir = args[1];
long numberOfElements = Long.parseLong(args[2]);
int transactionSize = Integer.parseInt(args[3]);
+ int numberOfThreads = Integer.parseInt(args[4]);
try
{
JournalImpl journal = appendData(journalType, journalDir,
- numberOfElements, transactionSize);
+ numberOfElements, transactionSize, numberOfThreads);
- journal.stop();
+ journal.stop(); // TODO: Remove this stop (for transactional tests at least)
}
catch (Exception e)
@@ -77,9 +80,9 @@
}
public static JournalImpl appendData(String journalType, String journalDir,
- long numberOfElements, int transactionSize) throws Exception
+ long numberOfElements, int transactionSize, int numberOfThreads) throws Exception
{
- JournalImpl journal = createJournal(journalType, journalDir);
+ final JournalImpl journal = createJournal(journalType, journalDir);
journal.start();
journal.load(new LoadManager()
@@ -103,38 +106,33 @@
}
});
- int transactionCounter = 0;
- long transactionId = 1;
+ LocalThreads threads[] = new LocalThreads[numberOfThreads];
+ final AtomicLong nextInteger = new AtomicLong();
- for (long i = 0; i < numberOfElements; i++)
+ for (int i = 0; i < numberOfThreads; i++)
{
+ threads[i] = new LocalThreads(journal, numberOfElements, transactionSize, nextInteger);
+ threads[i].start();
+ }
+
+ Exception e = null;
+ for (LocalThreads t: threads)
+ {
+ t.join();
- ByteBuffer buffer = ByteBuffer.allocate(512*3);
- buffer.putLong(numberOfElements - i);
-
- if (transactionSize != 0)
+ if (t.e != null)
{
- journal.appendAddRecordTransactional(transactionId, i, (byte)99, buffer.array());
-
- if (++transactionCounter == transactionSize)
- {
- System.out.println("Commit transaction " + transactionId);
- journal.appendCommitRecord(transactionId);
- transactionCounter = 0;
- transactionId ++;
- }
+ e = t.e;
}
- else
- {
- journal.appendAddRecord(i, (byte)99, buffer.array());
- }
}
-
- if (transactionCounter != 0)
+
+ if (e != null)
{
- journal.appendCommitRecord(transactionId);
+ throw e;
}
+
+
return journal;
}
@@ -171,4 +169,73 @@
// Inner classes -------------------------------------------------
+
+ static class LocalThreads extends Thread
+ {
+ final JournalImpl journal;
+ final long numberOfElements;
+ final int transactionSize;
+ final AtomicLong nextID;
+
+ Exception e;
+
+ public LocalThreads(JournalImpl journal, long numberOfElements, int transactionSize, AtomicLong nextID)
+ {
+ super();
+ this.journal = journal;
+ this.numberOfElements = numberOfElements;
+ this.transactionSize = transactionSize;
+ this.nextID = nextID;
+ }
+
+
+
+
+ public void run()
+ {
+ try
+ {
+ int transactionCounter = 0;
+
+ long transactionId = nextID.incrementAndGet();
+
+ for (long i = 0; i < numberOfElements; i++)
+ {
+
+ long id = nextID.incrementAndGet();
+
+ ByteBuffer buffer = ByteBuffer.allocate(512*3);
+ buffer.putLong(id);
+
+ if (transactionSize != 0)
+ {
+ journal.appendAddRecordTransactional(transactionId, id, (byte)99, buffer.array());
+
+ if (++transactionCounter == transactionSize)
+ {
+ System.out.println("Commit transaction " + transactionId);
+ journal.appendCommitRecord(transactionId);
+ transactionCounter = 0;
+ transactionId = nextID.incrementAndGet();
+ }
+ }
+ else
+ {
+ journal.appendAddRecord(id, (byte)99, buffer.array());
+ }
+ }
+
+ if (transactionCounter != 0)
+ {
+ journal.appendCommitRecord(transactionId);
+ }
+ }
+ catch (Exception e)
+ {
+ this.e = e;
+ }
+
+ }
+ }
+
}
More information about the jboss-cvs-commits
mailing list