[jboss-cvs] JBoss Messaging SVN: r7702 - in trunk: src/main/org/jboss/messaging/core/management/impl and 10 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Aug 10 12:56:34 EDT 2009
Author: timfox
Date: 2009-08-10 12:56:33 -0400 (Mon, 10 Aug 2009)
New Revision: 7702
Modified:
trunk/src/main/org/jboss/messaging/core/client/impl/ClientSessionImpl.java
trunk/src/main/org/jboss/messaging/core/client/impl/ConnectionManager.java
trunk/src/main/org/jboss/messaging/core/client/impl/ConnectionManagerImpl.java
trunk/src/main/org/jboss/messaging/core/management/impl/MessagingServerControlImpl.java
trunk/src/main/org/jboss/messaging/core/remoting/FailureListener.java
trunk/src/main/org/jboss/messaging/core/remoting/impl/RemotingConnectionImpl.java
trunk/src/main/org/jboss/messaging/core/server/cluster/impl/BridgeImpl.java
trunk/src/main/org/jboss/messaging/core/server/impl/MessagingServerImpl.java
trunk/src/main/org/jboss/messaging/core/server/impl/ServerSessionImpl.java
trunk/src/main/org/jboss/messaging/jms/client/JBossConnection.java
trunk/src/main/org/jboss/messaging/jms/server/recovery/MessagingXAResourceWrapper.java
trunk/tests/src/org/jboss/messaging/tests/integration/client/SessionTest.java
trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/FailureListenerOnFailoverTest.java
trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/LargeMessageMultiThreadFailoverTest.java
trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/ReconnectTest.java
trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/SimpleAutomaticFailoverTest.java
trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/SimpleManualFailoverTest.java
trunk/tests/src/org/jboss/messaging/tests/integration/jms/server/management/JMSServerControl2Test.java
trunk/tests/src/org/jboss/messaging/tests/integration/remoting/PingTest.java
Log:
fixing test suite part I
Modified: trunk/src/main/org/jboss/messaging/core/client/impl/ClientSessionImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/client/impl/ClientSessionImpl.java 2009-08-10 15:51:01 UTC (rev 7701)
+++ trunk/src/main/org/jboss/messaging/core/client/impl/ClientSessionImpl.java 2009-08-10 16:56:33 UTC (rev 7702)
@@ -556,12 +556,12 @@
public void addFailureListener(final FailureListener listener)
{
- remotingConnection.addFailureListener(listener);
+ connectionManager.addFailureListener(listener);
}
public boolean removeFailureListener(final FailureListener listener)
{
- return remotingConnection.removeFailureListener(listener);
+ return connectionManager.removeFailureListener(listener);
}
public int getVersion()
@@ -571,7 +571,6 @@
// ClientSessionInternal implementation
// ------------------------------------------------------------
-
public int getMinLargeMessageSize()
{
@@ -1093,7 +1092,7 @@
// FailureListener implementation --------------------------------------------
- public boolean connectionFailed(final MessagingException me)
+ public void connectionFailed(final MessagingException me)
{
try
{
@@ -1103,8 +1102,6 @@
{
log.error("Failed to cleanup session");
}
-
- return true;
}
// Public
@@ -1275,10 +1272,7 @@
channel.close();
}
- if (!channel.getConnection().isDestroyed())
- {
- connectionManager.removeSession(this);
- }
+ connectionManager.removeSession(this);
}
private void cleanUpChildren() throws Exception
Modified: trunk/src/main/org/jboss/messaging/core/client/impl/ConnectionManager.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/client/impl/ConnectionManager.java 2009-08-10 15:51:01 UTC (rev 7701)
+++ trunk/src/main/org/jboss/messaging/core/client/impl/ConnectionManager.java 2009-08-10 16:56:33 UTC (rev 7702)
@@ -24,6 +24,7 @@
import org.jboss.messaging.core.client.ClientSession;
import org.jboss.messaging.core.exception.MessagingException;
+import org.jboss.messaging.core.remoting.FailureListener;
import org.jboss.messaging.core.remoting.RemotingConnection;
/**
@@ -66,4 +67,8 @@
RemotingConnection getConnection(final int initialRefCount);
void close();
+
+ void addFailureListener(FailureListener listener);
+
+ boolean removeFailureListener(FailureListener listener);
}
Modified: trunk/src/main/org/jboss/messaging/core/client/impl/ConnectionManagerImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/client/impl/ConnectionManagerImpl.java 2009-08-10 15:51:01 UTC (rev 7701)
+++ trunk/src/main/org/jboss/messaging/core/client/impl/ConnectionManagerImpl.java 2009-08-10 16:56:33 UTC (rev 7702)
@@ -63,6 +63,7 @@
import org.jboss.messaging.core.remoting.spi.ConnectorFactory;
import org.jboss.messaging.core.remoting.spi.MessagingBuffer;
import org.jboss.messaging.core.version.Version;
+import org.jboss.messaging.utils.ConcurrentHashSet;
import org.jboss.messaging.utils.ExecutorFactory;
import org.jboss.messaging.utils.OrderedExecutorFactory;
import org.jboss.messaging.utils.UUIDGenerator;
@@ -134,8 +135,6 @@
private Iterator<ConnectionEntry> mapIterator;
- private Object failConnectionLock = new Object();
-
private final long retryInterval;
private final double retryIntervalMultiplier; // For exponential backoff
@@ -146,8 +145,8 @@
private volatile boolean closed;
- private boolean inFailoverOrReconnect;
-
+ private Set<FailureListener> listeners = new ConcurrentHashSet<FailureListener>();
+
private Connector connector;
private Map<Object, Pinger> pingers = new ConcurrentHashMap<Object, Pinger>();
@@ -474,7 +473,18 @@
closed = true;
}
+
+ public void addFailureListener(FailureListener listener)
+ {
+ listeners.add(listener);
+ }
+ public boolean removeFailureListener(FailureListener listener)
+ {
+ return listeners.remove(listener);
+ }
+
+
// Public
// ---------------------------------------------------------------------------------------
@@ -503,19 +513,13 @@
// Private
// --------------------------------------------------------------------------------------
- private boolean handleConnectionFailure(final MessagingException me, final Object connectionID)
+ private void handleConnectionFailure(final MessagingException me, final Object connectionID)
{
- return !failoverOrReconnect(me, connectionID);
+ failoverOrReconnect(me, connectionID);
}
- private boolean failoverOrReconnect(final MessagingException me, final Object connectionID)
+ private void failoverOrReconnect(final MessagingException me, final Object connectionID)
{
- // To prevent recursion
- if (inFailoverOrReconnect)
- {
- return false;
- }
-
boolean done = false;
synchronized (failoverLock)
@@ -527,7 +531,7 @@
// came in for one of the already closed connections, so we return true - we don't want to call the
// listeners again
- return true;
+ return;
}
// Now get locks on all channel 1s, whilst holding the failoverLock - this makes sure
@@ -643,8 +647,6 @@
done = reattachSessions(reconnectAttempts);
}
- inFailoverOrReconnect = true;
-
if (done)
{
// Destroy the old connections
@@ -655,40 +657,56 @@
}
else
{
- // Fail the old connections so their listeners get called
-
- //We need to destroy the current connections - since we might have connected ok just couldn't
- //find session, but we don't want to call the FailureListeners on them - these will get called when
- //we close the old connections (which have the same failureListeners)
-
- for (ConnectionEntry entry : connections.values())
- {
- entry.connection.setFailureListeners(new ArrayList<FailureListener>());
+ for (RemotingConnection connection : oldConnections)
+ {
+ connection.destroy();
}
- failConnections(me);
-
- //Then we need to destroy the old connections - pingers will already have been closed for these
-
- for (RemotingConnection connection : oldConnections)
- {
- connection.fail(me);
- }
+ closeConnectionsAndCallFailureListeners(me);
}
}
else
{
- // Just fail the connections
-
- failConnections(me);
+ closeConnectionsAndCallFailureListeners(me);
}
-
- inFailoverOrReconnect = false;
-
}
+ }
+
+ private void closeConnectionsAndCallFailureListeners(final MessagingException me)
+ {
+ refCount = 0;
+ mapIterator = null;
+ checkCloseConnections();
+
+ //TODO (after beta5) should really execute on different thread then remove the async in JBossConnection
+
+// threadPool.execute(new Runnable()
+// {
+// public void run()
+// {
+ callFailureListeners(me);
+// }
+// });
+ }
+
+ private void callFailureListeners(final MessagingException me)
+ {
+ final List<FailureListener> listenersClone = new ArrayList<FailureListener>(listeners);
- return done;
-
+ for (final FailureListener listener : listenersClone)
+ {
+ try
+ {
+ listener.connectionFailed(me);
+ }
+ catch (final Throwable t)
+ {
+ // Failure of one listener to execute shouldn't prevent others
+ // from
+ // executing
+ log.error("Failed to execute failure listener", t);
+ }
+ }
}
private void closePingers()
@@ -1044,25 +1062,6 @@
}
}
- private void failConnections(final MessagingException me)
- {
- synchronized (failConnectionLock)
- {
- // When a single connection fails, we fail *all* the connections
-
- Set<ConnectionEntry> copy = new HashSet<ConnectionEntry>(connections.values());
-
- for (ConnectionEntry entry : copy)
- {
- entry.connection.fail(me);
- }
-
- refCount = 0;
-
- checkCloseConnections();
- }
- }
-
private ConnectorFactory instantiateConnectorFactory(final String connectorFactoryClassName)
{
ClassLoader loader = Thread.currentThread().getContextClassLoader();
@@ -1214,9 +1213,9 @@
this.connectionID = connectionID;
}
- public boolean connectionFailed(final MessagingException me)
+ public void connectionFailed(final MessagingException me)
{
- return handleConnectionFailure(me, connectionID);
+ handleConnectionFailure(me, connectionID);
}
}
Modified: trunk/src/main/org/jboss/messaging/core/management/impl/MessagingServerControlImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/management/impl/MessagingServerControlImpl.java 2009-08-10 15:51:01 UTC (rev 7701)
+++ trunk/src/main/org/jboss/messaging/core/management/impl/MessagingServerControlImpl.java 2009-08-10 16:56:33 UTC (rev 7702)
@@ -391,12 +391,15 @@
public String[] listRemoteAddresses()
{
+ log.info("listing remote addresses");
Set<RemotingConnection> connections = remotingService.getConnections();
String[] remoteAddresses = new String[connections.size()];
int i = 0;
for (RemotingConnection connection : connections)
{
+ log.info("connection " + connection + " is on server");
+
remoteAddresses[i++] = connection.getRemoteAddress();
}
return remoteAddresses;
Modified: trunk/src/main/org/jboss/messaging/core/remoting/FailureListener.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/FailureListener.java 2009-08-10 15:51:01 UTC (rev 7701)
+++ trunk/src/main/org/jboss/messaging/core/remoting/FailureListener.java 2009-08-10 16:56:33 UTC (rev 7702)
@@ -37,5 +37,5 @@
/**
* @return <code>false</code> to stop calling subsequent failure listeners
*/
- boolean connectionFailed(MessagingException me);
+ void connectionFailed(MessagingException me);
}
Modified: trunk/src/main/org/jboss/messaging/core/remoting/impl/RemotingConnectionImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/impl/RemotingConnectionImpl.java 2009-08-10 15:51:01 UTC (rev 7701)
+++ trunk/src/main/org/jboss/messaging/core/remoting/impl/RemotingConnectionImpl.java 2009-08-10 16:56:33 UTC (rev 7702)
@@ -104,6 +104,8 @@
{
this(transportConnection, -1, interceptors, active, false);
+
+ log.info("created server connection " + this);
}
private RemotingConnectionImpl(final Connection transportConnection,
@@ -390,12 +392,7 @@
{
try
{
- boolean callNext = listener.connectionFailed(me);
-
- if (!callNext)
- {
- break;
- }
+ listener.connectionFailed(me);
}
catch (final Throwable t)
{
Modified: trunk/src/main/org/jboss/messaging/core/server/cluster/impl/BridgeImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/cluster/impl/BridgeImpl.java 2009-08-10 15:51:01 UTC (rev 7701)
+++ trunk/src/main/org/jboss/messaging/core/server/cluster/impl/BridgeImpl.java 2009-08-10 16:56:33 UTC (rev 7702)
@@ -508,11 +508,9 @@
// FailureListener implementation --------------------------------
- public boolean connectionFailed(final MessagingException me)
+ public void connectionFailed(final MessagingException me)
{
fail();
-
- return true;
}
// Package protected ---------------------------------------------
Modified: trunk/src/main/org/jboss/messaging/core/server/impl/MessagingServerImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/impl/MessagingServerImpl.java 2009-08-10 15:51:01 UTC (rev 7701)
+++ trunk/src/main/org/jboss/messaging/core/server/impl/MessagingServerImpl.java 2009-08-10 16:56:33 UTC (rev 7702)
@@ -1087,11 +1087,9 @@
replicatingConnection.addFailureListener(new FailureListener()
{
- public boolean connectionFailed(MessagingException me)
+ public void connectionFailed(MessagingException me)
{
replicatingChannel.executeOutstandingDelayedResults();
-
- return true;
}
});
Modified: trunk/src/main/org/jboss/messaging/core/server/impl/ServerSessionImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/impl/ServerSessionImpl.java 2009-08-10 15:51:01 UTC (rev 7701)
+++ trunk/src/main/org/jboss/messaging/core/server/impl/ServerSessionImpl.java 2009-08-10 16:56:33 UTC (rev 7702)
@@ -1156,7 +1156,7 @@
// FailureListener implementation
// --------------------------------------------------------------------
- public boolean connectionFailed(final MessagingException me)
+ public void connectionFailed(final MessagingException me)
{
try
{
@@ -1182,8 +1182,6 @@
{
log.error("Failed to close connection " + this);
}
-
- return true;
}
public void connectionClosed()
Modified: trunk/src/main/org/jboss/messaging/jms/client/JBossConnection.java
===================================================================
--- trunk/src/main/org/jboss/messaging/jms/client/JBossConnection.java 2009-08-10 15:51:01 UTC (rev 7701)
+++ trunk/src/main/org/jboss/messaging/jms/client/JBossConnection.java 2009-08-10 16:56:33 UTC (rev 7702)
@@ -24,7 +24,6 @@
import java.util.HashSet;
import java.util.Set;
-import java.util.concurrent.Executor;
import javax.jms.Connection;
import javax.jms.ConnectionConsumer;
@@ -54,7 +53,6 @@
import org.jboss.messaging.core.logging.Logger;
import org.jboss.messaging.core.remoting.FailureListener;
import org.jboss.messaging.core.version.Version;
-import org.jboss.messaging.utils.OrderedExecutorFactory;
import org.jboss.messaging.utils.SimpleString;
import org.jboss.messaging.utils.UUIDGenerator;
import org.jboss.messaging.utils.VersionLoader;
@@ -532,19 +530,11 @@
private class JMSFailureListener implements FailureListener
{
- // Make sure it's only called once
- private boolean failed;
-
- public synchronized boolean connectionFailed(final MessagingException me)
+ public synchronized void connectionFailed(final MessagingException me)
{
- if (failed)
- {
- return true;
- }
-
if (me == null)
{
- return true;
+ return;
}
if (exceptionListener != null)
@@ -561,10 +551,6 @@
}
}).start();
}
-
- failed = true;
-
- return true;
}
}
Modified: trunk/src/main/org/jboss/messaging/jms/server/recovery/MessagingXAResourceWrapper.java
===================================================================
--- trunk/src/main/org/jboss/messaging/jms/server/recovery/MessagingXAResourceWrapper.java 2009-08-10 15:51:01 UTC (rev 7701)
+++ trunk/src/main/org/jboss/messaging/jms/server/recovery/MessagingXAResourceWrapper.java 2009-08-10 16:56:33 UTC (rev 7702)
@@ -220,11 +220,10 @@
}
}
- public boolean connectionFailed(MessagingException me)
+ public void connectionFailed(MessagingException me)
{
log.warn("Notified of connection failure in recovery connectionFactory for provider " + connectorFactoryClassName, me);
close();
- return true;
}
/**
Modified: trunk/tests/src/org/jboss/messaging/tests/integration/client/SessionTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/client/SessionTest.java 2009-08-10 15:51:01 UTC (rev 7701)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/client/SessionTest.java 2009-08-10 16:56:33 UTC (rev 7702)
@@ -60,10 +60,9 @@
final CountDownLatch latch = new CountDownLatch(1);
clientSession.addFailureListener(new FailureListener()
{
- public boolean connectionFailed(MessagingException me)
+ public void connectionFailed(MessagingException me)
{
latch.countDown();
- return false;
}
});
@@ -91,10 +90,9 @@
{
boolean called = false;
- public boolean connectionFailed(MessagingException me)
+ public void connectionFailed(MessagingException me)
{
called = true;
- return false;
}
}
Modified: trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/FailureListenerOnFailoverTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/FailureListenerOnFailoverTest.java 2009-08-10 15:51:01 UTC (rev 7701)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/FailureListenerOnFailoverTest.java 2009-08-10 16:56:33 UTC (rev 7702)
@@ -90,11 +90,9 @@
int failCount;
- public synchronized boolean connectionFailed(final MessagingException me)
+ public synchronized void connectionFailed(final MessagingException me)
{
failCount++;
-
- return true;
}
synchronized int getFailCount()
Modified: trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/LargeMessageMultiThreadFailoverTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/LargeMessageMultiThreadFailoverTest.java 2009-08-10 15:51:01 UTC (rev 7701)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/LargeMessageMultiThreadFailoverTest.java 2009-08-10 16:56:33 UTC (rev 7702)
@@ -69,8 +69,6 @@
{
return 60000;
}
-
-
protected ClientSessionFactoryInternal createSessionFactory()
{
Modified: trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/ReconnectTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/ReconnectTest.java 2009-08-10 15:51:01 UTC (rev 7701)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/ReconnectTest.java 2009-08-10 16:56:33 UTC (rev 7702)
@@ -263,11 +263,9 @@
{
volatile boolean failed;
- public boolean connectionFailed(MessagingException me)
+ public void connectionFailed(MessagingException me)
{
failed = true;
-
- return true;
}
}
Modified: trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/SimpleAutomaticFailoverTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/SimpleAutomaticFailoverTest.java 2009-08-10 15:51:01 UTC (rev 7701)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/SimpleAutomaticFailoverTest.java 2009-08-10 16:56:33 UTC (rev 7702)
@@ -650,11 +650,9 @@
class MyListener implements FailureListener
{
- public boolean connectionFailed(final MessagingException me)
+ public void connectionFailed(final MessagingException me)
{
latch.countDown();
-
- return true;
}
}
Modified: trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/SimpleManualFailoverTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/SimpleManualFailoverTest.java 2009-08-10 15:51:01 UTC (rev 7701)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/SimpleManualFailoverTest.java 2009-08-10 16:56:33 UTC (rev 7702)
@@ -133,11 +133,9 @@
class MyListener implements FailureListener
{
- public boolean connectionFailed(MessagingException me)
+ public void connectionFailed(MessagingException me)
{
latch.countDown();
-
- return true;
}
}
Modified: trunk/tests/src/org/jboss/messaging/tests/integration/jms/server/management/JMSServerControl2Test.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/jms/server/management/JMSServerControl2Test.java 2009-08-10 15:51:01 UTC (rev 7701)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/jms/server/management/JMSServerControl2Test.java 2009-08-10 16:56:33 UTC (rev 7702)
@@ -256,8 +256,6 @@
System.out.println(remoteAddress);
}
- log.info("*** closing connection");
-
connection.close();
Thread.sleep(2 * CONNECTION_TTL);
@@ -272,7 +270,6 @@
server.stop();
}
}
-
}
private void doCloseConnectionsForAddress(String acceptorFactory, String connectorFactory) throws Exception
Modified: trunk/tests/src/org/jboss/messaging/tests/integration/remoting/PingTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/remoting/PingTest.java 2009-08-10 15:51:01 UTC (rev 7701)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/remoting/PingTest.java 2009-08-10 16:56:33 UTC (rev 7702)
@@ -86,11 +86,9 @@
{
volatile MessagingException me;
- public boolean connectionFailed(MessagingException me)
+ public void connectionFailed(MessagingException me)
{
this.me = me;
-
- return true;
}
public MessagingException getException()
@@ -146,6 +144,8 @@
assertNull(serverListener.getException());
RemotingConnection serverConn2 = server.getRemotingService().getConnections().iterator().next();
+
+ log.info("Server conn2 is " + serverConn2);
assertTrue(serverConn == serverConn2);
More information about the jboss-cvs-commits
mailing list