[jboss-cvs] JBoss Messaging SVN: r6428 - branches/Branch_Temp_Clebert_LargeMessage/tests/src/org/jboss/messaging/tests/integration/cluster/failover.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Apr 14 15:33:08 EDT 2009
Author: clebert.suconic at jboss.com
Date: 2009-04-14 15:33:08 -0400 (Tue, 14 Apr 2009)
New Revision: 6428
Modified:
branches/Branch_Temp_Clebert_LargeMessage/tests/src/org/jboss/messaging/tests/integration/cluster/failover/MultiThreadFailoverSupport.java
branches/Branch_Temp_Clebert_LargeMessage/tests/src/org/jboss/messaging/tests/integration/cluster/failover/MultiThreadRandomFailoverTestBase.java
Log:
Changes before merge
Modified: branches/Branch_Temp_Clebert_LargeMessage/tests/src/org/jboss/messaging/tests/integration/cluster/failover/MultiThreadFailoverSupport.java
===================================================================
--- branches/Branch_Temp_Clebert_LargeMessage/tests/src/org/jboss/messaging/tests/integration/cluster/failover/MultiThreadFailoverSupport.java 2009-04-14 19:32:48 UTC (rev 6427)
+++ branches/Branch_Temp_Clebert_LargeMessage/tests/src/org/jboss/messaging/tests/integration/cluster/failover/MultiThreadFailoverSupport.java 2009-04-14 19:33:08 UTC (rev 6428)
@@ -20,7 +20,6 @@
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-
package org.jboss.messaging.tests.integration.cluster.failover;
import java.io.IOException;
@@ -36,8 +35,8 @@
import org.jboss.messaging.core.client.impl.ClientSessionImpl;
import org.jboss.messaging.core.exception.MessagingException;
import org.jboss.messaging.core.logging.Logger;
-import org.jboss.messaging.core.management.impl.QueueControl;
import org.jboss.messaging.core.remoting.impl.RemotingConnectionImpl;
+import org.jboss.messaging.core.remoting.impl.invm.InVMAcceptor;
import org.jboss.messaging.core.remoting.impl.invm.InVMConnector;
import org.jboss.messaging.core.remoting.impl.wireformat.SessionReceiveContinuationMessage;
import org.jboss.messaging.tests.util.ServiceTestBase;
@@ -57,7 +56,7 @@
{
// Constants -----------------------------------------------------
-
+
private final Logger log = Logger.getLogger(this.getClass());
// Attributes ----------------------------------------------------
@@ -77,146 +76,161 @@
protected abstract void start() throws Exception;
protected abstract void stop() throws Exception;
-
+
protected abstract ClientSessionFactoryInternal createSessionFactory();
-
+
protected void setUp() throws Exception
{
super.setUp();
timer = new Timer();
}
-
+
protected void tearDown() throws Exception
{
timer.cancel();
super.tearDown();
}
-
+
protected boolean shouldFail()
{
return true;
}
-
-
protected void runMultipleThreadsFailoverTest(final RunnableT runnable,
- final int numThreads,
- final int numIts,
- final boolean failOnCreateConnection,
- final long failDelay) throws Exception
+ final int numThreads,
+ final int numIts,
+ final boolean failOnCreateConnection,
+ final long failDelay) throws Exception
{
JVMTIInterface jvmti = new JVMTIInterface();
for (int its = 0; its < numIts; its++)
{
log.info("Beginning iteration " + its);
-
- start();
- final ClientSessionFactoryInternal sf = createSessionFactory();
+ doRun(runnable, numThreads, failOnCreateConnection, failDelay);
- final ClientSession session = sf.createSession(false, true, true);
+ checkForLeaks(jvmti);
- Failer failer = startFailer(failDelay, session, failOnCreateConnection);
+ }
- class Runner extends Thread
- {
- private volatile Throwable throwable;
+ }
- private final RunnableT test;
+ /**
+ * @param jvmti
+ * @throws InterruptedException
+ * @throws Exception
+ * @throws IOException
+ */
+ private void checkForLeaks(JVMTIInterface jvmti) throws InterruptedException, Exception, IOException
+ {
+ timer.cancel();
+ timer = new Timer();
- private final int threadNum;
+ Thread.sleep(10000);
+ jvmti.forceGC();
+ printReferences(jvmti, SessionReceiveContinuationMessage.class, 5, 10);
- Runner(final RunnableT test, final int threadNum)
- {
- this.test = test;
+ //printReferences(jvmti, InVMAcceptor.class);
- this.threadNum = threadNum;
- }
+ // printReferences(jvmti, SessionReceiveContinuationMessage.class);
+ }
- @Override
- public void run()
- {
- try
- {
- test.run(sf, threadNum);
- }
- catch (Throwable t)
- {
- throwable = t;
+ /**
+ * @param runnable
+ * @param numThreads
+ * @param failOnCreateConnection
+ * @param failDelay
+ * @throws Exception
+ * @throws MessagingException
+ * @throws InterruptedException
+ */
+ private void doRun(final RunnableT runnable,
+ final int numThreads,
+ final boolean failOnCreateConnection,
+ final long failDelay) throws Exception, MessagingException, InterruptedException
+ {
+ start();
- log.error("Failed to run test", t);
+ final ClientSessionFactoryInternal sf = createSessionFactory();
- // Case a failure happened here, it should print the Thread dump
- // Sending it to System.out, as it would show on the Tests report
- System.out.println(threadDump(" - fired by MultiThreadRandomFailoverTestBase::runTestMultipleThreads (" + t.getLocalizedMessage() + ")"));
- }
- }
- }
+ final ClientSession session = sf.createSession(false, true, true);
- do
- {
- List<Runner> threads = new ArrayList<Runner>();
+ Failer failer = startFailer(failDelay, session, failOnCreateConnection);
- for (int i = 0; i < numThreads; i++)
- {
- Runner runner = new Runner(runnable, i);
+ class Runner extends Thread
+ {
+ private volatile Throwable throwable;
- threads.add(runner);
+ private final RunnableT test;
- runner.start();
- }
+ private final int threadNum;
- for (Runner thread : threads)
+ Runner(final RunnableT test, final int threadNum)
+ {
+ this.test = test;
+
+ this.threadNum = threadNum;
+ }
+
+ @Override
+ public void run()
+ {
+ try
{
- thread.join();
-
- if (thread.throwable != null)
- {
- throw new Exception("Exception on thread " + thread, thread.throwable);
- }
+ test.run(sf, threadNum);
}
+ catch (Throwable t)
+ {
+ throwable = t;
- runnable.checkFail();
+ log.error("Failed to run test", t);
+ // Case a failure happened here, it should print the Thread dump
+ // Sending it to System.out, as it would show on the Tests report
+ System.out.println(threadDump(" - fired by MultiThreadRandomFailoverTestBase::runTestMultipleThreads (" + t.getLocalizedMessage() +
+ ")"));
+ }
}
- while (!failer.isExecuted());
+ }
- InVMConnector.resetFailures();
+ do
+ {
+ List<Runner> threads = new ArrayList<Runner>();
- session.close();
+ for (int i = 0; i < numThreads; i++)
+ {
+ Runner runner = new Runner(runnable, i);
- assertEquals(0, sf.numSessions());
+ threads.add(runner);
- assertEquals(0, sf.numConnections());
+ runner.start();
+ }
- stop();
-
-
-
+ for (Runner thread : threads)
{
- jvmti.forceGC();
-
- Object[] instances = jvmti.getAllObjects(SessionReceiveContinuationMessage.class);
-
- System.out.println("************* Containing " + instances.length + " of SessionReceiveContinuationMessage");
-
- if (instances.length > 10)
+ thread.join();
+
+ if (thread.throwable != null)
{
- instances = null;
- System.out.println(threadDump("Leak detection"));
-
- printReferences(jvmti, SessionReceiveContinuationMessage.class);
-
+ throw new Exception("Exception on thread " + thread, thread.throwable);
}
-
-
-
}
-
+
+ runnable.checkFail();
+
}
-
-
+ while (!failer.isExecuted());
+
+ InVMConnector.resetFailures();
+
+ session.close();
+
+ assertEquals(0, sf.numSessions());
+
+ assertEquals(0, sf.numConnections());
+
+ stop();
}
/**
@@ -225,28 +239,37 @@
* @throws Exception
* @throws IOException
*/
- private void printReferences(JVMTIInterface jvmti, Class<?> clazz) throws Exception, IOException
+ private void printReferences(JVMTIInterface jvmti, Class<?> clazz, int minOcur, int levels) throws Exception, IOException
{
Object instances[] = jvmti.getAllObjects(clazz);
-
+
if (instances.length > 0)
{
- Object obj = instances[0];
- instances = null;
-
- System.out.println("Inventory:\n" + jvmti.inventoryReport());
-
+ // System.out.println("Inventory:\n" + jvmti.inventoryReport());
+
Map map = jvmti.createIndexMatrix();
-
- System.out.println("References of " + clazz.getCanonicalName() + ": \n" +
- jvmti.exploreObjectReferences(map, obj, 10, false));
-
-
+
+ for (int i = 0; i < Math.min(instances.length, minOcur); i++)
+ {
+
+ System.out.println("References of " + clazz.getCanonicalName() +
+ "[" +
+ (i + 1) +
+ " of " +
+ instances.length +
+ "]" +
+ ": \n" +
+ jvmti.exploreObjectReferences(map, instances[i], levels, false));
+ }
+
jvmti.releaseTags();
}
+ else
+ {
+ System.out.println("############# no refernces for " + clazz.getCanonicalName());
+ }
}
-
// Private -------------------------------------------------------
private Failer startFailer(final long time, final ClientSession session, final boolean failOnCreateConnection)
@@ -262,10 +285,8 @@
return failer;
}
-
// Inner classes -------------------------------------------------
-
protected abstract class RunnableT extends Thread
{
private volatile String failReason;
@@ -293,8 +314,6 @@
public abstract void run(final ClientSessionFactory sf, final int threadNum) throws Exception;
}
-
-
private class Failer extends TimerTask
{
private final ClientSession session;
@@ -340,6 +359,4 @@
}
}
-
-
}
Modified: branches/Branch_Temp_Clebert_LargeMessage/tests/src/org/jboss/messaging/tests/integration/cluster/failover/MultiThreadRandomFailoverTestBase.java
===================================================================
--- branches/Branch_Temp_Clebert_LargeMessage/tests/src/org/jboss/messaging/tests/integration/cluster/failover/MultiThreadRandomFailoverTestBase.java 2009-04-14 19:32:48 UTC (rev 6427)
+++ branches/Branch_Temp_Clebert_LargeMessage/tests/src/org/jboss/messaging/tests/integration/cluster/failover/MultiThreadRandomFailoverTestBase.java 2009-04-14 19:33:08 UTC (rev 6428)
@@ -1365,8 +1365,8 @@
assertEquals(0, InVMRegistry.instance.size());
InVMRegistry.instance.clear();
- InVMConnection.recreateFactory();
- ConnectionManagerImpl.recreatePingExecutor();
+// InVMConnection.recreateFactory();
+// ConnectionManagerImpl.recreatePingExecutor();
}
private void sendMessages(final ClientSession sessSend,
More information about the jboss-cvs-commits
mailing list