[jboss-cvs] JBoss Messaging SVN: r4283 - in trunk/tests/src/org/jboss/messaging/tests/performance: journal/impl and 4 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu May 22 10:28:16 EDT 2008
Author: clebert.suconic at jboss.com
Date: 2008-05-22 10:28:16 -0400 (Thu, 22 May 2008)
New Revision: 4283
Added:
trunk/tests/src/org/jboss/messaging/tests/performance/journal/impl/
trunk/tests/src/org/jboss/messaging/tests/performance/journal/impl/FakeJournalImplTest.java
trunk/tests/src/org/jboss/messaging/tests/performance/journal/impl/JournalImplTestUnit.java
trunk/tests/src/org/jboss/messaging/tests/performance/journal/impl/RealJournalImplAIOTest.java
trunk/tests/src/org/jboss/messaging/tests/performance/journal/impl/RealJournalImplTest.java
trunk/tests/src/org/jboss/messaging/tests/performance/persistence/impl/
trunk/tests/src/org/jboss/messaging/tests/performance/persistence/impl/StorageManagerTimingTest.java
trunk/tests/src/org/jboss/messaging/tests/performance/remoting/impl/
trunk/tests/src/org/jboss/messaging/tests/performance/remoting/impl/MeasureBase.java
trunk/tests/src/org/jboss/messaging/tests/performance/remoting/impl/MeasureInVMTest.java
trunk/tests/src/org/jboss/messaging/tests/performance/remoting/impl/MeasureRemoteTest.java
Removed:
trunk/tests/src/org/jboss/messaging/tests/performance/journal/FakeJournalImplTest.java
trunk/tests/src/org/jboss/messaging/tests/performance/journal/JournalImplTestUnit.java
trunk/tests/src/org/jboss/messaging/tests/performance/journal/RealJournalImplAIOTest.java
trunk/tests/src/org/jboss/messaging/tests/performance/journal/RealJournalImplTest.java
trunk/tests/src/org/jboss/messaging/tests/performance/persistence/StorageManagerTimingTest.java
trunk/tests/src/org/jboss/messaging/tests/performance/remoting/MeasureBase.java
trunk/tests/src/org/jboss/messaging/tests/performance/remoting/MeasureInVMTest.java
trunk/tests/src/org/jboss/messaging/tests/performance/remoting/MeasureRemoteTest.java
Log:
Moving tests around
Deleted: trunk/tests/src/org/jboss/messaging/tests/performance/journal/FakeJournalImplTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/performance/journal/FakeJournalImplTest.java 2008-05-22 12:29:03 UTC (rev 4282)
+++ trunk/tests/src/org/jboss/messaging/tests/performance/journal/FakeJournalImplTest.java 2008-05-22 14:28:16 UTC (rev 4283)
@@ -1,41 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.messaging.tests.performance.journal;
-
-import org.jboss.messaging.core.journal.SequentialFileFactory;
-import org.jboss.messaging.tests.unit.core.journal.impl.fakes.FakeSequentialFileFactory;
-
-/**
- *
- * A FakeJournalImplTest
- *
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- *
- */
-public class FakeJournalImplTest extends JournalImplTestUnit
-{
- protected SequentialFileFactory getFileFactory() throws Exception
- {
- return new FakeSequentialFileFactory();
- }
-}
-
Deleted: trunk/tests/src/org/jboss/messaging/tests/performance/journal/JournalImplTestUnit.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/performance/journal/JournalImplTestUnit.java 2008-05-22 12:29:03 UTC (rev 4282)
+++ trunk/tests/src/org/jboss/messaging/tests/performance/journal/JournalImplTestUnit.java 2008-05-22 14:28:16 UTC (rev 4283)
@@ -1,356 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.messaging.tests.performance.journal;
-
-import java.util.ArrayList;
-import java.util.concurrent.CountDownLatch;
-
-import org.jboss.messaging.core.asyncio.impl.AsynchronousFileImpl;
-import org.jboss.messaging.core.journal.IOCallback;
-import org.jboss.messaging.core.journal.Journal;
-import org.jboss.messaging.core.journal.PreparedTransactionInfo;
-import org.jboss.messaging.core.journal.RecordInfo;
-import org.jboss.messaging.core.journal.impl.JournalImpl;
-import org.jboss.messaging.core.logging.Logger;
-import org.jboss.messaging.tests.unit.core.journal.impl.JournalImplTestBase;
-
-/**
- *
- * A RealJournalImplTest
- *
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- *
- */
-public abstract class JournalImplTestUnit extends JournalImplTestBase
-{
- private static final Logger log = Logger.getLogger(JournalImplTestUnit.class);
-
- protected void tearDown() throws Exception
- {
- super.tearDown();
-
- assertEquals(0, AsynchronousFileImpl.getTotalMaxIO());
- }
-
- public void testAddUpdateDeleteManyLargeFileSize() throws Exception
- {
- final int numberAdds = 10000;
-
- final int numberUpdates = 5000;
-
- final int numberDeletes = 3000;
-
- long[] adds = new long[numberAdds];
-
- for (int i = 0; i < numberAdds; i++)
- {
- adds[i] = i;
- }
-
- long[] updates = new long[numberUpdates];
-
- for (int i = 0; i < numberUpdates; i++)
- {
- updates[i] = i;
- }
-
- long[] deletes = new long[numberDeletes];
-
- for (int i = 0; i < numberDeletes; i++)
- {
- deletes[i] = i;
- }
-
- // This would take a long time with sync=true, and still validates the file.
- setup(10, 10 * 1024 * 1024, false);
- createJournal();
- startJournal();
- load();
- add(adds);
- update(updates);
- delete(deletes);
- stopJournal();
- createJournal();
- startJournal();
- loadAndCheck();
-
- }
-
- public void testAddUpdateDeleteManySmallFileSize() throws Exception
- {
- final int numberAdds = 10000;
-
- final int numberUpdates = 5000;
-
- final int numberDeletes = 3000;
-
- long[] adds = new long[numberAdds];
-
- for (int i = 0; i < numberAdds; i++)
- {
- adds[i] = i;
- }
-
- long[] updates = new long[numberUpdates];
-
- for (int i = 0; i < numberUpdates; i++)
- {
- updates[i] = i;
- }
-
- long[] deletes = new long[numberDeletes];
-
- for (int i = 0; i < numberDeletes; i++)
- {
- deletes[i] = i;
- }
-
- setup(10, 10 * 1024, false);
- createJournal();
- startJournal();
- load();
- add(adds);
- update(updates);
- delete(deletes);
-
- log.info("Debug journal:" + debugJournal());
- stopJournal(false);
- createJournal();
- startJournal();
- loadAndCheck();
-
- }
-
- public void testReclaimAndReload() throws Exception
- {
- setup(2, 10 * 1024 * 1024, false);
- createJournal();
- startJournal();
- load();
-
- journal.startReclaimer();
-
- long start = System.currentTimeMillis();
-
-
- byte[] record = generateRecord(recordLength);
-
- int NUMBER_OF_RECORDS = 1000;
-
- for (int count = 0; count < NUMBER_OF_RECORDS; count++)
- {
- journal.appendAddRecord(count, (byte)0, record);
-
- if (count >= NUMBER_OF_RECORDS / 2)
- {
- journal.appendDeleteRecord(count - NUMBER_OF_RECORDS / 2);
- }
-
- if (count % 100 == 0)
- {
- log.info("Done: " + count);
- }
- }
-
- long end = System.currentTimeMillis();
-
- double rate = 1000 * ((double)NUMBER_OF_RECORDS) / (end - start);
-
- log.info("Rate of " + rate + " adds/removes per sec");
-
- log.info("Reclaim status = " + debugJournal());
-
- stopJournal();
- createJournal();
- startJournal();
- journal.load(new ArrayList<RecordInfo>(), new ArrayList<PreparedTransactionInfo>());
-
- assertEquals(NUMBER_OF_RECORDS / 2, journal.getIDMapSize());
-
- stopJournal();
- }
-
- public void testSpeedNonTransactional() throws Exception
- {
- for (int i=0;i<1;i++)
- {
- this.setUp();
- System.gc(); Thread.sleep(500);
- internaltestSpeedNonTransactional();
- this.tearDown();
- }
- }
-
- public void internaltestSpeedNonTransactional() throws Exception
- {
-
- final long numMessages = 10000;
-
- int numFiles = (int)(((numMessages * 1024 + 512) / (10 * 1024 * 1024)) * 1.3);
-
- if (numFiles<2) numFiles = 2;
-
- log.info("num Files=" + numFiles);
-
- Journal journal =
- new JournalImpl(10 * 1024 * 1024, numFiles, true, getFileFactory(),
- 5000, "jbm-data", "jbm", 5000, 120);
-
- journal.start();
-
- journal.load(new ArrayList<RecordInfo>(), null);
-
-
- final CountDownLatch latch = new CountDownLatch((int)numMessages);
-
-
- class LocalCallback implements IOCallback
- {
-
- int i=0;
- String message = null;
- boolean done = false;
- CountDownLatch latch;
-
- public LocalCallback(int i, CountDownLatch latch)
- {
- this.i = i;
- this.latch = latch;
- }
- public void done()
- {
- synchronized (this)
- {
- if (done)
- {
- message = "done received in duplicate";
- }
- done = true;
- this.latch.countDown();
- }
- }
-
- public void onError(int errorCode, String errorMessage)
- {
- synchronized (this)
- {
- System.out.println("********************** Error = " + (i++));
- message = errorMessage;
- latch.countDown();
- }
- }
-
- }
-
-
- log.info("Adding data");
- byte[] data = new byte[700];
-
- long start = System.currentTimeMillis();
-
- for (int i = 0; i < numMessages; i++)
- {
- journal.appendAddRecord(i, (byte)0, data);
- }
-
- long end = System.currentTimeMillis();
-
- double rate = 1000 * (double)numMessages / (end - start);
-
- boolean failed = false;
-
- // If this fails it is probably because JournalImpl it is closing the files without waiting all the completes to arrive first
- assertFalse(failed);
-
-
- log.info("Rate " + rate + " records/sec");
-
- journal.stop();
-
- journal =
- new JournalImpl(10 * 1024 * 1024, numFiles, true, getFileFactory(),
- 5000, "jbm-data", "jbm", 5000, 120);
-
- journal.start();
- journal.load(new ArrayList<RecordInfo>(), null);
- journal.stop();
-
- }
-
- public void testSpeedTransactional() throws Exception
- {
- Journal journal =
- new JournalImpl(10 * 1024 * 1024, 10, true, getFileFactory(),
- 5000, "jbm-data", "jbm", 5000, 120);
-
- journal.start();
-
- journal.load(new ArrayList<RecordInfo>(), null);
-
- try
- {
- final int numMessages = 50050;
-
- byte[] data = new byte[1024];
-
- long start = System.currentTimeMillis();
-
- int count = 0;
- double rates[] = new double[50];
- for (int i = 0; i < 50; i++)
- {
- long startTrans = System.currentTimeMillis();
- for (int j=0; j<1000; j++)
- {
- journal.appendAddRecordTransactional(i, (byte)0, count++, data);
- }
-
- journal.appendCommitRecord(i);
-
- long endTrans = System.currentTimeMillis();
-
- rates[i] = 1000 * (double)1000 / (endTrans - startTrans);
- }
-
- long end = System.currentTimeMillis();
-
- for (double rate: rates)
- {
- log.info("Transaction Rate = " + rate + " records/sec");
-
- }
-
- double rate = 1000 * (double)numMessages / (end - start);
-
- log.info("Rate " + rate + " records/sec");
- }
- finally
- {
- journal.stop();
- }
-
- }
-
-
-}
-
-
Deleted: trunk/tests/src/org/jboss/messaging/tests/performance/journal/RealJournalImplAIOTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/performance/journal/RealJournalImplAIOTest.java 2008-05-22 12:29:03 UTC (rev 4282)
+++ trunk/tests/src/org/jboss/messaging/tests/performance/journal/RealJournalImplAIOTest.java 2008-05-22 14:28:16 UTC (rev 4283)
@@ -1,67 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.messaging.tests.performance.journal;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-
-import org.jboss.messaging.core.asyncio.AIOCallback;
-import org.jboss.messaging.core.journal.IOCallback;
-import org.jboss.messaging.core.journal.Journal;
-import org.jboss.messaging.core.journal.RecordInfo;
-import org.jboss.messaging.core.journal.SequentialFileFactory;
-import org.jboss.messaging.core.journal.impl.AIOSequentialFileFactory;
-import org.jboss.messaging.core.journal.impl.JournalImpl;
-import org.jboss.messaging.core.journal.impl.NIOSequentialFileFactory;
-import org.jboss.messaging.core.logging.Logger;
-import org.jboss.messaging.tests.unit.core.journal.impl.fakes.FakeCallback;
-
-/**
- *
- * A RealJournalImplTest
- *
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- *
- */
-public class RealJournalImplAIOTest extends JournalImplTestUnit
-{
- private static final Logger log = Logger.getLogger(RealJournalImplAIOTest.class);
-
- protected String journalDir = System.getProperty("user.home") + "/journal-test";
-
- protected SequentialFileFactory getFileFactory() throws Exception
- {
- File file = new File(journalDir);
-
- log.info("deleting directory " + journalDir);
-
- deleteDirectory(file);
-
- file.mkdir();
-
- return new AIOSequentialFileFactory(journalDir);
- }
-
-}
-
Deleted: trunk/tests/src/org/jboss/messaging/tests/performance/journal/RealJournalImplTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/performance/journal/RealJournalImplTest.java 2008-05-22 12:29:03 UTC (rev 4282)
+++ trunk/tests/src/org/jboss/messaging/tests/performance/journal/RealJournalImplTest.java 2008-05-22 14:28:16 UTC (rev 4283)
@@ -1,58 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.messaging.tests.performance.journal;
-
-import java.io.File;
-
-import org.jboss.messaging.core.journal.SequentialFileFactory;
-import org.jboss.messaging.core.journal.impl.NIOSequentialFileFactory;
-import org.jboss.messaging.core.logging.Logger;
-
-/**
- *
- * A RealJournalImplTest
- *
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- *
- */
-public class RealJournalImplTest extends JournalImplTestUnit
-{
- private static final Logger log = Logger.getLogger(RealJournalImplTest.class);
-
- protected String journalDir = System.getProperty("user.home") + "/journal-test";
-
- protected SequentialFileFactory getFileFactory() throws Exception
- {
- File file = new File(journalDir);
-
- log.info("deleting directory " + journalDir);
-
- deleteDirectory(file);
-
- file.mkdir();
-
- return new NIOSequentialFileFactory(journalDir);
- }
-
-
-}
-
Copied: trunk/tests/src/org/jboss/messaging/tests/performance/journal/impl/FakeJournalImplTest.java (from rev 4282, trunk/tests/src/org/jboss/messaging/tests/performance/journal/FakeJournalImplTest.java)
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/performance/journal/impl/FakeJournalImplTest.java (rev 0)
+++ trunk/tests/src/org/jboss/messaging/tests/performance/journal/impl/FakeJournalImplTest.java 2008-05-22 14:28:16 UTC (rev 4283)
@@ -0,0 +1,41 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.messaging.tests.performance.journal.impl;
+
+import org.jboss.messaging.core.journal.SequentialFileFactory;
+import org.jboss.messaging.tests.unit.core.journal.impl.fakes.FakeSequentialFileFactory;
+
+/**
+ *
+ * A FakeJournalImplTest
+ *
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ *
+ */
+public class FakeJournalImplTest extends JournalImplTestUnit
+{
+ protected SequentialFileFactory getFileFactory() throws Exception
+ {
+ return new FakeSequentialFileFactory();
+ }
+}
+
Copied: trunk/tests/src/org/jboss/messaging/tests/performance/journal/impl/JournalImplTestUnit.java (from rev 4282, trunk/tests/src/org/jboss/messaging/tests/performance/journal/JournalImplTestUnit.java)
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/performance/journal/impl/JournalImplTestUnit.java (rev 0)
+++ trunk/tests/src/org/jboss/messaging/tests/performance/journal/impl/JournalImplTestUnit.java 2008-05-22 14:28:16 UTC (rev 4283)
@@ -0,0 +1,356 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.messaging.tests.performance.journal.impl;
+
+import java.util.ArrayList;
+import java.util.concurrent.CountDownLatch;
+
+import org.jboss.messaging.core.asyncio.impl.AsynchronousFileImpl;
+import org.jboss.messaging.core.journal.IOCallback;
+import org.jboss.messaging.core.journal.Journal;
+import org.jboss.messaging.core.journal.PreparedTransactionInfo;
+import org.jboss.messaging.core.journal.RecordInfo;
+import org.jboss.messaging.core.journal.impl.JournalImpl;
+import org.jboss.messaging.core.logging.Logger;
+import org.jboss.messaging.tests.unit.core.journal.impl.JournalImplTestBase;
+
+/**
+ *
+ * A RealJournalImplTest
+ *
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ *
+ */
+public abstract class JournalImplTestUnit extends JournalImplTestBase
+{
+ private static final Logger log = Logger.getLogger(JournalImplTestUnit.class);
+
+ protected void tearDown() throws Exception
+ {
+ super.tearDown();
+
+ assertEquals(0, AsynchronousFileImpl.getTotalMaxIO());
+ }
+
+ public void testAddUpdateDeleteManyLargeFileSize() throws Exception
+ {
+ final int numberAdds = 10000;
+
+ final int numberUpdates = 5000;
+
+ final int numberDeletes = 3000;
+
+ long[] adds = new long[numberAdds];
+
+ for (int i = 0; i < numberAdds; i++)
+ {
+ adds[i] = i;
+ }
+
+ long[] updates = new long[numberUpdates];
+
+ for (int i = 0; i < numberUpdates; i++)
+ {
+ updates[i] = i;
+ }
+
+ long[] deletes = new long[numberDeletes];
+
+ for (int i = 0; i < numberDeletes; i++)
+ {
+ deletes[i] = i;
+ }
+
+ // This would take a long time with sync=true, and still validates the file.
+ setup(10, 10 * 1024 * 1024, false);
+ createJournal();
+ startJournal();
+ load();
+ add(adds);
+ update(updates);
+ delete(deletes);
+ stopJournal();
+ createJournal();
+ startJournal();
+ loadAndCheck();
+
+ }
+
+ public void testAddUpdateDeleteManySmallFileSize() throws Exception
+ {
+ final int numberAdds = 10000;
+
+ final int numberUpdates = 5000;
+
+ final int numberDeletes = 3000;
+
+ long[] adds = new long[numberAdds];
+
+ for (int i = 0; i < numberAdds; i++)
+ {
+ adds[i] = i;
+ }
+
+ long[] updates = new long[numberUpdates];
+
+ for (int i = 0; i < numberUpdates; i++)
+ {
+ updates[i] = i;
+ }
+
+ long[] deletes = new long[numberDeletes];
+
+ for (int i = 0; i < numberDeletes; i++)
+ {
+ deletes[i] = i;
+ }
+
+ setup(10, 10 * 1024, false);
+ createJournal();
+ startJournal();
+ load();
+ add(adds);
+ update(updates);
+ delete(deletes);
+
+ log.info("Debug journal:" + debugJournal());
+ stopJournal(false);
+ createJournal();
+ startJournal();
+ loadAndCheck();
+
+ }
+
+ public void testReclaimAndReload() throws Exception
+ {
+ setup(2, 10 * 1024 * 1024, false);
+ createJournal();
+ startJournal();
+ load();
+
+ journal.startReclaimer();
+
+ long start = System.currentTimeMillis();
+
+
+ byte[] record = generateRecord(recordLength);
+
+ int NUMBER_OF_RECORDS = 1000;
+
+ for (int count = 0; count < NUMBER_OF_RECORDS; count++)
+ {
+ journal.appendAddRecord(count, (byte)0, record);
+
+ if (count >= NUMBER_OF_RECORDS / 2)
+ {
+ journal.appendDeleteRecord(count - NUMBER_OF_RECORDS / 2);
+ }
+
+ if (count % 100 == 0)
+ {
+ log.info("Done: " + count);
+ }
+ }
+
+ long end = System.currentTimeMillis();
+
+ double rate = 1000 * ((double)NUMBER_OF_RECORDS) / (end - start);
+
+ log.info("Rate of " + rate + " adds/removes per sec");
+
+ log.info("Reclaim status = " + debugJournal());
+
+ stopJournal();
+ createJournal();
+ startJournal();
+ journal.load(new ArrayList<RecordInfo>(), new ArrayList<PreparedTransactionInfo>());
+
+ assertEquals(NUMBER_OF_RECORDS / 2, journal.getIDMapSize());
+
+ stopJournal();
+ }
+
+ public void testSpeedNonTransactional() throws Exception
+ {
+ for (int i=0;i<1;i++)
+ {
+ this.setUp();
+ System.gc(); Thread.sleep(500);
+ internaltestSpeedNonTransactional();
+ this.tearDown();
+ }
+ }
+
+ public void internaltestSpeedNonTransactional() throws Exception
+ {
+
+ final long numMessages = 10000;
+
+ int numFiles = (int)(((numMessages * 1024 + 512) / (10 * 1024 * 1024)) * 1.3);
+
+ if (numFiles<2) numFiles = 2;
+
+ log.info("num Files=" + numFiles);
+
+ Journal journal =
+ new JournalImpl(10 * 1024 * 1024, numFiles, true, getFileFactory(),
+ 5000, "jbm-data", "jbm", 5000, 120);
+
+ journal.start();
+
+ journal.load(new ArrayList<RecordInfo>(), null);
+
+
+ final CountDownLatch latch = new CountDownLatch((int)numMessages);
+
+
+ class LocalCallback implements IOCallback
+ {
+
+ int i=0;
+ String message = null;
+ boolean done = false;
+ CountDownLatch latch;
+
+ public LocalCallback(int i, CountDownLatch latch)
+ {
+ this.i = i;
+ this.latch = latch;
+ }
+ public void done()
+ {
+ synchronized (this)
+ {
+ if (done)
+ {
+ message = "done received in duplicate";
+ }
+ done = true;
+ this.latch.countDown();
+ }
+ }
+
+ public void onError(int errorCode, String errorMessage)
+ {
+ synchronized (this)
+ {
+ System.out.println("********************** Error = " + (i++));
+ message = errorMessage;
+ latch.countDown();
+ }
+ }
+
+ }
+
+
+ log.info("Adding data");
+ byte[] data = new byte[700];
+
+ long start = System.currentTimeMillis();
+
+ for (int i = 0; i < numMessages; i++)
+ {
+ journal.appendAddRecord(i, (byte)0, data);
+ }
+
+ long end = System.currentTimeMillis();
+
+ double rate = 1000 * (double)numMessages / (end - start);
+
+ boolean failed = false;
+
+ // If this fails it is probably because JournalImpl it is closing the files without waiting all the completes to arrive first
+ assertFalse(failed);
+
+
+ log.info("Rate " + rate + " records/sec");
+
+ journal.stop();
+
+ journal =
+ new JournalImpl(10 * 1024 * 1024, numFiles, true, getFileFactory(),
+ 5000, "jbm-data", "jbm", 5000, 120);
+
+ journal.start();
+ journal.load(new ArrayList<RecordInfo>(), null);
+ journal.stop();
+
+ }
+
+ public void testSpeedTransactional() throws Exception
+ {
+ Journal journal =
+ new JournalImpl(10 * 1024 * 1024, 10, true, getFileFactory(),
+ 5000, "jbm-data", "jbm", 5000, 120);
+
+ journal.start();
+
+ journal.load(new ArrayList<RecordInfo>(), null);
+
+ try
+ {
+ final int numMessages = 50050;
+
+ byte[] data = new byte[1024];
+
+ long start = System.currentTimeMillis();
+
+ int count = 0;
+ double rates[] = new double[50];
+ for (int i = 0; i < 50; i++)
+ {
+ long startTrans = System.currentTimeMillis();
+ for (int j=0; j<1000; j++)
+ {
+ journal.appendAddRecordTransactional(i, (byte)0, count++, data);
+ }
+
+ journal.appendCommitRecord(i);
+
+ long endTrans = System.currentTimeMillis();
+
+ rates[i] = 1000 * (double)1000 / (endTrans - startTrans);
+ }
+
+ long end = System.currentTimeMillis();
+
+ for (double rate: rates)
+ {
+ log.info("Transaction Rate = " + rate + " records/sec");
+
+ }
+
+ double rate = 1000 * (double)numMessages / (end - start);
+
+ log.info("Rate " + rate + " records/sec");
+ }
+ finally
+ {
+ journal.stop();
+ }
+
+ }
+
+
+}
+
+
Copied: trunk/tests/src/org/jboss/messaging/tests/performance/journal/impl/RealJournalImplAIOTest.java (from rev 4282, trunk/tests/src/org/jboss/messaging/tests/performance/journal/RealJournalImplAIOTest.java)
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/performance/journal/impl/RealJournalImplAIOTest.java (rev 0)
+++ trunk/tests/src/org/jboss/messaging/tests/performance/journal/impl/RealJournalImplAIOTest.java 2008-05-22 14:28:16 UTC (rev 4283)
@@ -0,0 +1,67 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.messaging.tests.performance.journal.impl;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
+import org.jboss.messaging.core.asyncio.AIOCallback;
+import org.jboss.messaging.core.journal.IOCallback;
+import org.jboss.messaging.core.journal.Journal;
+import org.jboss.messaging.core.journal.RecordInfo;
+import org.jboss.messaging.core.journal.SequentialFileFactory;
+import org.jboss.messaging.core.journal.impl.AIOSequentialFileFactory;
+import org.jboss.messaging.core.journal.impl.JournalImpl;
+import org.jboss.messaging.core.journal.impl.NIOSequentialFileFactory;
+import org.jboss.messaging.core.logging.Logger;
+import org.jboss.messaging.tests.unit.core.journal.impl.fakes.FakeCallback;
+
+/**
+ *
+ * A RealJournalImplTest
+ *
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ *
+ */
+public class RealJournalImplAIOTest extends JournalImplTestUnit
+{
+ private static final Logger log = Logger.getLogger(RealJournalImplAIOTest.class);
+
+ protected String journalDir = System.getProperty("user.home") + "/journal-test";
+
+ protected SequentialFileFactory getFileFactory() throws Exception
+ {
+ File file = new File(journalDir);
+
+ log.info("deleting directory " + journalDir);
+
+ deleteDirectory(file);
+
+ file.mkdir();
+
+ return new AIOSequentialFileFactory(journalDir);
+ }
+
+}
+
Copied: trunk/tests/src/org/jboss/messaging/tests/performance/journal/impl/RealJournalImplTest.java (from rev 4282, trunk/tests/src/org/jboss/messaging/tests/performance/journal/RealJournalImplTest.java)
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/performance/journal/impl/RealJournalImplTest.java (rev 0)
+++ trunk/tests/src/org/jboss/messaging/tests/performance/journal/impl/RealJournalImplTest.java 2008-05-22 14:28:16 UTC (rev 4283)
@@ -0,0 +1,58 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.messaging.tests.performance.journal.impl;
+
+import java.io.File;
+
+import org.jboss.messaging.core.journal.SequentialFileFactory;
+import org.jboss.messaging.core.journal.impl.NIOSequentialFileFactory;
+import org.jboss.messaging.core.logging.Logger;
+
+/**
+ *
+ * A RealJournalImplTest
+ *
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ *
+ */
+public class RealJournalImplTest extends JournalImplTestUnit
+{
+ private static final Logger log = Logger.getLogger(RealJournalImplTest.class);
+
+ protected String journalDir = System.getProperty("user.home") + "/journal-test";
+
+ protected SequentialFileFactory getFileFactory() throws Exception
+ {
+ File file = new File(journalDir);
+
+ log.info("deleting directory " + journalDir);
+
+ deleteDirectory(file);
+
+ file.mkdir();
+
+ return new NIOSequentialFileFactory(journalDir);
+ }
+
+
+}
+
Deleted: trunk/tests/src/org/jboss/messaging/tests/performance/persistence/StorageManagerTimingTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/performance/persistence/StorageManagerTimingTest.java 2008-05-22 12:29:03 UTC (rev 4282)
+++ trunk/tests/src/org/jboss/messaging/tests/performance/persistence/StorageManagerTimingTest.java 2008-05-22 14:28:16 UTC (rev 4283)
@@ -1,288 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.messaging.tests.performance.persistence;
-
-import java.io.File;
-import java.util.HashMap;
-import java.util.concurrent.atomic.AtomicLong;
-
-import org.jboss.messaging.core.asyncio.impl.AsynchronousFileImpl;
-import org.jboss.messaging.core.config.impl.FileConfiguration;
-import org.jboss.messaging.core.logging.Logger;
-import org.jboss.messaging.core.message.impl.MessageImpl;
-import org.jboss.messaging.core.persistence.impl.journal.JournalStorageManager;
-import org.jboss.messaging.core.remoting.impl.mina.BufferWrapper;
-import org.jboss.messaging.core.server.JournalType;
-import org.jboss.messaging.core.server.Queue;
-import org.jboss.messaging.core.server.impl.ServerMessageImpl;
-import org.jboss.messaging.tests.performance.persistence.fakes.FakePostOffice;
-import org.jboss.messaging.tests.util.UnitTestCase;
-import org.jboss.messaging.util.SimpleString;
-
-public class StorageManagerTimingTest extends UnitTestCase
-{
-
- private static final Logger log = Logger.getLogger(StorageManagerTimingTest.class);
-
- protected void tearDown() throws Exception
- {
- super.tearDown();
- assertEquals(0, AsynchronousFileImpl.getTotalMaxIO());
- }
-
-
- public void testAIO() throws Exception
- {
- // just to do some initial loading.. ignore this rate
- internalTestStorage(JournalType.ASYNCIO, 1000, 1, 1);
-
- double rate = internalTestStorage(JournalType.ASYNCIO, 60000, 1, 1)[0];
- printRates("Rate of AIO, 60000 inserts / commits on every insert", rate);
-
- rate = internalTestStorage(JournalType.ASYNCIO, 30000, -1, 1)[0];
- printRates("Rate of AIO, 30000 inserts / single commit at the end", rate);
-
- rate = internalTestStorage(JournalType.ASYNCIO, 30000, 5, 1)[0];
- printRates("Rate of AIO, 30000 inserts / commit every 5 recodds", rate);
-
- rate = internalTestStorage(JournalType.ASYNCIO, 30000, -1, 1)[0];
- printRates("Rate of AIO, 30000 inserts / single commit at the end (again)", rate);
-
- }
-
- public void testAIOMultiThread() throws Exception
- {
- double[] rates = internalTestStorage(JournalType.ASYNCIO, 10000, -1, 1);
- rates = internalTestStorage(JournalType.ASYNCIO, 30000, -1, 5);
-
- printRates("Rate of AIO, 30000 inserts / single commit at the end", rates);
-
-
- rates = internalTestStorage(JournalType.ASYNCIO, 5000, 1, 5);
-
- printRates("Rate of AIO, 30000 inserts / commit on every insert", rates);
- }
-
- public void testNIO() throws Exception
- {
- // just to do some initial loading.. ignore this rate
- internalTestStorage(JournalType.NIO, 1000, 1, 1);
- double rate = internalTestStorage(JournalType.NIO, 1000, 1, 1)[0];
- printRates("Rate of NIO, 1000 inserts, 1000 commits", rate);
-
- rate = internalTestStorage(JournalType.NIO, 30000, -1, 1)[0];
- printRates("Rate of NIO, 30000 inserts / single commit at the end", rate);
-
- rate = internalTestStorage(JournalType.NIO, 30000, 5, 1)[0];
- printRates("Rate of NIO, 30000 inserts / commit every 5 records", rate);
- }
-
- public void testNIOMultiThread() throws Exception
- {
-
- double[] rates = internalTestStorage(JournalType.NIO, 5000, -1, 5);
-
- printRates("Rate of NIO, 5000 inserts / single commit at the end", rates);
-
- rates = internalTestStorage(JournalType.NIO, 5000, 1, 5);
-
- printRates("Rate of NIO, 5000 inserts / commit on every insert", rates);
-
-
- }
-
- public double[] internalTestStorage(final JournalType journalType,
- final long numberOfMessages,
- final int transInterval,
- final int numberOfThreads) throws Exception
- {
- FileConfiguration configuration = new FileConfiguration();
-
- configuration.start();
-
- deleteDirectory(new File(configuration.getBindingsDirectory()));
- deleteDirectory(new File(configuration.getJournalDirectory()));
-
- configuration.setJournalType(journalType);
-
- final JournalStorageManager journal = new JournalStorageManager(configuration);
- journal.start();
-
- FakePostOffice office = new FakePostOffice();
-
- HashMap<Long, Queue> queues = new HashMap<Long, Queue>();
-
- journal.loadMessages(office, queues);
-
- final byte[] bytes = new byte[900];
-
- for (int i=0;i<bytes.length;i++)
- {
- bytes[i] = (byte)('a' + (i%20));
- }
-
-
- final BufferWrapper buffer = new BufferWrapper(1024);
- buffer.putBytes(bytes);
-
- final AtomicLong transactionGenerator = new AtomicLong(1);
-
- class LocalThread extends Thread
- {
- int id;
- int commits = 1;
- Exception e;
- long totalTime = 0;
- public LocalThread(int id)
- {
- super("LocalThread:" + id);
- this.id = id;
- }
-
- public void run()
- {
- try
- {
- long start = System.currentTimeMillis();
-
- long trans = transactionGenerator.incrementAndGet();
- boolean commitPending=false;
- for (long i=1;i<=numberOfMessages;i++)
- {
-
- final SimpleString address = new SimpleString("Destination " + i);
-
-
- ServerMessageImpl implMsg = new ServerMessageImpl(/* type */ 1, /* durable */ true, /* expiration */ 0,
- /* timestamp */ 0, /* priority */(byte)0);
-
- implMsg.putStringProperty(new SimpleString("Key"), new SimpleString("This String is worthless!"));
-
- implMsg.setMessageID(i);
- implMsg.setBody(buffer);
-
- implMsg.setDestination(address);
-
-
-
- journal.storeMessageTransactional(trans, implMsg);
-
- commitPending = true;
-
- if (transInterval>0 && i%transInterval == 0)
- {
- journal.commit(trans);
- commits ++;
- trans = transactionGenerator.incrementAndGet();
- commitPending = false;
- }
- }
-
- if (commitPending) journal.commit(trans);
-
-
- long end = System.currentTimeMillis();
-
- totalTime = end - start;
- }
- catch (Exception e)
- {
- log.error(e.getMessage(), e);
- this.e = e;
- }
- }
- }
-
- try
- {
- LocalThread[] threads = new LocalThread[numberOfThreads];
-
-
- for (int i = 0; i < numberOfThreads; i++)
- {
- threads[i] = new LocalThread(i);
- }
-
- for (int i = 0; i < numberOfThreads; i++)
- {
- threads[i].start();
- }
-
- for (int i = 0; i < numberOfThreads; i++)
- {
- threads[i].join();
- }
-
- for (int i = 0; i < numberOfThreads; i++)
- {
- if (threads[i].e != null)
- {
- throw threads[i].e;
- }
- }
-
- double rates[] = new double[numberOfThreads];
-
- for (int i=0; i<numberOfThreads; i++)
- {
- rates[i] = (numberOfMessages + threads[i].commits) * 1000 / threads[i].totalTime;
- }
-
- return rates;
- }
- finally
- {
- journal.stop();
- }
-
- }
-
-
- private void printRates(String msg, double rate)
- {
- printRates(msg, new double[] { rate });
- }
- private void printRates(String msg, double[] rates)
- {
- double rate = 0;
-
- log.info("*************************************************************************");
- log.info(" " + msg + " ");
-
- double totalRate = 0;
- for (int i=0; i<rates.length; i++)
- {
- rate = rates[i];
- totalRate += rate;
- if (rates.length>1)
- {
- log.info( " Thread " + i + ": = " + rate + " inserts/sec (including commits)");
- }
- }
-
- log.info( " Total rate : = " + totalRate + " inserts/sec (including commits)");
- log.info("*************************************************************************");
- }
-
-
-}
Copied: trunk/tests/src/org/jboss/messaging/tests/performance/persistence/impl/StorageManagerTimingTest.java (from rev 4282, trunk/tests/src/org/jboss/messaging/tests/performance/persistence/StorageManagerTimingTest.java)
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/performance/persistence/impl/StorageManagerTimingTest.java (rev 0)
+++ trunk/tests/src/org/jboss/messaging/tests/performance/persistence/impl/StorageManagerTimingTest.java 2008-05-22 14:28:16 UTC (rev 4283)
@@ -0,0 +1,288 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.messaging.tests.performance.persistence.impl;
+
+import java.io.File;
+import java.util.HashMap;
+import java.util.concurrent.atomic.AtomicLong;
+
+import org.jboss.messaging.core.asyncio.impl.AsynchronousFileImpl;
+import org.jboss.messaging.core.config.impl.FileConfiguration;
+import org.jboss.messaging.core.logging.Logger;
+import org.jboss.messaging.core.message.impl.MessageImpl;
+import org.jboss.messaging.core.persistence.impl.journal.JournalStorageManager;
+import org.jboss.messaging.core.remoting.impl.mina.BufferWrapper;
+import org.jboss.messaging.core.server.JournalType;
+import org.jboss.messaging.core.server.Queue;
+import org.jboss.messaging.core.server.impl.ServerMessageImpl;
+import org.jboss.messaging.tests.performance.persistence.fakes.FakePostOffice;
+import org.jboss.messaging.tests.util.UnitTestCase;
+import org.jboss.messaging.util.SimpleString;
+
+public class StorageManagerTimingTest extends UnitTestCase
+{
+
+ private static final Logger log = Logger.getLogger(StorageManagerTimingTest.class);
+
+ protected void tearDown() throws Exception
+ {
+ super.tearDown();
+ assertEquals(0, AsynchronousFileImpl.getTotalMaxIO());
+ }
+
+
+ public void testAIO() throws Exception
+ {
+ // just to do some initial loading.. ignore this rate
+ internalTestStorage(JournalType.ASYNCIO, 1000, 1, 1);
+
+ double rate = internalTestStorage(JournalType.ASYNCIO, 60000, 1, 1)[0];
+ printRates("Rate of AIO, 60000 inserts / commits on every insert", rate);
+
+ rate = internalTestStorage(JournalType.ASYNCIO, 30000, -1, 1)[0];
+ printRates("Rate of AIO, 30000 inserts / single commit at the end", rate);
+
+ rate = internalTestStorage(JournalType.ASYNCIO, 30000, 5, 1)[0];
+ printRates("Rate of AIO, 30000 inserts / commit every 5 recodds", rate);
+
+ rate = internalTestStorage(JournalType.ASYNCIO, 30000, -1, 1)[0];
+ printRates("Rate of AIO, 30000 inserts / single commit at the end (again)", rate);
+
+ }
+
+ public void testAIOMultiThread() throws Exception
+ {
+ double[] rates = internalTestStorage(JournalType.ASYNCIO, 10000, -1, 1);
+ rates = internalTestStorage(JournalType.ASYNCIO, 30000, -1, 5);
+
+ printRates("Rate of AIO, 30000 inserts / single commit at the end", rates);
+
+
+ rates = internalTestStorage(JournalType.ASYNCIO, 5000, 1, 5);
+
+ printRates("Rate of AIO, 30000 inserts / commit on every insert", rates);
+ }
+
+ public void testNIO() throws Exception
+ {
+ // just to do some initial loading.. ignore this rate
+ internalTestStorage(JournalType.NIO, 1000, 1, 1);
+ double rate = internalTestStorage(JournalType.NIO, 1000, 1, 1)[0];
+ printRates("Rate of NIO, 1000 inserts, 1000 commits", rate);
+
+ rate = internalTestStorage(JournalType.NIO, 30000, -1, 1)[0];
+ printRates("Rate of NIO, 30000 inserts / single commit at the end", rate);
+
+ rate = internalTestStorage(JournalType.NIO, 30000, 5, 1)[0];
+ printRates("Rate of NIO, 30000 inserts / commit every 5 records", rate);
+ }
+
+ public void testNIOMultiThread() throws Exception
+ {
+
+ double[] rates = internalTestStorage(JournalType.NIO, 5000, -1, 5);
+
+ printRates("Rate of NIO, 5000 inserts / single commit at the end", rates);
+
+ rates = internalTestStorage(JournalType.NIO, 5000, 1, 5);
+
+ printRates("Rate of NIO, 5000 inserts / commit on every insert", rates);
+
+
+ }
+
+ public double[] internalTestStorage(final JournalType journalType,
+ final long numberOfMessages,
+ final int transInterval,
+ final int numberOfThreads) throws Exception
+ {
+ FileConfiguration configuration = new FileConfiguration();
+
+ configuration.start();
+
+ deleteDirectory(new File(configuration.getBindingsDirectory()));
+ deleteDirectory(new File(configuration.getJournalDirectory()));
+
+ configuration.setJournalType(journalType);
+
+ final JournalStorageManager journal = new JournalStorageManager(configuration);
+ journal.start();
+
+ FakePostOffice office = new FakePostOffice();
+
+ HashMap<Long, Queue> queues = new HashMap<Long, Queue>();
+
+ journal.loadMessages(office, queues);
+
+ final byte[] bytes = new byte[900];
+
+ for (int i=0;i<bytes.length;i++)
+ {
+ bytes[i] = (byte)('a' + (i%20));
+ }
+
+
+ final BufferWrapper buffer = new BufferWrapper(1024);
+ buffer.putBytes(bytes);
+
+ final AtomicLong transactionGenerator = new AtomicLong(1);
+
+ class LocalThread extends Thread
+ {
+ int id;
+ int commits = 1;
+ Exception e;
+ long totalTime = 0;
+ public LocalThread(int id)
+ {
+ super("LocalThread:" + id);
+ this.id = id;
+ }
+
+ public void run()
+ {
+ try
+ {
+ long start = System.currentTimeMillis();
+
+ long trans = transactionGenerator.incrementAndGet();
+ boolean commitPending=false;
+ for (long i=1;i<=numberOfMessages;i++)
+ {
+
+ final SimpleString address = new SimpleString("Destination " + i);
+
+
+ ServerMessageImpl implMsg = new ServerMessageImpl(/* type */ 1, /* durable */ true, /* expiration */ 0,
+ /* timestamp */ 0, /* priority */(byte)0);
+
+ implMsg.putStringProperty(new SimpleString("Key"), new SimpleString("This String is worthless!"));
+
+ implMsg.setMessageID(i);
+ implMsg.setBody(buffer);
+
+ implMsg.setDestination(address);
+
+
+
+ journal.storeMessageTransactional(trans, implMsg);
+
+ commitPending = true;
+
+ if (transInterval>0 && i%transInterval == 0)
+ {
+ journal.commit(trans);
+ commits ++;
+ trans = transactionGenerator.incrementAndGet();
+ commitPending = false;
+ }
+ }
+
+ if (commitPending) journal.commit(trans);
+
+
+ long end = System.currentTimeMillis();
+
+ totalTime = end - start;
+ }
+ catch (Exception e)
+ {
+ log.error(e.getMessage(), e);
+ this.e = e;
+ }
+ }
+ }
+
+ try
+ {
+ LocalThread[] threads = new LocalThread[numberOfThreads];
+
+
+ for (int i = 0; i < numberOfThreads; i++)
+ {
+ threads[i] = new LocalThread(i);
+ }
+
+ for (int i = 0; i < numberOfThreads; i++)
+ {
+ threads[i].start();
+ }
+
+ for (int i = 0; i < numberOfThreads; i++)
+ {
+ threads[i].join();
+ }
+
+ for (int i = 0; i < numberOfThreads; i++)
+ {
+ if (threads[i].e != null)
+ {
+ throw threads[i].e;
+ }
+ }
+
+ double rates[] = new double[numberOfThreads];
+
+ for (int i=0; i<numberOfThreads; i++)
+ {
+ rates[i] = (numberOfMessages + threads[i].commits) * 1000 / threads[i].totalTime;
+ }
+
+ return rates;
+ }
+ finally
+ {
+ journal.stop();
+ }
+
+ }
+
+
+ private void printRates(String msg, double rate)
+ {
+ printRates(msg, new double[] { rate });
+ }
+ private void printRates(String msg, double[] rates)
+ {
+ double rate = 0;
+
+ log.info("*************************************************************************");
+ log.info(" " + msg + " ");
+
+ double totalRate = 0;
+ for (int i=0; i<rates.length; i++)
+ {
+ rate = rates[i];
+ totalRate += rate;
+ if (rates.length>1)
+ {
+ log.info( " Thread " + i + ": = " + rate + " inserts/sec (including commits)");
+ }
+ }
+
+ log.info( " Total rate : = " + totalRate + " inserts/sec (including commits)");
+ log.info("*************************************************************************");
+ }
+
+
+}
Deleted: trunk/tests/src/org/jboss/messaging/tests/performance/remoting/MeasureBase.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/performance/remoting/MeasureBase.java 2008-05-22 12:29:03 UTC (rev 4282)
+++ trunk/tests/src/org/jboss/messaging/tests/performance/remoting/MeasureBase.java 2008-05-22 14:28:16 UTC (rev 4283)
@@ -1,193 +0,0 @@
-/*
- * JBoss, the OpenSource J2EE webOS
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-
-package org.jboss.messaging.tests.performance.remoting;
-
-import junit.framework.TestCase;
-
-import org.jboss.messaging.core.client.impl.ConnectionParamsImpl;
-import org.jboss.messaging.core.client.impl.LocationImpl;
-import org.jboss.messaging.core.client.impl.RemotingConnectionImpl;
-import org.jboss.messaging.core.config.impl.ConfigurationImpl;
-import org.jboss.messaging.core.remoting.Packet;
-import org.jboss.messaging.core.remoting.PacketDispatcher;
-import org.jboss.messaging.core.remoting.PacketHandler;
-import org.jboss.messaging.core.remoting.PacketReturner;
-import org.jboss.messaging.core.remoting.impl.mina.MinaService;
-import org.jboss.messaging.core.remoting.impl.wireformat.EmptyPacket;
-
-
-/**
- *
- * @author clebert suconic
- *
- */
-public abstract class MeasureBase extends TestCase
-{
- protected MinaService service;
- protected PacketDispatcher serverDispatcher;
-
- @Override
- public void setUp() throws Exception
- {
- super.setUp();
- startServer();
- serverDispatcher.register(new FakeHandler());
- }
-
- @Override
- public void tearDown() throws Exception
- {
- service.stop();
- }
-
-
- public void testMixingSends() throws Throwable
- {
- RemotingConnectionImpl remoting = new RemotingConnectionImpl(getLocation(), createParameters());
- remoting.start();
-
- int NUMBER_OF_MESSAGES = 300;
-
- long start = System.currentTimeMillis();
-
- for (int i=0; i<NUMBER_OF_MESSAGES; i++)
- {
- if (i%2 == 0)
- {
- remoting.sendOneWay(10, 10, new EmptyPacket(EmptyPacket.CLOSE));
- }
- else
- {
- Object ret = remoting.sendBlocking(10, 0, new EmptyPacket(EmptyPacket.CLOSE));
- assertTrue (ret instanceof EmptyPacket);
- //assertEquals(EmptyPacket.EXCEPTION, ret.getType());
- }
- }
-
- long end = System.currentTimeMillis();
-
-
- System.out.println("Messages / second = " + NUMBER_OF_MESSAGES * 1000 / (end-start));
- Thread.sleep(1000);
-
- remoting.stop();
-
- }
-
- public void testBlockSends() throws Throwable
- {
- //NIOConnector connector = createNIOConnector(new PacketDispatcherImpl(null));
- //NIOSession session = connector.connect();
-
-
-
- RemotingConnectionImpl remoting = new RemotingConnectionImpl(getLocation(), createParameters());
- remoting.start();
-
- int NUMBER_OF_MESSAGES = 100;
-
- long start = System.currentTimeMillis();
-
- for (int i=0; i<NUMBER_OF_MESSAGES; i++)
- {
- Object ret = remoting.sendBlocking(10, 10, new EmptyPacket(EmptyPacket.CLOSE));
- assertTrue (ret instanceof EmptyPacket);
- }
-
- long end = System.currentTimeMillis();
-
-
- System.out.println("Messages / second = " + NUMBER_OF_MESSAGES * 1000 / (end-start));
- Thread.sleep(1000);
-
- remoting.stop();
-
- }
-
- public void testOneWaySends() throws Throwable
- {
- //NIOConnector connector = createNIOConnector(new PacketDispatcherImpl(null));
- //NIOSession session = connector.connect();
-
-
- RemotingConnectionImpl remoting = new RemotingConnectionImpl(getLocation(), createParameters());
- remoting.start();
-
- int NUMBER_OF_MESSAGES = 30000;
-
- long start = System.currentTimeMillis();
-
- for (int i=0; i<NUMBER_OF_MESSAGES; i++)
- {
- remoting.sendOneWay(10, 10, new EmptyPacket(EmptyPacket.CLOSE));
- }
-
- remoting.sendBlocking(10, 10, new EmptyPacket(EmptyPacket.CLOSE));
-
- long end = System.currentTimeMillis();
-
-
- System.out.println("Messages / second = " + NUMBER_OF_MESSAGES * 1000 / (end-start));
-
- remoting.stop();
-
- }
-
- protected abstract LocationImpl getLocation();
-
- protected abstract ConfigurationImpl createConfiguration();
-
-
-
- protected void startServer() throws Exception
- {
- service = new MinaService(createConfiguration());
- service.start();
- serverDispatcher = service.getDispatcher();
- System.out.println("Server Dispatcher = " + serverDispatcher);
- }
-
- // Private
-
- protected ConnectionParamsImpl createParameters()
- {
- ConnectionParamsImpl param = new ConnectionParamsImpl();
- param.setTimeout(50000);
- return param;
- }
-
-
-
- // Inner Classes
-
- class FakeHandler implements PacketHandler
- {
-
- public long getID()
- {
- return 10;
- }
-
- public void handle(Packet packet, PacketReturner sender)
- {
- //System.out.println("Hello " + packet);
- try
- {
- if (packet.getResponseTargetID() >= 0)
- {
- packet.setTargetID(packet.getResponseTargetID());
- sender.send(packet);
- }
- } catch (Exception e)
- {
- e.printStackTrace();
- }
- }
- }
-
-}
Deleted: trunk/tests/src/org/jboss/messaging/tests/performance/remoting/MeasureInVMTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/performance/remoting/MeasureInVMTest.java 2008-05-22 12:29:03 UTC (rev 4282)
+++ trunk/tests/src/org/jboss/messaging/tests/performance/remoting/MeasureInVMTest.java 2008-05-22 14:28:16 UTC (rev 4283)
@@ -1,33 +0,0 @@
-/*
- * JBoss, the OpenSource J2EE webOS
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-
-package org.jboss.messaging.tests.performance.remoting;
-
-import org.jboss.messaging.core.client.impl.LocationImpl;
-import org.jboss.messaging.core.config.impl.ConfigurationImpl;
-import org.jboss.messaging.tests.unit.core.remoting.impl.ConfigurationHelper;
-
-
-/** This test was added to compare InVM calls against MINA calls */
-public class MeasureInVMTest extends MeasureBase
-{
-
- @Override
- protected LocationImpl getLocation()
- {
- return new LocationImpl(0);
-
- }
-
- protected ConfigurationImpl createConfiguration()
- {
- return ConfigurationHelper.newInVMConfig();
- }
-
-
-
-}
Deleted: trunk/tests/src/org/jboss/messaging/tests/performance/remoting/MeasureRemoteTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/performance/remoting/MeasureRemoteTest.java 2008-05-22 12:29:03 UTC (rev 4282)
+++ trunk/tests/src/org/jboss/messaging/tests/performance/remoting/MeasureRemoteTest.java 2008-05-22 14:28:16 UTC (rev 4283)
@@ -1,34 +0,0 @@
-/*
- * JBoss, the OpenSource J2EE webOS
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-
-package org.jboss.messaging.tests.performance.remoting;
-
-import static org.jboss.messaging.core.remoting.TransportType.TCP;
-
-import org.jboss.messaging.core.client.impl.LocationImpl;
-import org.jboss.messaging.core.config.impl.ConfigurationImpl;
-import org.jboss.messaging.tests.integration.core.remoting.mina.TestSupport;
-import org.jboss.messaging.tests.unit.core.remoting.impl.ConfigurationHelper;
-
-public class MeasureRemoteTest extends MeasureBase
-{
-
- @Override
- protected LocationImpl getLocation()
- {
- return new LocationImpl(TCP, "localhost", TestSupport.PORT);
- }
-
- @Override
- protected ConfigurationImpl createConfiguration()
- {
- return ConfigurationHelper.newTCPConfiguration("localhost", TestSupport.PORT);
- }
-
-
-
-}
Copied: trunk/tests/src/org/jboss/messaging/tests/performance/remoting/impl/MeasureBase.java (from rev 4282, trunk/tests/src/org/jboss/messaging/tests/performance/remoting/MeasureBase.java)
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/performance/remoting/impl/MeasureBase.java (rev 0)
+++ trunk/tests/src/org/jboss/messaging/tests/performance/remoting/impl/MeasureBase.java 2008-05-22 14:28:16 UTC (rev 4283)
@@ -0,0 +1,193 @@
+/*
+ * JBoss, the OpenSource J2EE webOS
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+
+package org.jboss.messaging.tests.performance.remoting.impl;
+
+import junit.framework.TestCase;
+
+import org.jboss.messaging.core.client.impl.ConnectionParamsImpl;
+import org.jboss.messaging.core.client.impl.LocationImpl;
+import org.jboss.messaging.core.client.impl.RemotingConnectionImpl;
+import org.jboss.messaging.core.config.impl.ConfigurationImpl;
+import org.jboss.messaging.core.remoting.Packet;
+import org.jboss.messaging.core.remoting.PacketDispatcher;
+import org.jboss.messaging.core.remoting.PacketHandler;
+import org.jboss.messaging.core.remoting.PacketReturner;
+import org.jboss.messaging.core.remoting.impl.mina.MinaService;
+import org.jboss.messaging.core.remoting.impl.wireformat.EmptyPacket;
+
+
+/**
+ *
+ * @author clebert suconic
+ *
+ */
+public abstract class MeasureBase extends TestCase
+{
+ protected MinaService service;
+ protected PacketDispatcher serverDispatcher;
+
+ @Override
+ public void setUp() throws Exception
+ {
+ super.setUp();
+ startServer();
+ serverDispatcher.register(new FakeHandler());
+ }
+
+ @Override
+ public void tearDown() throws Exception
+ {
+ service.stop();
+ }
+
+
+ public void testMixingSends() throws Throwable
+ {
+ RemotingConnectionImpl remoting = new RemotingConnectionImpl(getLocation(), createParameters());
+ remoting.start();
+
+ int NUMBER_OF_MESSAGES = 300;
+
+ long start = System.currentTimeMillis();
+
+ for (int i=0; i<NUMBER_OF_MESSAGES; i++)
+ {
+ if (i%2 == 0)
+ {
+ remoting.sendOneWay(10, 10, new EmptyPacket(EmptyPacket.CLOSE));
+ }
+ else
+ {
+ Object ret = remoting.sendBlocking(10, 0, new EmptyPacket(EmptyPacket.CLOSE));
+ assertTrue (ret instanceof EmptyPacket);
+ //assertEquals(EmptyPacket.EXCEPTION, ret.getType());
+ }
+ }
+
+ long end = System.currentTimeMillis();
+
+
+ System.out.println("Messages / second = " + NUMBER_OF_MESSAGES * 1000 / (end-start));
+ Thread.sleep(1000);
+
+ remoting.stop();
+
+ }
+
+ public void testBlockSends() throws Throwable
+ {
+ //NIOConnector connector = createNIOConnector(new PacketDispatcherImpl(null));
+ //NIOSession session = connector.connect();
+
+
+
+ RemotingConnectionImpl remoting = new RemotingConnectionImpl(getLocation(), createParameters());
+ remoting.start();
+
+ int NUMBER_OF_MESSAGES = 100;
+
+ long start = System.currentTimeMillis();
+
+ for (int i=0; i<NUMBER_OF_MESSAGES; i++)
+ {
+ Object ret = remoting.sendBlocking(10, 10, new EmptyPacket(EmptyPacket.CLOSE));
+ assertTrue (ret instanceof EmptyPacket);
+ }
+
+ long end = System.currentTimeMillis();
+
+
+ System.out.println("Messages / second = " + NUMBER_OF_MESSAGES * 1000 / (end-start));
+ Thread.sleep(1000);
+
+ remoting.stop();
+
+ }
+
+ public void testOneWaySends() throws Throwable
+ {
+ //NIOConnector connector = createNIOConnector(new PacketDispatcherImpl(null));
+ //NIOSession session = connector.connect();
+
+
+ RemotingConnectionImpl remoting = new RemotingConnectionImpl(getLocation(), createParameters());
+ remoting.start();
+
+ int NUMBER_OF_MESSAGES = 30000;
+
+ long start = System.currentTimeMillis();
+
+ for (int i=0; i<NUMBER_OF_MESSAGES; i++)
+ {
+ remoting.sendOneWay(10, 10, new EmptyPacket(EmptyPacket.CLOSE));
+ }
+
+ remoting.sendBlocking(10, 10, new EmptyPacket(EmptyPacket.CLOSE));
+
+ long end = System.currentTimeMillis();
+
+
+ System.out.println("Messages / second = " + NUMBER_OF_MESSAGES * 1000 / (end-start));
+
+ remoting.stop();
+
+ }
+
+ protected abstract LocationImpl getLocation();
+
+ protected abstract ConfigurationImpl createConfiguration();
+
+
+
+ protected void startServer() throws Exception
+ {
+ service = new MinaService(createConfiguration());
+ service.start();
+ serverDispatcher = service.getDispatcher();
+ System.out.println("Server Dispatcher = " + serverDispatcher);
+ }
+
+ // Private
+
+ protected ConnectionParamsImpl createParameters()
+ {
+ ConnectionParamsImpl param = new ConnectionParamsImpl();
+ param.setTimeout(50000);
+ return param;
+ }
+
+
+
+ // Inner Classes
+
+ class FakeHandler implements PacketHandler
+ {
+
+ public long getID()
+ {
+ return 10;
+ }
+
+ public void handle(Packet packet, PacketReturner sender)
+ {
+ //System.out.println("Hello " + packet);
+ try
+ {
+ if (packet.getResponseTargetID() >= 0)
+ {
+ packet.setTargetID(packet.getResponseTargetID());
+ sender.send(packet);
+ }
+ } catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+ }
+
+}
Copied: trunk/tests/src/org/jboss/messaging/tests/performance/remoting/impl/MeasureInVMTest.java (from rev 4282, trunk/tests/src/org/jboss/messaging/tests/performance/remoting/MeasureInVMTest.java)
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/performance/remoting/impl/MeasureInVMTest.java (rev 0)
+++ trunk/tests/src/org/jboss/messaging/tests/performance/remoting/impl/MeasureInVMTest.java 2008-05-22 14:28:16 UTC (rev 4283)
@@ -0,0 +1,33 @@
+/*
+ * JBoss, the OpenSource J2EE webOS
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+
+package org.jboss.messaging.tests.performance.remoting.impl;
+
+import org.jboss.messaging.core.client.impl.LocationImpl;
+import org.jboss.messaging.core.config.impl.ConfigurationImpl;
+import org.jboss.messaging.tests.unit.core.remoting.impl.ConfigurationHelper;
+
+
+/** This test was added to compare InVM calls against MINA calls */
+public class MeasureInVMTest extends MeasureBase
+{
+
+ @Override
+ protected LocationImpl getLocation()
+ {
+ return new LocationImpl(0);
+
+ }
+
+ protected ConfigurationImpl createConfiguration()
+ {
+ return ConfigurationHelper.newInVMConfig();
+ }
+
+
+
+}
Copied: trunk/tests/src/org/jboss/messaging/tests/performance/remoting/impl/MeasureRemoteTest.java (from rev 4282, trunk/tests/src/org/jboss/messaging/tests/performance/remoting/MeasureRemoteTest.java)
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/performance/remoting/impl/MeasureRemoteTest.java (rev 0)
+++ trunk/tests/src/org/jboss/messaging/tests/performance/remoting/impl/MeasureRemoteTest.java 2008-05-22 14:28:16 UTC (rev 4283)
@@ -0,0 +1,34 @@
+/*
+ * JBoss, the OpenSource J2EE webOS
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+
+package org.jboss.messaging.tests.performance.remoting.impl;
+
+import static org.jboss.messaging.core.remoting.TransportType.TCP;
+
+import org.jboss.messaging.core.client.impl.LocationImpl;
+import org.jboss.messaging.core.config.impl.ConfigurationImpl;
+import org.jboss.messaging.tests.integration.core.remoting.mina.TestSupport;
+import org.jboss.messaging.tests.unit.core.remoting.impl.ConfigurationHelper;
+
+public class MeasureRemoteTest extends MeasureBase
+{
+
+ @Override
+ protected LocationImpl getLocation()
+ {
+ return new LocationImpl(TCP, "localhost", TestSupport.PORT);
+ }
+
+ @Override
+ protected ConfigurationImpl createConfiguration()
+ {
+ return ConfigurationHelper.newTCPConfiguration("localhost", TestSupport.PORT);
+ }
+
+
+
+}
More information about the jboss-cvs-commits
mailing list