Author: clebert.suconic(a)jboss.com
Date: 2010-07-30 14:12:11 -0400 (Fri, 30 Jul 2010)
New Revision: 9491
Added:
trunk/tests/src/org/hornetq/tests/soak/journal/JournalCleanupCompactSoakTest.java
Modified:
trunk/tests/src/org/hornetq/tests/stress/journal/JournalCleanupCompactStressTest.java
Log:
avoid OutOfMemoryException on soak test for very long runs (maximizing number of pending
records with a semaphore)
Added: trunk/tests/src/org/hornetq/tests/soak/journal/JournalCleanupCompactSoakTest.java
===================================================================
--- trunk/tests/src/org/hornetq/tests/soak/journal/JournalCleanupCompactSoakTest.java
(rev 0)
+++
trunk/tests/src/org/hornetq/tests/soak/journal/JournalCleanupCompactSoakTest.java 2010-07-30
18:12:11 UTC (rev 9491)
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2010 Red Hat, Inc.
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+package org.hornetq.tests.soak.journal;
+
+import java.util.concurrent.TimeUnit;
+
+import org.hornetq.tests.stress.journal.JournalCleanupCompactStressTest;
+
+/**
+ * A JournalCleanupCompactSoakTest
+ *
+ * @author <a href="mailto:clebert.suconic@jboss.org">Clebert
Suconic</a>
+ *
+ *
+ */
+public class JournalCleanupCompactSoakTest extends JournalCleanupCompactStressTest
+{
+
+ // Constants -----------------------------------------------------
+
+ // Attributes ----------------------------------------------------
+
+ // Static --------------------------------------------------------
+
+ // Constructors --------------------------------------------------
+
+ // Public --------------------------------------------------------
+
+ protected long getTotalTimeMilliseconds()
+ {
+ return TimeUnit.SECONDS.toMillis(1);
+ }
+
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+
+}
Modified:
trunk/tests/src/org/hornetq/tests/stress/journal/JournalCleanupCompactStressTest.java
===================================================================
---
trunk/tests/src/org/hornetq/tests/stress/journal/JournalCleanupCompactStressTest.java 2010-07-30
17:20:25 UTC (rev 9490)
+++
trunk/tests/src/org/hornetq/tests/stress/journal/JournalCleanupCompactStressTest.java 2010-07-30
18:12:11 UTC (rev 9491)
@@ -18,6 +18,7 @@
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
+import java.util.concurrent.Semaphore;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
@@ -51,6 +52,9 @@
{
public static SimpleIDGenerator idGen = new SimpleIDGenerator(1);
+
+ // We want to maximize the difference between appends and deles, or we could get out
of memory
+ public Semaphore maxRecords;
private volatile boolean running;
@@ -77,6 +81,8 @@
{
super.setUp();
+ maxRecords = new Semaphore(20000);
+
errors.set(0);
File dir = new File(getTemporaryDir());
@@ -235,6 +241,11 @@
LinkedBlockingDeque<Long> queue = new LinkedBlockingDeque<Long>();
OperationContextImpl ctx = new
OperationContextImpl(executorFactory.getExecutor());
+
+ public FastAppenderTx()
+ {
+ super("FastAppenderTX");
+ }
@Override
public void run()
@@ -255,7 +266,7 @@
long id = JournalCleanupCompactStressTest.idGen.generateID();
ids[i] = id;
journal.appendAddRecordTransactional(txID, id, (byte)0,
generateRecord());
- Thread.sleep(1);
+ maxRecords.acquire();
}
journal.appendCommitRecord(txID, true, ctx);
ctx.executeOnCompletion(new IOAsyncTask()
@@ -293,6 +304,7 @@
public FastUpdateTx(final LinkedBlockingDeque<Long> queue)
{
+ super("FastUpdateTX");
this.queue = queue;
}
@@ -350,6 +362,7 @@
for (long id : ids)
{
journal.appendDeleteRecord(id, false);
+ maxRecords.release();
numberOfDeletes.incrementAndGet();
}
}
@@ -373,6 +386,12 @@
*/
class SlowAppenderNoTX extends Thread
{
+
+ public SlowAppenderNoTX()
+ {
+ super("SlowAppender");
+ }
+
@Override
public void run()
{
@@ -386,6 +405,7 @@
{
System.out.println("append slow");
ids[i] = JournalCleanupCompactStressTest.idGen.generateID();
+ maxRecords.acquire();
journal.appendAddRecord(ids[i], (byte)1, generateRecord(), true);
numberOfRecords.incrementAndGet();