[jboss-cvs] JBoss Messaging SVN: r6146 - in trunk: src/main/org/jboss/messaging/core/client/impl and 48 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Mar 24 06:20:44 EDT 2009
Author: timfox
Date: 2009-03-24 06:20:42 -0400 (Tue, 24 Mar 2009)
New Revision: 6146
Modified:
trunk/src/config/ra.xml
trunk/src/main/org/jboss/messaging/core/client/impl/ClientSessionFactoryImpl.java
trunk/src/main/org/jboss/messaging/core/client/impl/ClientSessionImpl.java
trunk/src/main/org/jboss/messaging/core/client/impl/ClientSessionPacketHandler.java
trunk/src/main/org/jboss/messaging/core/client/impl/ConnectionManagerImpl.java
trunk/src/main/org/jboss/messaging/core/config/TransportConfiguration.java
trunk/src/main/org/jboss/messaging/core/config/cluster/BridgeConfiguration.java
trunk/src/main/org/jboss/messaging/core/config/cluster/ClusterConnectionConfiguration.java
trunk/src/main/org/jboss/messaging/core/config/impl/ConfigurationImpl.java
trunk/src/main/org/jboss/messaging/core/config/impl/FileConfiguration.java
trunk/src/main/org/jboss/messaging/core/management/BridgeControlMBean.java
trunk/src/main/org/jboss/messaging/core/management/ClusterConnectionControlMBean.java
trunk/src/main/org/jboss/messaging/core/management/ManagementService.java
trunk/src/main/org/jboss/messaging/core/management/impl/BridgeControl.java
trunk/src/main/org/jboss/messaging/core/management/impl/ClusterConnectionControl.java
trunk/src/main/org/jboss/messaging/core/management/impl/ManagementServiceImpl.java
trunk/src/main/org/jboss/messaging/core/management/jmx/impl/ReplicationAwareMessagingServerControlWrapper.java
trunk/src/main/org/jboss/messaging/core/persistence/StorageManager.java
trunk/src/main/org/jboss/messaging/core/persistence/impl/journal/JournalStorageManager.java
trunk/src/main/org/jboss/messaging/core/persistence/impl/nullpm/NullStorageManager.java
trunk/src/main/org/jboss/messaging/core/postoffice/impl/BindingsImpl.java
trunk/src/main/org/jboss/messaging/core/postoffice/impl/LocalQueueBinding.java
trunk/src/main/org/jboss/messaging/core/postoffice/impl/PostOfficeImpl.java
trunk/src/main/org/jboss/messaging/core/remoting/Channel.java
trunk/src/main/org/jboss/messaging/core/remoting/impl/RemotingConnectionImpl.java
trunk/src/main/org/jboss/messaging/core/remoting/impl/invm/InVMAcceptor.java
trunk/src/main/org/jboss/messaging/core/remoting/impl/invm/InVMConnection.java
trunk/src/main/org/jboss/messaging/core/remoting/impl/invm/InVMConnector.java
trunk/src/main/org/jboss/messaging/core/remoting/impl/wireformat/CreateQueueMessage.java
trunk/src/main/org/jboss/messaging/core/remoting/impl/wireformat/PacketImpl.java
trunk/src/main/org/jboss/messaging/core/remoting/impl/wireformat/replication/ReplicateRemoteConsumerAddedMessage.java
trunk/src/main/org/jboss/messaging/core/remoting/impl/wireformat/replication/ReplicateRemoteConsumerRemovedMessage.java
trunk/src/main/org/jboss/messaging/core/remoting/server/impl/RemotingServiceImpl.java
trunk/src/main/org/jboss/messaging/core/remoting/spi/Connection.java
trunk/src/main/org/jboss/messaging/core/server/MessagingServer.java
trunk/src/main/org/jboss/messaging/core/server/cluster/impl/BridgeImpl.java
trunk/src/main/org/jboss/messaging/core/server/cluster/impl/BroadcastGroupImpl.java
trunk/src/main/org/jboss/messaging/core/server/cluster/impl/ClusterConnectionImpl.java
trunk/src/main/org/jboss/messaging/core/server/cluster/impl/ClusterManagerImpl.java
trunk/src/main/org/jboss/messaging/core/server/cluster/impl/RemoteQueueBindingImpl.java
trunk/src/main/org/jboss/messaging/core/server/impl/MessagingServerImpl.java
trunk/src/main/org/jboss/messaging/core/server/impl/MessagingServerPacketHandler.java
trunk/src/main/org/jboss/messaging/core/server/impl/QueueImpl.java
trunk/src/main/org/jboss/messaging/core/server/impl/ServerConsumerImpl.java
trunk/src/main/org/jboss/messaging/core/server/impl/ServerSessionImpl.java
trunk/src/main/org/jboss/messaging/integration/transports/netty/MessagingChannelHandler.java
trunk/src/main/org/jboss/messaging/integration/transports/netty/NettyAcceptor.java
trunk/src/main/org/jboss/messaging/integration/transports/netty/NettyConnection.java
trunk/src/main/org/jboss/messaging/integration/transports/netty/NettyConnector.java
trunk/src/main/org/jboss/messaging/jms/client/JBossConnectionFactory.java
trunk/src/main/org/jboss/messaging/jms/server/JMSServerManager.java
trunk/src/main/org/jboss/messaging/jms/server/impl/JMSServerDeployer.java
trunk/src/main/org/jboss/messaging/jms/server/impl/JMSServerManagerImpl.java
trunk/src/main/org/jboss/messaging/jms/server/management/ConnectionFactoryControlMBean.java
trunk/src/main/org/jboss/messaging/jms/server/management/JMSServerControlMBean.java
trunk/src/main/org/jboss/messaging/jms/server/management/impl/ConnectionFactoryControl.java
trunk/src/main/org/jboss/messaging/jms/server/management/impl/JMSServerControl.java
trunk/src/main/org/jboss/messaging/jms/server/management/jmx/impl/ReplicationAwareConnectionFactoryControlWrapper.java
trunk/src/main/org/jboss/messaging/jms/server/management/jmx/impl/ReplicationAwareJMSServerControlWrapper.java
trunk/src/main/org/jboss/messaging/ra/JBMRAProperties.java
trunk/src/main/org/jboss/messaging/ra/JBMResourceAdapter.java
trunk/tests/config/log4j.xml
trunk/tests/jms-tests/src/org/jboss/test/messaging/jms/CTSMiscellaneousTest.java
trunk/tests/jms-tests/src/org/jboss/test/messaging/jms/JMSTestCase.java
trunk/tests/jms-tests/src/org/jboss/test/messaging/tools/container/LocalTestServer.java
trunk/tests/src/org/jboss/messaging/tests/integration/client/ClientConsumerTest.java
trunk/tests/src/org/jboss/messaging/tests/integration/client/ClientEndToEndTest.java
trunk/tests/src/org/jboss/messaging/tests/integration/client/ClientSessionFactoryTest.java
trunk/tests/src/org/jboss/messaging/tests/integration/clientcrash/ClientCrashTest.java
trunk/tests/src/org/jboss/messaging/tests/integration/clientcrash/CrashClient.java
trunk/tests/src/org/jboss/messaging/tests/integration/cluster/bridge/BridgeReconnectTest.java
trunk/tests/src/org/jboss/messaging/tests/integration/cluster/bridge/BridgeStartTest.java
trunk/tests/src/org/jboss/messaging/tests/integration/cluster/bridge/BridgeTest.java
trunk/tests/src/org/jboss/messaging/tests/integration/cluster/distribution/ClusterTestBase.java
trunk/tests/src/org/jboss/messaging/tests/integration/cluster/distribution/OneWayChainClusterTest.java
trunk/tests/src/org/jboss/messaging/tests/integration/cluster/distribution/SymmetricClusterTest.java
trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/FailoverTestBase.java
trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/FailureListenerOnFailoverTest.java
trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/FailureOnCreateConnectionTest.java
trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/MultiThreadFailoverSupport.java
trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/MultiThreadRandomFailoverTest.java
trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/MultiThreadRandomFailoverTestBase.java
trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/RandomFailoverTest.java
trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/ReconnectTest.java
trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/ReconnectWithBackupTest.java
trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/ReplicateConnectionFailureTest.java
trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/SimpleAutomaticFailoverTest.java
trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/XAMultiThreadRandomFailoverTest.java
trunk/tests/src/org/jboss/messaging/tests/integration/cluster/management/ReplicationAwareQueueControlWrapperTest.java
trunk/tests/src/org/jboss/messaging/tests/integration/http/NettyHttpTest.java
trunk/tests/src/org/jboss/messaging/tests/integration/jms/bridge/BridgeTestBase.java
trunk/tests/src/org/jboss/messaging/tests/integration/jms/cluster/JMSFailoverTest.java
trunk/tests/src/org/jboss/messaging/tests/integration/jms/consumer/ConsumerTest.java
trunk/tests/src/org/jboss/messaging/tests/integration/jms/management/JMSQueueControlTest.java
trunk/tests/src/org/jboss/messaging/tests/integration/jms/management/JMSServerControl2Test.java
trunk/tests/src/org/jboss/messaging/tests/integration/jms/management/JMSServerControlTest.java
trunk/tests/src/org/jboss/messaging/tests/integration/jms/management/JMSUtil.java
trunk/tests/src/org/jboss/messaging/tests/integration/management/BridgeControlTest.java
trunk/tests/src/org/jboss/messaging/tests/integration/management/ClusterConnectionControlTest.java
trunk/tests/src/org/jboss/messaging/tests/integration/remoting/PingTest.java
trunk/tests/src/org/jboss/messaging/tests/integration/xa/BasicXaRecoveryTest.java
trunk/tests/src/org/jboss/messaging/tests/integration/xa/BasicXaTest.java
trunk/tests/src/org/jboss/messaging/tests/stress/remote/PingStressTest.java
trunk/tests/src/org/jboss/messaging/tests/unit/core/persistence/impl/journal/JournalStorageManagerTest.java
trunk/tests/src/org/jboss/messaging/tests/util/ServiceTestBase.java
Log:
more clustering backup work, various fixes, tweaks other stuff etc
Modified: trunk/src/config/ra.xml
===================================================================
--- trunk/src/config/ra.xml 2009-03-23 19:56:44 UTC (rev 6145)
+++ trunk/src/config/ra.xml 2009-03-24 10:20:42 UTC (rev 6146)
@@ -223,14 +223,14 @@
<config-property-value></config-property-value>
</config-property>
<config-property>
- <description>The max retries before failover</description>
- <config-property-name>MaxRetriesBeforeFailover</config-property-name>
+ <description>The maximum number of initial connection attempts</description>
+ <config-property-name>InitialConnectAttempts</config-property-name>
<config-property-type>java.lang.Integer</config-property-type>
<config-property-value></config-property-value>
</config-property>
<config-property>
- <description>The max retries after failover</description>
- <config-property-name>MaxRetriesAfterFailover</config-property-name>
+ <description>The maximum number of reconnection attempts after failure is detected</description>
+ <config-property-name>ReconnectAttempts</config-property-name>
<config-property-type>java.lang.Integer</config-property-type>
<config-property-value></config-property-value>
</config-property>
Modified: trunk/src/main/org/jboss/messaging/core/client/impl/ClientSessionFactoryImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/client/impl/ClientSessionFactoryImpl.java 2009-03-23 19:56:44 UTC (rev 6145)
+++ trunk/src/main/org/jboss/messaging/core/client/impl/ClientSessionFactoryImpl.java 2009-03-24 10:20:42 UTC (rev 6146)
@@ -89,9 +89,9 @@
public static final double DEFAULT_RETRY_INTERVAL_MULTIPLIER = 1d;
- public static final int DEFAULT_MAX_RETRIES_BEFORE_FAILOVER = 0;
+ public static final int DEFAULT_INITIAL_CONNECT_ATTEMPTS = 1;
- public static final int DEFAULT_MAX_RETRIES_AFTER_FAILOVER = 0;
+ public static final int DEFAULT_RECONNECT_ATTEMPTS = 0;
// Attributes
// -----------------------------------------------------------------------------------
@@ -147,9 +147,9 @@
private final double retryIntervalMultiplier; // For exponential backoff
- private final int maxRetriesBeforeFailover;
+ private final int initialConnectAttempts;
- private final int maxRetriesAfterFailover;
+ private final int reconnectAttempts;
// Static
// ---------------------------------------------------------------------------------------
@@ -201,8 +201,8 @@
this.preAcknowledge = DEFAULT_PRE_ACKNOWLEDGE;
this.retryInterval = DEFAULT_RETRY_INTERVAL;
this.retryIntervalMultiplier = DEFAULT_RETRY_INTERVAL_MULTIPLIER;
- this.maxRetriesBeforeFailover = DEFAULT_MAX_RETRIES_BEFORE_FAILOVER;
- this.maxRetriesAfterFailover = DEFAULT_MAX_RETRIES_AFTER_FAILOVER;
+ this.initialConnectAttempts = DEFAULT_INITIAL_CONNECT_ATTEMPTS;
+ this.reconnectAttempts = DEFAULT_RECONNECT_ATTEMPTS;
}
public ClientSessionFactoryImpl(final String discoveryGroupAddress,
@@ -227,8 +227,8 @@
final int ackBatchSize,
final long retryInterval,
final double retryIntervalMultiplier,
- final int maxRetriesBeforeFailover,
- final int maxRetriesAfterFailover) throws MessagingException
+ final int initialConnectAttempts,
+ final int reconnectAttempts) throws MessagingException
{
try
{
@@ -269,8 +269,8 @@
this.preAcknowledge = preAcknowledge;
this.retryInterval = retryInterval;
this.retryIntervalMultiplier = retryIntervalMultiplier;
- this.maxRetriesBeforeFailover = maxRetriesBeforeFailover;
- this.maxRetriesAfterFailover = maxRetriesAfterFailover;
+ this.initialConnectAttempts = initialConnectAttempts;
+ this.reconnectAttempts = reconnectAttempts;
}
public ClientSessionFactoryImpl(final List<Pair<TransportConfiguration, TransportConfiguration>> connectors,
@@ -292,8 +292,8 @@
final int ackBatchSize,
final long retryInterval,
final double retryIntervalMultiplier,
- final int maxRetriesBeforeFailover,
- final int maxRetriesAfterFailover)
+ final int initialConnectAttempts,
+ final int reconnectAttempts)
{
this.loadBalancingPolicy = instantiateLoadBalancingPolicy(connectionloadBalancingPolicyClassName);
this.pingPeriod = pingPeriod;
@@ -313,8 +313,8 @@
this.preAcknowledge = preAcknowledge;
this.retryInterval = retryInterval;
this.retryIntervalMultiplier = retryIntervalMultiplier;
- this.maxRetriesBeforeFailover = maxRetriesBeforeFailover;
- this.maxRetriesAfterFailover = maxRetriesAfterFailover;
+ this.initialConnectAttempts = initialConnectAttempts;
+ this.reconnectAttempts = reconnectAttempts;
this.initialWaitTimeout = -1;
@@ -328,8 +328,8 @@
connectionTTL,
retryInterval,
retryIntervalMultiplier,
- maxRetriesBeforeFailover,
- maxRetriesAfterFailover);
+ initialConnectAttempts,
+ reconnectAttempts);
connectionManagerMap.put(pair, cm);
}
@@ -343,8 +343,8 @@
final TransportConfiguration backupConnectorConfig,
final long retryInterval,
final double retryIntervalMultiplier,
- final int maxRetriesBeforeFailover,
- final int maxRetriesAfterFailover)
+ final int initialConnectAttempts,
+ final int reconnectAttempts)
{
this.loadBalancingPolicy = new FirstElementConnectionLoadBalancingPolicy();
this.pingPeriod = DEFAULT_PING_PERIOD;
@@ -364,8 +364,8 @@
this.preAcknowledge = DEFAULT_PRE_ACKNOWLEDGE;
this.retryInterval = retryInterval;
this.retryIntervalMultiplier = retryIntervalMultiplier;
- this.maxRetriesBeforeFailover = maxRetriesBeforeFailover;
- this.maxRetriesAfterFailover = maxRetriesAfterFailover;
+ this.initialConnectAttempts = initialConnectAttempts;
+ this.reconnectAttempts = reconnectAttempts;
this.initialWaitTimeout = -1;
@@ -380,8 +380,8 @@
connectionTTL,
retryInterval,
retryIntervalMultiplier,
- maxRetriesBeforeFailover,
- maxRetriesAfterFailover);
+ initialConnectAttempts,
+ reconnectAttempts);
connectionManagerMap.put(pair, cm);
@@ -393,8 +393,8 @@
public ClientSessionFactoryImpl(final TransportConfiguration connectorConfig,
final long retryInterval,
final double retryIntervalMultiplier,
- final int maxRetriesBeforeFailover,
- final int maxRetriesAfterFailover)
+ final int initialConnectAttempts,
+ final int reconnectAttempts)
{
this.loadBalancingPolicy = new FirstElementConnectionLoadBalancingPolicy();
this.pingPeriod = DEFAULT_PING_PERIOD;
@@ -414,8 +414,8 @@
this.preAcknowledge = DEFAULT_PRE_ACKNOWLEDGE;
this.retryInterval = retryInterval;
this.retryIntervalMultiplier = retryIntervalMultiplier;
- this.maxRetriesBeforeFailover = maxRetriesBeforeFailover;
- this.maxRetriesAfterFailover = maxRetriesAfterFailover;
+ this.initialConnectAttempts = initialConnectAttempts;
+ this.reconnectAttempts = reconnectAttempts;
this.initialWaitTimeout = -1;
@@ -430,8 +430,8 @@
connectionTTL,
retryInterval,
retryIntervalMultiplier,
- maxRetriesBeforeFailover,
- maxRetriesAfterFailover);
+ initialConnectAttempts,
+ reconnectAttempts);
connectionManagerMap.put(pair, cm);
@@ -442,7 +442,7 @@
public ClientSessionFactoryImpl(final TransportConfiguration connectorConfig,
final TransportConfiguration backupConfig)
- {
+ {
this.loadBalancingPolicy = new FirstElementConnectionLoadBalancingPolicy();
this.pingPeriod = DEFAULT_PING_PERIOD;
this.callTimeout = DEFAULT_CALL_TIMEOUT;
@@ -461,8 +461,8 @@
this.preAcknowledge = DEFAULT_PRE_ACKNOWLEDGE;
this.retryInterval = DEFAULT_RETRY_INTERVAL;
this.retryIntervalMultiplier = DEFAULT_RETRY_INTERVAL_MULTIPLIER;
- this.maxRetriesBeforeFailover = DEFAULT_MAX_RETRIES_BEFORE_FAILOVER;
- this.maxRetriesAfterFailover = DEFAULT_MAX_RETRIES_AFTER_FAILOVER;
+ this.initialConnectAttempts = DEFAULT_INITIAL_CONNECT_ATTEMPTS;
+ this.reconnectAttempts = DEFAULT_RECONNECT_ATTEMPTS;
this.initialWaitTimeout = -1;
@@ -477,8 +477,8 @@
connectionTTL,
retryInterval,
retryIntervalMultiplier,
- maxRetriesBeforeFailover,
- maxRetriesAfterFailover);
+ initialConnectAttempts,
+ reconnectAttempts);
connectionManagerMap.put(pair, cm);
@@ -507,8 +507,8 @@
final int ackBatchSize,
final long retryInterval,
final double retryIntervalMultiplier,
- final int maxRetriesBeforeFailover,
- final int maxRetriesAfterFailover)
+ final int initialConnectAttempts,
+ final int reconnectAttempts)
{
this.loadBalancingPolicy = instantiateLoadBalancingPolicy(connectionloadBalancingPolicyClassName);
this.pingPeriod = pingPeriod;
@@ -528,8 +528,8 @@
this.preAcknowledge = preAcknowledge;
this.retryInterval = retryInterval;
this.retryIntervalMultiplier = retryIntervalMultiplier;
- this.maxRetriesBeforeFailover = maxRetriesBeforeFailover;
- this.maxRetriesAfterFailover = maxRetriesAfterFailover;
+ this.initialConnectAttempts = initialConnectAttempts;
+ this.reconnectAttempts = reconnectAttempts;
this.initialWaitTimeout = -1;
@@ -543,8 +543,8 @@
connectionTTL,
retryInterval,
retryIntervalMultiplier,
- maxRetriesBeforeFailover,
- maxRetriesAfterFailover);
+ initialConnectAttempts,
+ reconnectAttempts);
connectionManagerMap.put(pair, cm);
@@ -558,7 +558,12 @@
*/
public ClientSessionFactoryImpl(final TransportConfiguration connectorConfig)
{
- this(connectorConfig, null, 0, 0, 0, 0);
+ this(connectorConfig,
+ null,
+ DEFAULT_RETRY_INTERVAL,
+ DEFAULT_RETRY_INTERVAL_MULTIPLIER,
+ DEFAULT_INITIAL_CONNECT_ATTEMPTS,
+ DEFAULT_RECONNECT_ATTEMPTS);
}
// ClientSessionFactory implementation------------------------------------------------------------
@@ -811,8 +816,8 @@
connectionTTL,
retryInterval,
retryIntervalMultiplier,
- maxRetriesBeforeFailover,
- maxRetriesAfterFailover);
+ initialConnectAttempts,
+ reconnectAttempts);
connectionManagerMap.put(connectorPair, connectionManager);
}
Modified: trunk/src/main/org/jboss/messaging/core/client/impl/ClientSessionImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/client/impl/ClientSessionImpl.java 2009-03-23 19:56:44 UTC (rev 6145)
+++ trunk/src/main/org/jboss/messaging/core/client/impl/ClientSessionImpl.java 2009-03-24 10:20:42 UTC (rev 6146)
@@ -624,7 +624,7 @@
started = false;
}
}
-
+
public void addFailureListener(final FailureListener listener)
{
remotingConnection.addFailureListener(listener);
@@ -721,7 +721,6 @@
if (consumer != null)
{
consumer.handleLargeMessage(message);
-
}
}
@@ -734,7 +733,7 @@
consumer.handleLargeMessageContinuation(continuation);
}
}
-
+
public void close() throws MessagingException
{
if (closed)
@@ -822,6 +821,8 @@
//
// however if session re-attach fails and the session was not in a call to close, then we DO want to call
// the session listeners so we return false
+ //
+ // Also session reattach will fail if the server is restarted - so the session is lost
ok = true;
}
else
Modified: trunk/src/main/org/jboss/messaging/core/client/impl/ClientSessionPacketHandler.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/client/impl/ClientSessionPacketHandler.java 2009-03-23 19:56:44 UTC (rev 6145)
+++ trunk/src/main/org/jboss/messaging/core/client/impl/ClientSessionPacketHandler.java 2009-03-24 10:20:42 UTC (rev 6146)
@@ -31,8 +31,8 @@
import org.jboss.messaging.core.remoting.ChannelHandler;
import org.jboss.messaging.core.remoting.Packet;
import org.jboss.messaging.core.remoting.impl.wireformat.MessagingExceptionMessage;
+import org.jboss.messaging.core.remoting.impl.wireformat.SessionReceiveContinuationMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.SessionReceiveMessage;
-import org.jboss.messaging.core.remoting.impl.wireformat.SessionReceiveContinuationMessage;
/**
*
Modified: trunk/src/main/org/jboss/messaging/core/client/impl/ConnectionManagerImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/client/impl/ConnectionManagerImpl.java 2009-03-23 19:56:44 UTC (rev 6145)
+++ trunk/src/main/org/jboss/messaging/core/client/impl/ConnectionManagerImpl.java 2009-03-24 10:20:42 UTC (rev 6146)
@@ -32,6 +32,7 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.locks.Lock;
@@ -66,7 +67,7 @@
*
*
*/
-public class ConnectionManagerImpl implements ConnectionManager, FailureListener, ConnectionLifeCycleListener
+public class ConnectionManagerImpl implements ConnectionManager, ConnectionLifeCycleListener
{
// Constants
// ------------------------------------------------------------------------------------
@@ -78,6 +79,10 @@
// Attributes
// -----------------------------------------------------------------------------------
+ private final TransportConfiguration connectorConfig;
+
+ private final TransportConfiguration backupConfig;
+
private ConnectorFactory connectorFactory;
private Map<String, Object> transportParams;
@@ -112,6 +117,8 @@
private int refCount;
+ private boolean connected;
+
private Iterator<ConnectionEntry> mapIterator;
private Object failConnectionLock = new Object();
@@ -120,12 +127,27 @@
private final double retryIntervalMultiplier; // For exponential backoff
- private final int maxRetriesBeforeFailover;
+ private final int initialConnectAttempts;
- private final int maxRetriesAfterFailover;
+ private final int reconnectAttempts;
private volatile boolean closed;
+ private boolean inFailoverOrReconnect;
+
+ // debug
+
+ private static Map<TransportConfiguration, Set<RemotingConnection>> debugConns;
+
+ private static boolean debug = false;
+
+ public static void enableDebug()
+ {
+ debug = true;
+
+ debugConns = new ConcurrentHashMap<TransportConfiguration, Set<RemotingConnection>>();
+ }
+
// Static
// ---------------------------------------------------------------------------------------
@@ -140,9 +162,13 @@
final long connectionTTL,
final long retryInterval,
final double retryIntervalMultiplier,
- final int maxRetriesBeforeFailover,
- final int maxRetriesAfterFailover)
+ final int initialConnectAttempts,
+ final int reconnectAttempts)
{
+ this.connectorConfig = connectorConfig;
+
+ this.backupConfig = backupConfig;
+
connectorFactory = instantiateConnectorFactory(connectorConfig.getFactoryClassName());
transportParams = connectorConfig.getParams();
@@ -172,9 +198,9 @@
this.retryIntervalMultiplier = retryIntervalMultiplier;
- this.maxRetriesBeforeFailover = maxRetriesBeforeFailover;
+ this.initialConnectAttempts = initialConnectAttempts;
- this.maxRetriesAfterFailover = maxRetriesAfterFailover;
+ this.reconnectAttempts = reconnectAttempts;
}
// ConnectionLifeCycleListener implementation --------------------
@@ -185,22 +211,15 @@
public void connectionDestroyed(final Object connectionID)
{
- // If conn still exists here this means that the underlying transport
- // conn has been closed from the server side without
- // being returned from the client side so we need to fail the conn and
- // call it's listeners
- if (connections.containsKey(connectionID))
- {
- MessagingException me = new MessagingException(MessagingException.OBJECT_CLOSED,
- "The conn has been closed by the server");
+ MessagingException me = new MessagingException(MessagingException.OBJECT_CLOSED,
+ "The connection has been closed by the server");
- failConnection(me);
- }
+ failoverOrReconnect(me, connectionID);
}
public void connectionException(final Object connectionID, final MessagingException me)
{
- failConnection(me);
+ failoverOrReconnect(me, connectionID);
}
// ConnectionManager implementation ------------------------------------------------------------------
@@ -225,7 +244,7 @@
synchronized (createSessionLock)
{
String name = UUIDGenerator.getInstance().generateSimpleStringUUID().toString();
-
+
boolean retry = false;
do
{
@@ -248,7 +267,7 @@
// This can happen if the connection manager gets closed - e.g. the server gets shut down
return null;
}
-
+
channel1 = connection.getChannel(1, -1, false);
// Lock it - this must be done while the failoverLock is held
@@ -321,18 +340,20 @@
sessionChannel.setHandler(handler);
- connection.addFailureListener(this);
+ connected = true;
return session;
}
}
catch (Throwable t)
{
- if(lock != null)
+ if (lock != null)
{
lock.unlock();
+
lock = null;
}
+
if (connection != null)
{
returnConnection(connection.getID());
@@ -389,7 +410,7 @@
throw new IllegalStateException("Cannot find session to remove " + session);
}
- this.returnConnection(session.getConnection().getID());
+ returnConnection(session.getConnection().getID());
}
}
}
@@ -409,11 +430,11 @@
closed = true;
}
- // FailureListener implementation --------------------------------------------------------
+ private boolean handleConnectionFailed(final MessagingException me, final Object connectionID)
+ {
+ boolean callNext = !failoverOrReconnect(me, connectionID);
- public boolean connectionFailed(final MessagingException me)
- {
- return !failover();
+ return callNext;
}
// Public
@@ -430,46 +451,91 @@
private RemotingConnection getConnectionForCreateSession() throws MessagingException
{
- while (true)
+ int connectAttempts = connected ? 2 : initialConnectAttempts;
+
+ int count = 0;
+
+ if (connectAttempts != 0)
{
- if (closed)
+ while (true)
{
- return null;
- }
+ if (closed)
+ {
+ return null;
+ }
- RemotingConnection connection = getConnection(1);
+ RemotingConnection connection = getConnection(1);
- if (connection == null)
- {
- // Connection is dead - failover/reconnect
- boolean failedOver = failover();
-
- if (!failedOver)
+ if (connection == null)
{
- // Nothing we can do here
- throw new MessagingException(MessagingException.NOT_CONNECTED,
- "Unabled to create session - server is unavailable and no backup server or backup is unavailable");
- }
+ // We failed to get a connection
- try
- {
- Thread.sleep(retryInterval);
+ // We now call failover() - this will attempt to reconnect/failover any pre-existing connections
+ // If there are no pre-existing connections it will just return true, so we need to continue in a loop
+ // here
+
+ MessagingException me = new MessagingException(MessagingException.NOT_CONNECTED,
+ "Unabled to create session - server is unavailable and no backup server or backup is unavailable");
+
+ boolean failedOver = failoverOrReconnect(me, null);
+
+ if (!failedOver)
+ {
+ // Nothing we can do here
+ throw me;
+ }
+
+ if (connectAttempts != -1)
+ {
+ count++;
+
+ if (count == connectAttempts)
+ {
+ break;
+ }
+ }
+
+ try
+ {
+ Thread.sleep(retryInterval);
+ }
+ catch (Exception ignore)
+ {
+ }
}
- catch (Exception ignore)
+ else
{
+ return connection;
}
}
- else
- {
- return connection;
- }
}
+
+ throw new MessagingException(MessagingException.NOT_CONNECTED,
+ "Unabled to create session after " + connectAttempts + " attempts");
}
- private boolean failover()
+ private boolean failoverOrReconnect(final MessagingException me, final Object connectionID)
{
+ // To prevent recursion
+ if (inFailoverOrReconnect)
+ {
+ return false;
+ }
+
synchronized (failoverLock)
{
+ if (connectionID != null && !connections.containsKey(connectionID))
+ {
+ // We already failed over - probably the first failure came in, all the connetions were failed over then a
+ // async connection exception or disconnect
+ // came in for one of the already closed connections, so we return true - we don't want to call the
+ // listeners again
+
+ return true;
+ }
+
+ inFailoverOrReconnect = true;
+
// Now get locks on all channel 1s, whilst holding the failoverLock - this makes sure
// There are either no threads executing in createSession, or one is blocking on a createSession
// result.
@@ -495,10 +561,21 @@
// It can then release the channel 1 lock, and retry (which will cause locking on failoverLock
// until failover is complete
- if (backupConnectorFactory != null || maxRetriesBeforeFailover != 0 || maxRetriesAfterFailover != 0)
+ boolean done = false;
+
+ int connectAttempts;
+
+ if (!connected)
{
- log.info("Commencing automatic failover / reconnection");
+ connectAttempts = initialConnectAttempts;
+ }
+ else
+ {
+ connectAttempts = backupConnectorFactory == null ? reconnectAttempts : 0;
+ }
+ if (backupConnectorFactory != null || connectAttempts != 0)
+ {
lockAllChannel1s();
final boolean needToInterrupt;
@@ -515,7 +592,7 @@
// Forcing return all channels won't guarantee that any blocked thread will return immediately
// So we need to wait for it
forceReturnAllChannel1s();
-
+
// Now we need to make sure that the thread has actually exited and returned it's connections
// before failover occurs
@@ -552,64 +629,65 @@
mapIterator = null;
- boolean done = false;
-
- if (maxRetriesBeforeFailover != 0)
+ if (connectAttempts != 0)
{
// First try reconnecting to current node if configured to do this
- done = reconnect(maxRetriesBeforeFailover);
+ done = reattachSessions(connectAttempts);
}
-
- if (!done)
+ else
{
- // If didn't reconnect to current node then try failover to backup
+ // Now try failing over to backup
- int retries = maxRetriesAfterFailover;
+ connectorFactory = backupConnectorFactory;
- if (backupConnectorFactory != null)
- {
- connectorFactory = backupConnectorFactory;
+ transportParams = backupTransportParams;
- transportParams = backupTransportParams;
-
- if (maxRetriesAfterFailover == 0)
- {
- retries = 1;
- }
- }
-
backupConnectorFactory = null;
backupTransportParams = null;
- done = reconnect(retries);
+ done = reattachSessions(connectAttempts);
}
- for (RemotingConnection connection : oldConnections)
+ if (done)
{
- connection.destroy();
+ // Destroy the old connections
+ for (RemotingConnection connection : oldConnections)
+ {
+ connection.destroy();
+ }
}
-
- if (done)
+ else
{
- log.info("Automatic failover / reconnection successful");
+ // Fail the old connections so their listeners get called
+ for (RemotingConnection connection : oldConnections)
+ {
+ connection.fail(me);
+ }
}
-
- return done;
}
else
{
- return false;
+ // Just fail the connections
+
+ failConnection(me);
}
+
+ inFailoverOrReconnect = false;
+
+ return done;
}
}
- private boolean reconnect(final int retries)
+ /*
+ * Re-attach sessions all pre-existing sessions to new remoting connections
+ */
+ private boolean reattachSessions(final int connectAttempts)
{
- // We fail over sessions per connection to ensure there is the same mapping of channel id
+ // We re-attach sessions per connection to ensure there is the same mapping of channel id
// on live and backup connections
-
+
Map<RemotingConnection, List<ClientSessionInternal>> sessionsPerConnection = new HashMap<RemotingConnection, List<ClientSessionInternal>>();
for (Map.Entry<ClientSessionInternal, RemotingConnection> entry : sessions.entrySet())
@@ -636,7 +714,7 @@
{
List<ClientSessionInternal> theSessions = entry.getValue();
- RemotingConnection backupConnection = getConnectionWithRetry(theSessions, retries);
+ RemotingConnection backupConnection = getConnectionWithRetry(theSessions, connectAttempts);
if (backupConnection == null)
{
@@ -649,19 +727,15 @@
List<FailureListener> oldListeners = entry.getKey().getFailureListeners();
- List<FailureListener> newListeners = new ArrayList<FailureListener>(oldListeners.size());
+ List<FailureListener> newListeners = new ArrayList<FailureListener>(backupConnection.getFailureListeners());
- newListeners.add(this);
-
- for (int i = 0; i < oldListeners.size(); i++)
+ for (FailureListener listener : oldListeners)
{
- // Add all apart from the first one which is the old connectionmanager
+ // Add all apart from the first one which is the old DelegatingFailureListener
- FailureListener listener = oldListeners.get(i);
-
- if (listener instanceof ConnectionManagerImpl == false)
+ if (listener instanceof DelegatingFailureListener == false)
{
- newListeners.add(oldListeners.get(i));
+ newListeners.add(listener);
}
}
@@ -679,11 +753,12 @@
for (Map.Entry<ClientSessionInternal, RemotingConnection> entry : sessions.entrySet())
{
boolean b = entry.getKey().handleFailover(entry.getValue());
-
+
if (!b)
{
- //If a session fails to re-attach we doom the lot, but we make sure we try all sessions and don't exit early
- //or connections might be left lying around
+ // If a session fails to re-attach we doom the lot, but we make sure we try all sessions and don't exit
+ // early
+ // or connections might be left lying around
ok = false;
}
}
@@ -692,7 +767,8 @@
return ok;
}
- private RemotingConnection getConnectionWithRetry(final List<ClientSessionInternal> sessions, final int retries)
+ private RemotingConnection getConnectionWithRetry(final List<ClientSessionInternal> sessions,
+ final int connectAttempts)
{
long interval = retryInterval;
@@ -706,20 +782,20 @@
return null;
}
-
+
RemotingConnection connection = getConnection(sessions.size());
-
+
if (connection == null)
{
// Failed to get backup connection
- if (retries != 0)
+ if (connectAttempts != 0)
{
count++;
- if (retries != -1 && count == retries)
+ if (connectAttempts != -1 && count == connectAttempts)
{
- log.warn("Retried " + retries + " times to reconnect. Now giving up.");
+ log.warn("Retried " + connectAttempts + " times to reconnect. Now giving up.");
return null;
}
@@ -752,7 +828,7 @@
if (refCount == 0)
{
// Close connections
-
+
Set<ConnectionEntry> copy = new HashSet<ConnectionEntry>(connections.values());
connections.clear();
@@ -760,13 +836,18 @@
for (ConnectionEntry entry : copy)
{
try
- {
+ {
entry.connection.destroy();
-
+ }
+ catch (Throwable ignore)
+ {
+ }
+ try
+ {
entry.connector.close();
}
catch (Throwable ignore)
- {
+ {
}
}
@@ -781,7 +862,7 @@
if (connections.size() < maxConnections)
{
// Create a new one
-
+
DelegatingBufferHandler handler = new DelegatingBufferHandler();
Connector connector = null;
@@ -791,26 +872,58 @@
try
{
connector = connectorFactory.createConnector(transportParams, handler, this);
-
+
if (connector != null)
{
connector.start();
+
+ tc = connector.createConnection();
+
+ if (tc == null)
+ {
+ try
+ {
+ connector.close();
+ }
+ catch (Throwable t)
+ {}
+
+ }
- tc = connector.createConnection();
}
}
catch (Exception e)
{
// Sanity catch for badly behaved remoting plugins
-
+
log.warn("connector.create or connectorFactory.createConnector should never throw an exception, implementation is badly behaved, but we'll deal with it anyway.",
e);
+
+ if (tc != null)
+ {
+ try
+ {
+ tc.close();
+ }
+ catch (Throwable t)
+ {}
+ }
+
+ if (connector != null)
+ {
+ try
+ {
+ connector.close();
+ }
+ catch (Throwable t)
+ {}
+ }
tc = null;
connector = null;
}
-
+
if (tc == null)
{
return null;
@@ -818,11 +931,18 @@
conn = new RemotingConnectionImpl(tc, callTimeout, pingPeriod, connectionTTL, pingExecutor, null);
+ conn.addFailureListener(new DelegatingFailureListener(conn.getID()));
+
handler.conn = conn;
conn.startPinger();
connections.put(conn.getID(), new ConnectionEntry(conn, connector));
+
+ if (debug)
+ {
+ checkAddDebug(conn);
+ }
}
else
{
@@ -949,4 +1069,63 @@
}
}
+ private class DelegatingFailureListener implements FailureListener
+ {
+ final Object connectionID;
+
+ DelegatingFailureListener(final Object connectionID)
+ {
+ this.connectionID = connectionID;
+ }
+
+ public boolean connectionFailed(final MessagingException me)
+ {
+ return handleConnectionFailed(me, connectionID);
+ }
+ }
+
+ // Debug only
+
+ private void checkAddDebug(final RemotingConnection conn)
+ {
+ Set<RemotingConnection> conns;
+
+ synchronized (debugConns)
+ {
+ conns = debugConns.get(connectorConfig);
+
+ if (conns == null)
+ {
+ conns = new HashSet<RemotingConnection>();
+
+ debugConns.put(connectorConfig, conns);
+ }
+
+ conns.add(conn);
+ }
+ }
+
+ public static void failAllConnectionsForConnector(final TransportConfiguration config)
+ {
+ Set<RemotingConnection> conns;
+
+ synchronized (debugConns)
+ {
+ conns = debugConns.get(config);
+
+ if (conns != null)
+ {
+ conns = new HashSet<RemotingConnection>(debugConns.get(config));
+ }
+ }
+
+ if (conns != null)
+ {
+ for (RemotingConnection conn : conns)
+ {
+ conn.fail(new MessagingException(MessagingException.INTERNAL_ERROR, "blah"));
+ }
+ }
+ }
+
}
Modified: trunk/src/main/org/jboss/messaging/core/config/TransportConfiguration.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/config/TransportConfiguration.java 2009-03-23 19:56:44 UTC (rev 6145)
+++ trunk/src/main/org/jboss/messaging/core/config/TransportConfiguration.java 2009-03-24 10:20:42 UTC (rev 6146)
@@ -21,15 +21,12 @@
*/
package org.jboss.messaging.core.config;
-import static java.util.Collections.emptyMap;
-
import java.io.Serializable;
-import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
-import java.util.UUID;
import org.jboss.messaging.core.remoting.spi.MessagingBuffer;
+import org.jboss.messaging.utils.UUIDGenerator;
/**
* A TransportConfiguration
@@ -191,12 +188,12 @@
public TransportConfiguration(final String className, final Map<String, Object> params)
{
- this(className, params, UUID.randomUUID().toString());
+ this(className, params, UUIDGenerator.getInstance().generateStringUUID());
}
public TransportConfiguration(final String className)
{
- this(className, new HashMap<String, Object>(), UUID.randomUUID().toString());
+ this(className, new HashMap<String, Object>(), UUIDGenerator.getInstance().generateStringUUID());
}
public String getName()
Modified: trunk/src/main/org/jboss/messaging/core/config/cluster/BridgeConfiguration.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/config/cluster/BridgeConfiguration.java 2009-03-23 19:56:44 UTC (rev 6145)
+++ trunk/src/main/org/jboss/messaging/core/config/cluster/BridgeConfiguration.java 2009-03-24 10:20:42 UTC (rev 6146)
@@ -57,9 +57,9 @@
private final double retryIntervalMultiplier;
- private final int maxRetriesBeforeFailover;
+ private final int initialConnectAttempts;
- private final int maxRetriesAfterFailover;
+ private final int reconnectAttempts;
private final boolean useDuplicateDetection;
@@ -70,8 +70,8 @@
final String transformerClassName,
final long retryInterval,
final double retryIntervalMultiplier,
- final int maxRetriesBeforeFailover,
- final int maxRetriesAfterFailover,
+ final int initialConnectAttempts,
+ final int reconnectAttempts,
final boolean useDuplicateDetection,
final Pair<String, String> connectorPair)
{
@@ -82,8 +82,8 @@
this.transformerClassName = transformerClassName;
this.retryInterval = retryInterval;
this.retryIntervalMultiplier = retryIntervalMultiplier;
- this.maxRetriesBeforeFailover = maxRetriesBeforeFailover;
- this.maxRetriesAfterFailover = maxRetriesAfterFailover;
+ this.initialConnectAttempts = initialConnectAttempts;
+ this.reconnectAttempts = reconnectAttempts;
this.useDuplicateDetection = useDuplicateDetection;
this.connectorPair = connectorPair;
this.discoveryGroupName = null;
@@ -96,8 +96,8 @@
final String transformerClassName,
final long retryInterval,
final double retryIntervalMultiplier,
- final int maxRetriesBeforeFailover,
- final int maxRetriesAfterFailover,
+ final int initialConnectAttempts,
+ final int reconnectAttempts,
final boolean useDuplicateDetection,
final String discoveryGroupName)
{
@@ -108,8 +108,8 @@
this.transformerClassName = transformerClassName;
this.retryInterval = retryInterval;
this.retryIntervalMultiplier = retryIntervalMultiplier;
- this.maxRetriesBeforeFailover = maxRetriesBeforeFailover;
- this.maxRetriesAfterFailover = maxRetriesAfterFailover;
+ this.initialConnectAttempts = initialConnectAttempts;
+ this.reconnectAttempts = reconnectAttempts;
this.useDuplicateDetection = useDuplicateDetection;
this.connectorPair = null;
this.discoveryGroupName = discoveryGroupName;
@@ -160,14 +160,14 @@
return retryIntervalMultiplier;
}
- public int getMaxRetriesBeforeFailover()
+ public int getInitialConnectAttempts()
{
- return maxRetriesBeforeFailover;
+ return initialConnectAttempts;
}
- public int getMaxRetriesAfterFailover()
+ public int getReconnectAttempts()
{
- return maxRetriesAfterFailover;
+ return reconnectAttempts;
}
public boolean isUseDuplicateDetection()
Modified: trunk/src/main/org/jboss/messaging/core/config/cluster/ClusterConnectionConfiguration.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/config/cluster/ClusterConnectionConfiguration.java 2009-03-23 19:56:44 UTC (rev 6145)
+++ trunk/src/main/org/jboss/messaging/core/config/cluster/ClusterConnectionConfiguration.java 2009-03-24 10:20:42 UTC (rev 6146)
@@ -48,9 +48,9 @@
private final double retryIntervalMultiplier;
- private final int maxRetriesBeforeFailover;
+ private final int initialConnectAttempts;
- private final int maxRetriesAfterFailover;
+ private final int reconnectAttempts;
private final boolean duplicateDetection;
@@ -66,8 +66,8 @@
final String address,
final long retryInterval,
final double retryIntervalMultiplier,
- final int maxRetriesBeforeFailover,
- final int maxRetriesAfterFailover,
+ final int initialConnectAttempts,
+ final int reconnectAttempts,
final boolean duplicateDetection,
final boolean forwardWhenNoConsumers,
final int maxHops,
@@ -77,8 +77,8 @@
this.address = address;
this.retryInterval = retryInterval;
this.retryIntervalMultiplier = retryIntervalMultiplier;
- this.maxRetriesBeforeFailover = maxRetriesBeforeFailover;
- this.maxRetriesAfterFailover = maxRetriesAfterFailover;
+ this.initialConnectAttempts = initialConnectAttempts;
+ this.reconnectAttempts = reconnectAttempts;
this.staticConnectorNamePairs = staticConnectorNamePairs;
this.duplicateDetection = duplicateDetection;
this.forwardWhenNoConsumers = forwardWhenNoConsumers;
@@ -90,8 +90,8 @@
final String address,
final long retryInterval,
final double retryIntervalMultiplier,
- final int maxRetriesBeforeFailover,
- final int maxRetriesAfterFailover,
+ final int initialConnectAttempts,
+ final int reconnectAttempts,
final boolean duplicateDetection,
final boolean forwardWhenNoConsumers,
final int maxHops,
@@ -101,8 +101,8 @@
this.address = address;
this.retryInterval = retryInterval;
this.retryIntervalMultiplier = retryIntervalMultiplier;
- this.maxRetriesBeforeFailover = maxRetriesBeforeFailover;
- this.maxRetriesAfterFailover = maxRetriesAfterFailover;
+ this.initialConnectAttempts = initialConnectAttempts;
+ this.reconnectAttempts = reconnectAttempts;
this.duplicateDetection = duplicateDetection;
this.forwardWhenNoConsumers = forwardWhenNoConsumers;
this.discoveryGroupName = discoveryGroupName;
@@ -155,14 +155,14 @@
return retryIntervalMultiplier;
}
- public int getMaxRetriesBeforeFailover()
+ public int getInitialConnectAttempts()
{
- return maxRetriesBeforeFailover;
+ return initialConnectAttempts;
}
- public int getMaxRetriesAfterFailover()
+ public int getReconnectAttempts()
{
- return maxRetriesAfterFailover;
+ return reconnectAttempts;
}
}
Modified: trunk/src/main/org/jboss/messaging/core/config/impl/ConfigurationImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/config/impl/ConfigurationImpl.java 2009-03-23 19:56:44 UTC (rev 6145)
+++ trunk/src/main/org/jboss/messaging/core/config/impl/ConfigurationImpl.java 2009-03-24 10:20:42 UTC (rev 6146)
@@ -61,7 +61,7 @@
public static final long DEFAULT_CONNECTION_SCAN_PERIOD = 1000;
- public static final long DEFAULT_CONNECTION_TTL_OVERRIDE = 100000;;
+ public static final long DEFAULT_CONNECTION_TTL_OVERRIDE = -1;
public static final String DEFAULT_BINDINGS_DIRECTORY = "data/bindings";
Modified: trunk/src/main/org/jboss/messaging/core/config/impl/FileConfiguration.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/config/impl/FileConfiguration.java 2009-03-23 19:56:44 UTC (rev 6145)
+++ trunk/src/main/org/jboss/messaging/core/config/impl/FileConfiguration.java 2009-03-24 10:20:42 UTC (rev 6146)
@@ -22,8 +22,8 @@
package org.jboss.messaging.core.config.impl;
-import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_MAX_RETRIES_AFTER_FAILOVER;
-import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_MAX_RETRIES_BEFORE_FAILOVER;
+import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_INITIAL_CONNECT_ATTEMPTS;
+import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_RECONNECT_ATTEMPTS;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_RETRY_INTERVAL;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_RETRY_INTERVAL_MULTIPLIER;
@@ -35,6 +35,7 @@
import java.util.List;
import java.util.Map;
+import org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl;
import org.jboss.messaging.core.config.TransportConfiguration;
import org.jboss.messaging.core.config.cluster.BridgeConfiguration;
import org.jboss.messaging.core.config.cluster.BroadcastGroupConfiguration;
@@ -546,9 +547,9 @@
double retryIntervalMultiplier = DEFAULT_RETRY_INTERVAL_MULTIPLIER;
- int maxRetriesBeforeFailover = DEFAULT_MAX_RETRIES_BEFORE_FAILOVER;
+ int initialConnectAttempts = ClientSessionFactoryImpl.DEFAULT_INITIAL_CONNECT_ATTEMPTS;
- int maxRetriesAfterFailover = DEFAULT_MAX_RETRIES_AFTER_FAILOVER;
+ int reconnectAttempts = ClientSessionFactoryImpl.DEFAULT_RECONNECT_ATTEMPTS;
List<Pair<String, String>> connectorPairs = new ArrayList<Pair<String, String>>();
@@ -568,13 +569,13 @@
{
retryIntervalMultiplier = org.jboss.messaging.utils.XMLUtil.parseDouble(child);
}
- else if (child.getNodeName().equals("max-retries-before-failover"))
+ else if (child.getNodeName().equals("initial-connect-attempts"))
{
- maxRetriesBeforeFailover = org.jboss.messaging.utils.XMLUtil.parseInt(child);
+ initialConnectAttempts = org.jboss.messaging.utils.XMLUtil.parseInt(child);
}
- else if (child.getNodeName().equals("max-retries-after-failover"))
+ else if (child.getNodeName().equals("reconnect-attempts"))
{
- maxRetriesAfterFailover = org.jboss.messaging.utils.XMLUtil.parseInt(child);
+ reconnectAttempts = org.jboss.messaging.utils.XMLUtil.parseInt(child);
}
else if (child.getNodeName().equals("use-duplicate-detection"))
{
@@ -611,8 +612,8 @@
address,
retryInterval,
retryIntervalMultiplier,
- maxRetriesBeforeFailover,
- maxRetriesAfterFailover,
+ initialConnectAttempts,
+ reconnectAttempts,
duplicateDetection,
forwardWhenNoConsumers,
maxHops,
@@ -624,8 +625,8 @@
address,
retryInterval,
retryIntervalMultiplier,
- maxRetriesBeforeFailover,
- maxRetriesAfterFailover,
+ initialConnectAttempts,
+ reconnectAttempts,
duplicateDetection,
forwardWhenNoConsumers,
maxHops,
@@ -655,9 +656,9 @@
double retryIntervalMultiplier = DEFAULT_RETRY_INTERVAL_MULTIPLIER;
- int maxRetriesBeforeFailover = DEFAULT_MAX_RETRIES_BEFORE_FAILOVER;
+ int initialConnectAttempts = DEFAULT_INITIAL_CONNECT_ATTEMPTS;
- int maxRetriesAfterFailover = DEFAULT_MAX_RETRIES_AFTER_FAILOVER;
+ int reconnectAttempts = DEFAULT_RECONNECT_ATTEMPTS;
boolean useDuplicateDetection = DEFAULT_BRIDGE_DUPLICATE_DETECTION;
@@ -695,11 +696,11 @@
}
else if (child.getNodeName().equals("max-retries-before-failover"))
{
- maxRetriesBeforeFailover = XMLUtil.parseInt(child);
+ initialConnectAttempts = XMLUtil.parseInt(child);
}
else if (child.getNodeName().equals("max-retries-after-failover"))
{
- maxRetriesAfterFailover = org.jboss.messaging.utils.XMLUtil.parseInt(child);
+ reconnectAttempts = org.jboss.messaging.utils.XMLUtil.parseInt(child);
}
else if (child.getNodeName().equals("use-duplicate-detection"))
{
@@ -737,8 +738,8 @@
transformerClassName,
retryInterval,
retryIntervalMultiplier,
- maxRetriesBeforeFailover,
- maxRetriesAfterFailover,
+ initialConnectAttempts,
+ reconnectAttempts,
useDuplicateDetection,
connectorPair);
}
@@ -751,8 +752,8 @@
transformerClassName,
retryInterval,
retryIntervalMultiplier,
- maxRetriesBeforeFailover,
- maxRetriesAfterFailover,
+ initialConnectAttempts,
+ reconnectAttempts,
useDuplicateDetection,
discoveryGroupName);
}
Modified: trunk/src/main/org/jboss/messaging/core/management/BridgeControlMBean.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/management/BridgeControlMBean.java 2009-03-23 19:56:44 UTC (rev 6145)
+++ trunk/src/main/org/jboss/messaging/core/management/BridgeControlMBean.java 2009-03-24 10:20:42 UTC (rev 6146)
@@ -50,9 +50,9 @@
double getRetryIntervalMultiplier();
- int getMaxRetriesBeforeFailover();
+ int getInitialConnectAttempts();
- int getMaxRetriesAfterFailover();
+ int getReconnectAttempts();
boolean isUseDuplicateDetection();
}
Modified: trunk/src/main/org/jboss/messaging/core/management/ClusterConnectionControlMBean.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/management/ClusterConnectionControlMBean.java 2009-03-23 19:56:44 UTC (rev 6145)
+++ trunk/src/main/org/jboss/messaging/core/management/ClusterConnectionControlMBean.java 2009-03-24 10:20:42 UTC (rev 6146)
@@ -50,7 +50,7 @@
double getRetryIntervalMultiplier();
- int getMaxRetriesBeforeFailover();
+ int getInitialConnectAttempts();
- int getMaxRetriesAfterFailover();
+ int getReconnectAttempts();
}
Modified: trunk/src/main/org/jboss/messaging/core/management/ManagementService.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/management/ManagementService.java 2009-03-23 19:56:44 UTC (rev 6145)
+++ trunk/src/main/org/jboss/messaging/core/management/ManagementService.java 2009-03-24 10:20:42 UTC (rev 6146)
@@ -92,7 +92,8 @@
ResourceManager resourceManager,
RemotingService remotingService,
MessagingServer messagingServer,
- QueueFactory queueFactory) throws Exception;
+ QueueFactory queueFactory,
+ boolean backup) throws Exception;
void unregisterServer() throws Exception;
Modified: trunk/src/main/org/jboss/messaging/core/management/impl/BridgeControl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/management/impl/BridgeControl.java 2009-03-23 19:56:44 UTC (rev 6145)
+++ trunk/src/main/org/jboss/messaging/core/management/impl/BridgeControl.java 2009-03-24 10:20:42 UTC (rev 6146)
@@ -84,14 +84,14 @@
return configuration.getFilterString();
}
- public int getMaxRetriesAfterFailover()
+ public int getReconnectAttempts()
{
- return configuration.getMaxRetriesAfterFailover();
+ return configuration.getReconnectAttempts();
}
- public int getMaxRetriesBeforeFailover()
+ public int getInitialConnectAttempts()
{
- return configuration.getMaxRetriesBeforeFailover();
+ return configuration.getInitialConnectAttempts();
}
public String getName()
Modified: trunk/src/main/org/jboss/messaging/core/management/impl/ClusterConnectionControl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/management/impl/ClusterConnectionControl.java 2009-03-23 19:56:44 UTC (rev 6145)
+++ trunk/src/main/org/jboss/messaging/core/management/impl/ClusterConnectionControl.java 2009-03-24 10:20:42 UTC (rev 6146)
@@ -73,14 +73,14 @@
return configuration.getMaxHops();
}
- public int getMaxRetriesBeforeFailover()
+ public int getInitialConnectAttempts()
{
- return configuration.getMaxRetriesBeforeFailover();
+ return configuration.getInitialConnectAttempts();
}
- public int getMaxRetriesAfterFailover()
+ public int getReconnectAttempts()
{
- return configuration.getMaxRetriesAfterFailover();
+ return configuration.getReconnectAttempts();
}
public String getName()
Modified: trunk/src/main/org/jboss/messaging/core/management/impl/ManagementServiceImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/management/impl/ManagementServiceImpl.java 2009-03-23 19:56:44 UTC (rev 6145)
+++ trunk/src/main/org/jboss/messaging/core/management/impl/ManagementServiceImpl.java 2009-03-24 10:20:42 UTC (rev 6146)
@@ -165,12 +165,14 @@
final ResourceManager resourceManager,
final RemotingService remotingService,
final MessagingServer messagingServer,
- final QueueFactory queueFactory) throws Exception
+ final QueueFactory queueFactory,
+ final boolean backup) throws Exception
{
this.postOffice = postOffice;
this.addressSettingsRepository = addressSettingsRepository;
this.securityRepository = securityRepository;
this.storageManager = storageManager;
+
managedServer = new MessagingServerControl(postOffice,
storageManager,
configuration,
@@ -369,8 +371,7 @@
ManagementHelper.storeResult(reply, result);
}
catch (Exception e)
- {
- e.printStackTrace(System.err);
+ {
log.warn("exception while invoking " + operation + " on " + objectName, e);
reply.putBooleanProperty(ManagementHelper.HDR_JMX_OPERATION_SUCCEEDED, false);
String exceptionMessage = e.getMessage();
@@ -553,9 +554,9 @@
}
}
}
-
+
public void sendNotification(final Notification notification) throws Exception
- {
+ {
if (managedServer != null && noticationsEnabled)
{
// This needs to be synchronized since we need to ensure notifications are processed in strict sequence
@@ -578,6 +579,7 @@
// Now send message
ServerMessage notificationMessage = new ServerMessageImpl(storageManager.generateUniqueID());
+
notificationMessage.setBody(ChannelBuffers.EMPTY_BUFFER);
// Notification messages are always durable so the user can choose whether to add a durable queue to consume
// them in
Modified: trunk/src/main/org/jboss/messaging/core/management/jmx/impl/ReplicationAwareMessagingServerControlWrapper.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/management/jmx/impl/ReplicationAwareMessagingServerControlWrapper.java 2009-03-23 19:56:44 UTC (rev 6145)
+++ trunk/src/main/org/jboss/messaging/core/management/jmx/impl/ReplicationAwareMessagingServerControlWrapper.java 2009-03-24 10:20:42 UTC (rev 6146)
@@ -236,8 +236,8 @@
}
public void sendQueueInfoToQueue(final String queueName, final String address) throws Exception
- {
- localControl.sendQueueInfoToQueue(queueName, address);
+ {
+ replicationAwareInvoke("sendQueueInfoToQueue", queueName, address);
}
public boolean addAddress(String address) throws Exception
Modified: trunk/src/main/org/jboss/messaging/core/persistence/StorageManager.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/persistence/StorageManager.java 2009-03-23 19:56:44 UTC (rev 6145)
+++ trunk/src/main/org/jboss/messaging/core/persistence/StorageManager.java 2009-03-24 10:20:42 UTC (rev 6146)
@@ -55,8 +55,12 @@
// Message related operations
UUID getPersistentID();
+
+ void setPersistentID(UUID id) throws Exception;
long generateUniqueID();
+
+ long getCurrentUniqueID();
void storeMessage(ServerMessage message) throws Exception;
Modified: trunk/src/main/org/jboss/messaging/core/persistence/impl/journal/JournalStorageManager.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/persistence/impl/journal/JournalStorageManager.java 2009-03-23 19:56:44 UTC (rev 6145)
+++ trunk/src/main/org/jboss/messaging/core/persistence/impl/journal/JournalStorageManager.java 2009-03-24 10:20:42 UTC (rev 6146)
@@ -35,6 +35,7 @@
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicLong;
import javax.transaction.xa.Xid;
@@ -81,7 +82,6 @@
import org.jboss.messaging.utils.JBMThreadFactory;
import org.jboss.messaging.utils.Pair;
import org.jboss.messaging.utils.SimpleString;
-import org.jboss.messaging.utils.TimeAndCounterIDGenerator;
import org.jboss.messaging.utils.UUID;
import org.jboss.messaging.utils.UUIDGenerator;
@@ -97,14 +97,17 @@
public class JournalStorageManager implements StorageManager
{
private static final Logger log = Logger.getLogger(JournalStorageManager.class);
+
+ private static final long CHECKPOINT_BATCH_SIZE = 2 ^ 32;
+
// Bindings journal record type
public static final byte QUEUE_BINDING_RECORD = 21;
- // public static final byte DESTINATION_RECORD = 22;
+ public static final byte PERSISTENT_ID_RECORD = 23;
- public static final byte PERSISTENT_ID_RECORD = 23;
+ public static final byte ID_COUNTER_RECORD = 24;
// type + expiration + timestamp + priority
public static final int SIZE_FIELDS = SIZE_INT + SIZE_LONG + SIZE_LONG + SIZE_BYTE;
@@ -129,8 +132,7 @@
private UUID persistentID;
- // This will produce a unique id **for this node only**
- private final IDGenerator idGenerator = new TimeAndCounterIDGenerator();
+ private final BatchingIDGenerator idGenerator = new BatchingIDGenerator(0, CHECKPOINT_BATCH_SIZE);
private final Journal messageJournal;
@@ -216,8 +218,6 @@
largeMessagesFactory = new NIOSequentialFileFactory(config.getLargeMessagesDirectory());
}
-
-
/* This constructor is only used for testing */
public JournalStorageManager(final Journal messageJournal,
final Journal bindingsJournal,
@@ -233,11 +233,28 @@
{
return persistentID;
}
+
+ public void setPersistentID(UUID id) throws Exception
+ {
+ long recordID = generateUniqueID();
+
+ if (id != null)
+ {
+ bindingsJournal.appendAddRecord(recordID, PERSISTENT_ID_RECORD, new PersistentIDEncoding(id), true);
+ }
+
+ this.persistentID = id;
+ }
public long generateUniqueID()
{
return idGenerator.generateID();
}
+
+ public long getCurrentUniqueID()
+ {
+ return idGenerator.getCurrentID();
+ }
public LargeServerMessage createLargeMessage()
{
@@ -895,6 +912,8 @@
List<PreparedTransactionInfo> preparedTransactions = new ArrayList<PreparedTransactionInfo>();
bindingsJournal.load(records, preparedTransactions);
+
+ long lastID = -1;
for (RecordInfo record : records)
{
@@ -922,19 +941,24 @@
persistentID = encoding.uuid;
}
+ else if (rec == ID_COUNTER_RECORD)
+ {
+ IDCounterEncoding encoding = new IDCounterEncoding();
+
+ encoding.decode(buffer);
+
+ lastID = encoding.id;
+ }
else
{
throw new IllegalStateException("Invalid record type " + rec);
}
}
+
+ idGenerator.setID(lastID + 1);
+ }
- if (persistentID == null)
- {
- persistentID = UUIDGenerator.getInstance().generateUUID();
-
- bindingsJournal.appendAddRecord(generateUniqueID(), PERSISTENT_ID_RECORD, new PersistentIDEncoding(persistentID), true);
- }
- }
+
// MessagingComponent implementation
// ------------------------------------------------------
@@ -961,6 +985,9 @@
{
return;
}
+
+ //Must call close to make sure last id is persisted
+ idGenerator.close();
executor.shutdown();
@@ -1070,6 +1097,79 @@
// Inner Classes
// ----------------------------------------------------------------------------
+ private class BatchingIDGenerator implements IDGenerator
+ {
+ private final AtomicLong counter;
+
+ private final long checkpointSize;
+
+ private volatile long nextID;
+
+ public BatchingIDGenerator(final long start, final long checkpointSize)
+ {
+ this.counter = new AtomicLong(start);
+
+ this.checkpointSize = checkpointSize;
+
+ nextID = start + checkpointSize;
+ }
+
+ public void setID(final long id)
+ {
+ this.counter.set(id);
+
+ nextID = id + checkpointSize;
+ }
+
+ public long generateID()
+ {
+ long id = counter.getAndIncrement();
+
+ if (id >= nextID)
+ {
+ saveCheckPoint(id);
+
+ return id;
+ }
+ else
+ {
+ return id;
+ }
+ }
+
+ private synchronized void saveCheckPoint(final long id)
+ {
+ if (id >= nextID)
+ {
+ storeID(id);
+
+ nextID += checkpointSize;
+ }
+ }
+
+ public long getCurrentID()
+ {
+ return counter.get();
+ }
+
+ public void close()
+ {
+ storeID(counter.get());
+ }
+
+ private void storeID(final long id)
+ {
+ try
+ {
+ bindingsJournal.appendAddRecord(id, ID_COUNTER_RECORD, new IDCounterEncoding(id), true);
+ }
+ catch (Exception e)
+ {
+ log.error("Failed to store id", e);
+ }
+ }
+ }
+
private static class XidEncoding implements EncodingSupport
{
final Xid xid;
@@ -1232,7 +1332,37 @@
}
}
+
+ private static class IDCounterEncoding implements EncodingSupport
+ {
+ long id;
+ IDCounterEncoding(final long id)
+ {
+ this.id = id;
+ }
+
+ IDCounterEncoding()
+ {
+ }
+
+ public void decode(final MessagingBuffer buffer)
+ {
+ id = buffer.readLong();
+ }
+
+ public void encode(final MessagingBuffer buffer)
+ {
+ buffer.writeLong(id);
+ }
+
+ public int getEncodeSize()
+ {
+ return SIZE_LONG;
+ }
+
+ }
+
private static class LargeMessageEncoding implements EncodingSupport
{
private final LargeServerMessage message;
Modified: trunk/src/main/org/jboss/messaging/core/persistence/impl/nullpm/NullStorageManager.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/persistence/impl/nullpm/NullStorageManager.java 2009-03-23 19:56:44 UTC (rev 6145)
+++ trunk/src/main/org/jboss/messaging/core/persistence/impl/nullpm/NullStorageManager.java 2009-03-24 10:20:42 UTC (rev 6146)
@@ -24,9 +24,11 @@
import java.util.List;
import java.util.Map;
+import java.util.concurrent.atomic.AtomicLong;
import javax.transaction.xa.Xid;
+import org.jboss.messaging.core.logging.Logger;
import org.jboss.messaging.core.paging.PageTransactionInfo;
import org.jboss.messaging.core.persistence.QueueBindingInfo;
import org.jboss.messaging.core.persistence.StorageManager;
@@ -39,12 +41,9 @@
import org.jboss.messaging.core.settings.HierarchicalRepository;
import org.jboss.messaging.core.settings.impl.AddressSettings;
import org.jboss.messaging.core.transaction.ResourceManager;
-import org.jboss.messaging.utils.IDGenerator;
import org.jboss.messaging.utils.Pair;
import org.jboss.messaging.utils.SimpleString;
-import org.jboss.messaging.utils.TimeAndCounterIDGenerator;
import org.jboss.messaging.utils.UUID;
-import org.jboss.messaging.utils.UUIDGenerator;
/**
*
@@ -56,9 +55,11 @@
*/
public class NullStorageManager implements StorageManager
{
- private final IDGenerator idGenerator = new TimeAndCounterIDGenerator();
+ private static final Logger log = Logger.getLogger(NullStorageManager.class);
- private final UUID id = UUIDGenerator.getInstance().generateUUID();
+ private final AtomicLong idGenerator = new AtomicLong(0);
+
+ private UUID id;
private volatile boolean started;
@@ -66,6 +67,11 @@
{
return id;
}
+
+ public void setPersistentID(final UUID id)
+ {
+ this.id = id;
+ }
public void addQueueBinding(final Binding queueBinding) throws Exception
{
@@ -177,11 +183,18 @@
{
return new NullStorageLargeServerMessage();
}
-
+
public long generateUniqueID()
{
- return idGenerator.generateID();
+ long id = idGenerator.getAndIncrement();
+
+ return id;
}
+
+ public long getCurrentUniqueID()
+ {
+ return idGenerator.get();
+ }
public synchronized void start() throws Exception
{
Modified: trunk/src/main/org/jboss/messaging/core/postoffice/impl/BindingsImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/postoffice/impl/BindingsImpl.java 2009-03-23 19:56:44 UTC (rev 6145)
+++ trunk/src/main/org/jboss/messaging/core/postoffice/impl/BindingsImpl.java 2009-03-24 10:20:42 UTC (rev 6146)
@@ -148,7 +148,7 @@
if (binding == null)
{
// The binding has been closed - we need to route the message somewhere else...............
- throw new IllegalStateException("Binding not found when routing from cluster - it must have closed");
+ throw new IllegalStateException("Binding not found when routing from cluster - it must have closed " + bindingID);
// FIXME need to deal with this better
}
Modified: trunk/src/main/org/jboss/messaging/core/postoffice/impl/LocalQueueBinding.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/postoffice/impl/LocalQueueBinding.java 2009-03-23 19:56:44 UTC (rev 6145)
+++ trunk/src/main/org/jboss/messaging/core/postoffice/impl/LocalQueueBinding.java 2009-03-24 10:20:42 UTC (rev 6146)
@@ -161,7 +161,7 @@
}
public void willRoute(final ServerMessage message)
- {
+ {
}
public boolean isQueueBinding()
Modified: trunk/src/main/org/jboss/messaging/core/postoffice/impl/PostOfficeImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/postoffice/impl/PostOfficeImpl.java 2009-03-23 19:56:44 UTC (rev 6145)
+++ trunk/src/main/org/jboss/messaging/core/postoffice/impl/PostOfficeImpl.java 2009-03-24 10:20:42 UTC (rev 6146)
@@ -127,7 +127,7 @@
private final HierarchicalRepository<AddressSettings> addressSettingsRepository;
private final boolean allowRouteWhenNoBindings;
-
+
public PostOfficeImpl(final StorageManager storageManager,
final PagingManager pagingManager,
final QueueFactory bindableFactory,
@@ -381,7 +381,7 @@
TypedProperties props = notification.getProperties();
SimpleString clusterName = (SimpleString)props.getProperty(ManagementHelper.HDR_CLUSTER_NAME);
-
+
if (clusterName == null)
{
throw new IllegalStateException("No distance");
@@ -573,12 +573,10 @@
return addressManager.getBinding(name);
}
- public Set<Long> idsAdded = new HashSet<Long>();
-
public void route(final ServerMessage message, Transaction tx) throws Exception
- {
+ {
SimpleString address = message.getDestination();
-
+
byte[] duplicateID = (byte[])message.getProperty(MessageImpl.HDR_DUPLICATE_DETECTION_ID);
DuplicateIDCache cache = null;
@@ -730,7 +728,7 @@
}
public void sendQueueInfoToQueue(final SimpleString queueName, final SimpleString address) throws Exception
- {
+ {
// We send direct to the queue so we can send it to the same queue that is bound to the notifications adress -
// this is crucial for ensuring
// that queue infos and notifications are received in a contiguous consistent stream
Modified: trunk/src/main/org/jboss/messaging/core/remoting/Channel.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/Channel.java 2009-03-23 19:56:44 UTC (rev 6145)
+++ trunk/src/main/org/jboss/messaging/core/remoting/Channel.java 2009-03-24 10:20:42 UTC (rev 6146)
@@ -25,7 +25,7 @@
long getID();
void send(Packet packet);
-
+
Packet sendBlocking(Packet packet) throws MessagingException;
void replicatePacket(Packet packet, long replicatedChannelID, Runnable action);
Modified: trunk/src/main/org/jboss/messaging/core/remoting/impl/RemotingConnectionImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/impl/RemotingConnectionImpl.java 2009-03-23 19:56:44 UTC (rev 6145)
+++ trunk/src/main/org/jboss/messaging/core/remoting/impl/RemotingConnectionImpl.java 2009-03-24 10:20:42 UTC (rev 6146)
@@ -14,6 +14,8 @@
import static org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl.CREATESESSION;
import static org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl.CREATESESSION_RESP;
+import static org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl.CREATE_QUEUE;
+import static org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl.DELETE_QUEUE;
import static org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl.EARLY_RESPONSE;
import static org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl.EXCEPTION;
import static org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl.NULL_RESPONSE;
@@ -22,7 +24,13 @@
import static org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl.PONG;
import static org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl.REATTACH_SESSION;
import static org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl.REATTACH_SESSION_RESP;
+import static org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl.REPLICATE_ACKNOWLEDGE;
+import static org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl.REPLICATE_ADD_REMOTE_CONSUMER;
+import static org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl.REPLICATE_ADD_REMOTE_QUEUE_BINDING;
import static org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl.REPLICATE_CREATESESSION;
+import static org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl.REPLICATE_REMOVE_REMOTE_CONSUMER;
+import static org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl.REPLICATE_REMOVE_REMOTE_QUEUE_BINDING;
+import static org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl.REPLICATE_STARTUP_INFO;
import static org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl.REPLICATION_RESPONSE;
import static org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl.SESS_ACKNOWLEDGE;
import static org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl.SESS_BINDINGQUERY;
@@ -31,8 +39,6 @@
import static org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl.SESS_COMMIT;
import static org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl.SESS_CONSUMER_CLOSE;
import static org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl.SESS_CREATECONSUMER;
-import static org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl.CREATE_QUEUE;
-import static org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl.DELETE_QUEUE;
import static org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl.SESS_EXPIRED;
import static org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl.SESS_FAILOVER_COMPLETE;
import static org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl.SESS_FLOWTOKEN;
@@ -87,6 +93,7 @@
import org.jboss.messaging.core.remoting.Interceptor;
import org.jboss.messaging.core.remoting.Packet;
import org.jboss.messaging.core.remoting.RemotingConnection;
+import org.jboss.messaging.core.remoting.impl.wireformat.CreateQueueMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.CreateSessionMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.CreateSessionResponseMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.MessagingExceptionMessage;
@@ -106,7 +113,6 @@
import org.jboss.messaging.core.remoting.impl.wireformat.SessionConsumerCloseMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.SessionConsumerFlowCreditMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.SessionCreateConsumerMessage;
-import org.jboss.messaging.core.remoting.impl.wireformat.CreateQueueMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.SessionDeleteQueueMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.SessionExpiredMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.SessionFailoverCompleteMessage;
@@ -129,6 +135,12 @@
import org.jboss.messaging.core.remoting.impl.wireformat.SessionXASetTimeoutMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.SessionXASetTimeoutResponseMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.SessionXAStartMessage;
+import org.jboss.messaging.core.remoting.impl.wireformat.replication.ReplicateAcknowledgeMessage;
+import org.jboss.messaging.core.remoting.impl.wireformat.replication.ReplicateRemoteBindingAddedMessage;
+import org.jboss.messaging.core.remoting.impl.wireformat.replication.ReplicateRemoteBindingRemovedMessage;
+import org.jboss.messaging.core.remoting.impl.wireformat.replication.ReplicateRemoteConsumerAddedMessage;
+import org.jboss.messaging.core.remoting.impl.wireformat.replication.ReplicateRemoteConsumerRemovedMessage;
+import org.jboss.messaging.core.remoting.impl.wireformat.replication.ReplicateStartupInfoMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.replication.SessionReplicateDeliveryMessage;
import org.jboss.messaging.core.remoting.spi.Connection;
import org.jboss.messaging.core.remoting.spi.ConnectionLifeCycleListener;
@@ -164,6 +176,11 @@
Connector connector = connectorFactory.createConnector(params, handler, listener);
+ if (connector == null)
+ {
+ return null;
+ }
+
connector.start();
Connection tc = connector.createConnection();
@@ -358,7 +375,6 @@
public String getRemoteAddress()
{
- log.info("transport connection is " + transportConnection);
return transportConnection.getRemoteAddress();
}
@@ -416,7 +432,7 @@
destroyed = true;
}
- log.warn("Connection failed, client " + client + " " + System.identityHashCode(this) + " " + me.getMessage(), me);
+ log.warn("Connection failure has been detected " + me.getMessage() + ":" + me.getCode());
// Then call the listeners
callListeners(me);
@@ -487,7 +503,7 @@
if (!frozen)
{
final ChannelImpl channel = channels.get(packet.getChannelID());
-
+
if (channel != null)
{
channel.handlePacket(packet);
@@ -543,18 +559,6 @@
log.error("Failed to execute failure listener", t);
}
}
- for (ChannelImpl channel : channels.values())
- {
- channel.lock.lock();
- try
- {
- channel.sendCondition.signalAll();
- }
- finally
- {
- channel.lock.unlock();
- }
- }
}
private void internalClose()
@@ -823,11 +827,41 @@
packet = new SessionSendContinuationMessage();
break;
}
+ case REPLICATE_ADD_REMOTE_QUEUE_BINDING:
+ {
+ packet = new ReplicateRemoteBindingAddedMessage();
+ break;
+ }
+ case REPLICATE_REMOVE_REMOTE_QUEUE_BINDING:
+ {
+ packet = new ReplicateRemoteBindingRemovedMessage();
+ break;
+ }
+ case REPLICATE_ADD_REMOTE_CONSUMER:
+ {
+ packet = new ReplicateRemoteConsumerAddedMessage();
+ break;
+ }
+ case REPLICATE_REMOVE_REMOTE_CONSUMER:
+ {
+ packet = new ReplicateRemoteConsumerRemovedMessage();
+ break;
+ }
case SESS_REPLICATE_DELIVERY:
{
packet = new SessionReplicateDeliveryMessage();
break;
}
+ case REPLICATE_STARTUP_INFO:
+ {
+ packet = new ReplicateStartupInfoMessage();
+ break;
+ }
+ case REPLICATE_ACKNOWLEDGE:
+ {
+ packet = new ReplicateAcknowledgeMessage();
+ break;
+ }
default:
{
throw new IllegalArgumentException("Invalid type: " + packetType);
@@ -888,7 +922,7 @@
private CommandConfirmationHandler commandConfirmationHandler;
private int responseActionCount;
-
+
private boolean playedResponsesOnFailure;
public void setCommandConfirmationHandler(final CommandConfirmationHandler handler)
@@ -1091,10 +1125,7 @@
catch (InterruptedException e)
{
}
- if(closed)
- {
- break;
- }
+
final long now = System.currentTimeMillis();
toWait -= now - start;
@@ -1136,23 +1167,23 @@
{
if (playedResponsesOnFailure && action != null)
{
- //Already replicating channel failed, so just play the action now
-
- action.run();
+ // Already replicating channel failed, so just play the action now
+
+ action.run();
}
else
- {
+ {
if (action != null)
{
responseActions.add(action);
-
+
responseActionCount++;
}
-
+
final MessagingBuffer buffer = connection.transportConnection.createBuffer(packet.getRequiredBufferSize());
-
+
packet.encode(buffer);
-
+
connection.transportConnection.write(buffer);
}
}
@@ -1160,8 +1191,8 @@
public void executeOutstandingDelayedResults()
{
- //Execute on different thread to avoid deadlock
-
+ // Execute on different thread to avoid deadlock
+
new Thread()
{
public void run()
@@ -1170,7 +1201,7 @@
}
}.start();
}
-
+
private void doExecuteOutstandingDelayedResults()
{
synchronized (replicationLock)
@@ -1192,7 +1223,7 @@
}
responseActionCount = 0;
-
+
this.playedResponsesOnFailure = true;
}
}
@@ -1342,7 +1373,7 @@
doWrite(packet);
}
}
-
+
// This will never get called concurrently by more than one thread
// TODO it's not ideal synchronizing this since it forms a contention point with replication
@@ -1357,7 +1388,7 @@
{
return;
}
-
+
result = responseActions.poll();
if (result == null)
@@ -1385,7 +1416,7 @@
}
private void waitForAllReplicationResponse()
- {
+ {
synchronized (replicationLock)
{
long toWait = 10000; // TODO don't hardcode timeout
@@ -1467,11 +1498,11 @@
if (packet.isResponse())
{
response = packet;
-
+
confirm(packet);
-
+
lock.lock();
-
+
try
{
sendCondition.signal();
@@ -1571,6 +1602,7 @@
firstTime = false;
// Send ping
+
final Packet ping = new Ping(connectionTTL);
pingChannel.send(ping);
@@ -1599,7 +1631,7 @@
long connectionTTLToUse = connectionTTL != -1 ? connectionTTL : ((Ping)packet).getExpirePeriod();
expireTime = System.currentTimeMillis() + connectionTTLToUse;
-
+
// Parameter is placeholder for future
final Packet pong = new Pong(-1);
Modified: trunk/src/main/org/jboss/messaging/core/remoting/impl/invm/InVMAcceptor.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/impl/invm/InVMAcceptor.java 2009-03-23 19:56:44 UTC (rev 6145)
+++ trunk/src/main/org/jboss/messaging/core/remoting/impl/invm/InVMAcceptor.java 2009-03-24 10:20:42 UTC (rev 6146)
@@ -26,6 +26,7 @@
import java.util.concurrent.ConcurrentMap;
import org.jboss.messaging.core.exception.MessagingException;
+import org.jboss.messaging.core.logging.Logger;
import org.jboss.messaging.core.remoting.spi.Acceptor;
import org.jboss.messaging.core.remoting.spi.BufferHandler;
import org.jboss.messaging.core.remoting.spi.Connection;
@@ -40,6 +41,8 @@
*/
public class InVMAcceptor implements Acceptor
{
+ private static final Logger log = Logger.getLogger(InVMAcceptor.class);
+
private final int id;
private final BufferHandler handler;
@@ -71,7 +74,7 @@
InVMRegistry registry = InVMRegistry.instance;
registry.registerAcceptor(id, this);
-
+
started = true;
}
Modified: trunk/src/main/org/jboss/messaging/core/remoting/impl/invm/InVMConnection.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/impl/invm/InVMConnection.java 2009-03-23 19:56:44 UTC (rev 6145)
+++ trunk/src/main/org/jboss/messaging/core/remoting/impl/invm/InVMConnection.java 2009-03-24 10:20:42 UTC (rev 6146)
@@ -109,7 +109,12 @@
}
public void write(final MessagingBuffer buffer)
- {
+ {
+ write(buffer, false);
+ }
+
+ public void write(final MessagingBuffer buffer, final boolean flush)
+ {
executor.execute(new Runnable()
{
public void run()
@@ -119,12 +124,9 @@
if (!closed)
{
buffer.readInt(); // read and discard
+
handler.bufferReceived(id, buffer);
- }
- else
- {
- //Ignore - buffer came in after connection is closed
- }
+ }
}
catch (Exception e)
{
Modified: trunk/src/main/org/jboss/messaging/core/remoting/impl/invm/InVMConnector.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/impl/invm/InVMConnector.java 2009-03-23 19:56:44 UTC (rev 6145)
+++ trunk/src/main/org/jboss/messaging/core/remoting/impl/invm/InVMConnector.java 2009-03-24 10:20:42 UTC (rev 6146)
@@ -181,7 +181,7 @@
}
public void connectionDestroyed(final Object connectionID)
- {
+ {
if (connections.remove(connectionID) != null)
{
//Execute on different thread to avoid deadlocks
Modified: trunk/src/main/org/jboss/messaging/core/remoting/impl/wireformat/CreateQueueMessage.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/impl/wireformat/CreateQueueMessage.java 2009-03-23 19:56:44 UTC (rev 6145)
+++ trunk/src/main/org/jboss/messaging/core/remoting/impl/wireformat/CreateQueueMessage.java 2009-03-24 10:20:42 UTC (rev 6146)
@@ -18,7 +18,7 @@
* 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.core.remoting.impl.wireformat;
@@ -37,17 +37,24 @@
// Attributes ----------------------------------------------------
private SimpleString address;
+
private SimpleString queueName;
+
private SimpleString filterString;
+
private boolean durable;
+
private boolean temporary;
-
+
// Static --------------------------------------------------------
// Constructors --------------------------------------------------
- public CreateQueueMessage(final SimpleString address, final SimpleString queueName,
- final SimpleString filterString, final boolean durable, final boolean temporary)
+ public CreateQueueMessage(final SimpleString address,
+ final SimpleString queueName,
+ final SimpleString filterString,
+ final boolean durable,
+ final boolean temporary)
{
super(CREATE_QUEUE);
@@ -57,7 +64,7 @@
this.durable = durable;
this.temporary = temporary;
}
-
+
public CreateQueueMessage()
{
super(CREATE_QUEUE);
@@ -77,7 +84,7 @@
buff.append("]");
return buff.toString();
}
-
+
public SimpleString getAddress()
{
return address;
@@ -97,12 +104,12 @@
{
return durable;
}
-
+
public boolean isTemporary()
{
return temporary;
}
-
+
public void encodeBody(final MessagingBuffer buffer)
{
buffer.writeSimpleString(address);
@@ -111,7 +118,7 @@
buffer.writeBoolean(durable);
buffer.writeBoolean(temporary);
}
-
+
public void decodeBody(final MessagingBuffer buffer)
{
address = buffer.readSimpleString();
@@ -120,17 +127,17 @@
durable = buffer.readBoolean();
temporary = buffer.readBoolean();
}
-
+
public boolean equals(Object other)
{
if (other instanceof CreateQueueMessage == false)
{
return false;
}
-
+
CreateQueueMessage r = (CreateQueueMessage)other;
-
- return super.equals(other) && r.address.equals(this.address) &&
+
+ return super.equals(other) && r.address.equals(this.address) &&
r.queueName.equals(this.queueName) &&
(r.filterString == null ? this.filterString == null : r.filterString.equals(this.filterString)) &&
r.durable == this.durable &&
Modified: trunk/src/main/org/jboss/messaging/core/remoting/impl/wireformat/PacketImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/impl/wireformat/PacketImpl.java 2009-03-23 19:56:44 UTC (rev 6145)
+++ trunk/src/main/org/jboss/messaging/core/remoting/impl/wireformat/PacketImpl.java 2009-03-24 10:20:42 UTC (rev 6146)
@@ -158,6 +158,8 @@
public static final byte REPLICATE_ACKNOWLEDGE = 95;
+ public static final byte REPLICATE_STARTUP_INFO = 96;
+
// Static --------------------------------------------------------
public PacketImpl(final byte type)
@@ -167,7 +169,7 @@
// Public --------------------------------------------------------
-
+
public byte getType()
{
return type;
Modified: trunk/src/main/org/jboss/messaging/core/remoting/impl/wireformat/replication/ReplicateRemoteConsumerAddedMessage.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/impl/wireformat/replication/ReplicateRemoteConsumerAddedMessage.java 2009-03-23 19:56:44 UTC (rev 6145)
+++ trunk/src/main/org/jboss/messaging/core/remoting/impl/wireformat/replication/ReplicateRemoteConsumerAddedMessage.java 2009-03-24 10:20:42 UTC (rev 6146)
@@ -15,6 +15,7 @@
import org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl;
import org.jboss.messaging.core.remoting.spi.MessagingBuffer;
import org.jboss.messaging.utils.SimpleString;
+import org.jboss.messaging.utils.TypedProperties;
/**
*
@@ -36,17 +37,21 @@
private SimpleString filterString;
+ private TypedProperties properties;
+
// Static --------------------------------------------------------
// Constructors --------------------------------------------------
- public ReplicateRemoteConsumerAddedMessage(SimpleString uniqueBindingName, SimpleString filterString)
+ public ReplicateRemoteConsumerAddedMessage(SimpleString uniqueBindingName, SimpleString filterString, TypedProperties properties)
{
super(REPLICATE_ADD_REMOTE_CONSUMER);
this.uniqueBindingName = uniqueBindingName;
this.filterString = filterString;
+
+ this.properties = properties;
}
// Public --------------------------------------------------------
@@ -61,6 +66,8 @@
buffer.writeSimpleString(uniqueBindingName);
buffer.writeNullableSimpleString(filterString);
+
+ properties.encode(buffer);
}
public void decodeBody(final MessagingBuffer buffer)
@@ -68,6 +75,10 @@
uniqueBindingName = buffer.readSimpleString();
filterString = buffer.readNullableSimpleString();
+
+ properties = new TypedProperties();
+
+ properties.decode(buffer);
}
public SimpleString getUniqueBindingName()
@@ -79,6 +90,11 @@
{
return filterString;
}
+
+ public TypedProperties getProperties()
+ {
+ return properties;
+ }
// Package protected ---------------------------------------------
Modified: trunk/src/main/org/jboss/messaging/core/remoting/impl/wireformat/replication/ReplicateRemoteConsumerRemovedMessage.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/impl/wireformat/replication/ReplicateRemoteConsumerRemovedMessage.java 2009-03-23 19:56:44 UTC (rev 6145)
+++ trunk/src/main/org/jboss/messaging/core/remoting/impl/wireformat/replication/ReplicateRemoteConsumerRemovedMessage.java 2009-03-24 10:20:42 UTC (rev 6146)
@@ -15,6 +15,7 @@
import org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl;
import org.jboss.messaging.core.remoting.spi.MessagingBuffer;
import org.jboss.messaging.utils.SimpleString;
+import org.jboss.messaging.utils.TypedProperties;
/**
*
@@ -36,17 +37,21 @@
private SimpleString filterString;
+ private TypedProperties properties;
+
// Static --------------------------------------------------------
// Constructors --------------------------------------------------
- public ReplicateRemoteConsumerRemovedMessage(SimpleString uniqueBindingName, SimpleString filterString)
+ public ReplicateRemoteConsumerRemovedMessage(SimpleString uniqueBindingName, SimpleString filterString, final TypedProperties properties)
{
super(REPLICATE_REMOVE_REMOTE_CONSUMER);
this.uniqueBindingName = uniqueBindingName;
this.filterString = filterString;
+
+ this.properties = properties;
}
// Public --------------------------------------------------------
@@ -61,6 +66,8 @@
buffer.writeSimpleString(uniqueBindingName);
buffer.writeNullableSimpleString(filterString);
+
+ properties.encode(buffer);
}
public void decodeBody(final MessagingBuffer buffer)
@@ -68,6 +75,10 @@
uniqueBindingName = buffer.readSimpleString();
filterString = buffer.readNullableSimpleString();
+
+ properties = new TypedProperties();
+
+ properties.decode(buffer);
}
public SimpleString getUniqueBindingName()
@@ -79,6 +90,11 @@
{
return filterString;
}
+
+ public TypedProperties getProperties()
+ {
+ return properties;
+ }
// Package protected ---------------------------------------------
Modified: trunk/src/main/org/jboss/messaging/core/remoting/server/impl/RemotingServiceImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/server/impl/RemotingServiceImpl.java 2009-03-23 19:56:44 UTC (rev 6145)
+++ trunk/src/main/org/jboss/messaging/core/remoting/server/impl/RemotingServiceImpl.java 2009-03-24 10:20:42 UTC (rev 6146)
@@ -24,6 +24,7 @@
import org.jboss.messaging.core.remoting.impl.AbstractBufferHandler;
import org.jboss.messaging.core.remoting.impl.RemotingConnectionImpl;
import org.jboss.messaging.core.remoting.impl.invm.InVMAcceptorFactory;
+import org.jboss.messaging.core.remoting.impl.invm.TransportConstants;
import org.jboss.messaging.core.remoting.server.RemotingService;
import org.jboss.messaging.core.remoting.spi.Acceptor;
import org.jboss.messaging.core.remoting.spi.AcceptorFactory;
@@ -160,7 +161,7 @@
Class<?> clazz = loader.loadClass(info.getFactoryClassName());
AcceptorFactory factory = (AcceptorFactory)clazz.newInstance();
-
+
Acceptor acceptor = factory.createAcceptor(info.getParams(), bufferHandler, this);
acceptors.add(acceptor);
@@ -184,12 +185,12 @@
failedConnectionTimer = new Timer(true);
failedConnectionsTask = new FailedConnectionsTask();
-
+
failedConnectionTimer.schedule(failedConnectionsTask, connectionScanPeriod, connectionScanPeriod);
started = true;
}
-
+
public synchronized void stop()
{
if (!started)
@@ -327,7 +328,7 @@
if (conn.isExpired(now))
{
failedConnections.add(conn);
- }
+ }
}
for (RemotingConnection conn : failedConnections)
@@ -346,13 +347,12 @@
return super.cancel();
}
-
}
private class DelegatingBufferHandler extends AbstractBufferHandler
{
public void bufferReceived(final Object connectionID, final MessagingBuffer buffer)
- {
+ {
RemotingConnection conn = connections.get(connectionID);
if (conn != null)
Modified: trunk/src/main/org/jboss/messaging/core/remoting/spi/Connection.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/spi/Connection.java 2009-03-23 19:56:44 UTC (rev 6145)
+++ trunk/src/main/org/jboss/messaging/core/remoting/spi/Connection.java 2009-03-24 10:20:42 UTC (rev 6146)
@@ -24,8 +24,6 @@
import org.jboss.messaging.core.exception.MessagingException;
-
-
/**
*
* @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
@@ -44,6 +42,6 @@
void close();
String getRemoteAddress();
-
+
void fail(MessagingException me);
}
\ No newline at end of file
Modified: trunk/src/main/org/jboss/messaging/core/server/MessagingServer.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/MessagingServer.java 2009-03-23 19:56:44 UTC (rev 6145)
+++ trunk/src/main/org/jboss/messaging/core/server/MessagingServer.java 2009-03-24 10:20:42 UTC (rev 6146)
@@ -16,7 +16,6 @@
import java.util.Set;
import org.jboss.messaging.core.config.Configuration;
-import org.jboss.messaging.core.config.TransportConfiguration;
import org.jboss.messaging.core.management.ManagementService;
import org.jboss.messaging.core.management.MessagingServerControlMBean;
import org.jboss.messaging.core.persistence.StorageManager;
@@ -33,7 +32,6 @@
import org.jboss.messaging.core.settings.impl.AddressSettings;
import org.jboss.messaging.core.transaction.ResourceManager;
import org.jboss.messaging.core.version.Version;
-import org.jboss.messaging.utils.Pair;
import org.jboss.messaging.utils.SimpleString;
import org.jboss.messaging.utils.UUID;
@@ -127,7 +125,11 @@
SimpleString getNodeID();
- UUID getUUID();
-
Channel getReplicatingChannel();
+
+ void initialiseBackup(UUID nodeID, long currentMessageID) throws Exception;
+
+ boolean isInitialised();
+
+ Queue createQueue(SimpleString address, SimpleString queueName, SimpleString filter, boolean durable, boolean temporary) throws Exception;
}
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-03-23 19:56:44 UTC (rev 6145)
+++ trunk/src/main/org/jboss/messaging/core/server/cluster/impl/BridgeImpl.java 2009-03-24 10:20:42 UTC (rev 6146)
@@ -27,6 +27,7 @@
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_ACKNOWLEDGE;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_NON_PERSISTENT_SEND;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_PERSISTENT_SEND;
+import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_CALL_TIMEOUT;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_CONNECTION_LOAD_BALANCING_POLICY_CLASS_NAME;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_CONNECTION_TTL;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_CONSUMER_MAX_RATE;
@@ -63,6 +64,7 @@
import org.jboss.messaging.core.management.ObjectNames;
import org.jboss.messaging.core.message.Message;
import org.jboss.messaging.core.message.impl.MessageImpl;
+import org.jboss.messaging.core.persistence.StorageManager;
import org.jboss.messaging.core.postoffice.BindingType;
import org.jboss.messaging.core.remoting.Channel;
import org.jboss.messaging.core.remoting.FailureListener;
@@ -81,7 +83,6 @@
import org.jboss.messaging.utils.Pair;
import org.jboss.messaging.utils.SimpleString;
import org.jboss.messaging.utils.UUID;
-import org.jboss.messaging.utils.UUIDGenerator;
/**
* A BridgeImpl
@@ -136,9 +137,9 @@
private final double retryIntervalMultiplier;
- private final int maxRetriesBeforeFailover;
+ private final int initialConnectAttempts;
- private final int maxRetriesAfterFailover;
+ private final int reconnectAttempts;
private final SimpleString idsHeaderName;
@@ -146,12 +147,14 @@
private final SimpleString managementAddress;
- private final SimpleString managementNotificationAddres;
+ private final SimpleString managementNotificationAddress;
private final String clusterPassword;
+ private final StorageManager storageManager;
+
private Channel replicatingChannel;
-
+
private boolean activated;
// Static --------------------------------------------------------
@@ -171,14 +174,15 @@
final Transformer transformer,
final long retryInterval,
final double retryIntervalMultiplier,
- final int maxRetriesBeforeFailover,
- final int maxRetriesAfterFailover,
+ final int initialConnectAttempts,
+ final int reconnectAttempts,
final boolean useDuplicateDetection,
final SimpleString managementAddress,
final SimpleString managementNotificationAddress,
final String clusterPassword,
final Channel replicatingChannel,
- final boolean activated) throws Exception
+ final boolean activated,
+ final StorageManager storageManager) throws Exception
{
this(nodeUUID,
name,
@@ -191,15 +195,16 @@
transformer,
retryInterval,
retryIntervalMultiplier,
- maxRetriesBeforeFailover,
- maxRetriesAfterFailover,
+ initialConnectAttempts,
+ reconnectAttempts,
useDuplicateDetection,
managementAddress,
managementNotificationAddress,
clusterPassword,
null,
replicatingChannel,
- activated);
+ activated,
+ storageManager);
}
public BridgeImpl(final UUID nodeUUID,
@@ -213,15 +218,16 @@
final Transformer transformer,
final long retryInterval,
final double retryIntervalMultiplier,
- final int maxRetriesBeforeFailover,
- final int maxRetriesAfterFailover,
+ final int initialConnectAttempts,
+ final int reconnectAttempts,
final boolean useDuplicateDetection,
final SimpleString managementAddress,
final SimpleString managementNotificationAddress,
final String clusterPassword,
final MessageFlowRecord flowRecord,
final Channel replicatingChannel,
- final boolean activated) throws Exception
+ final boolean activated,
+ final StorageManager storageManager) throws Exception
{
this.nodeUUID = nodeUUID;
@@ -254,23 +260,25 @@
this.retryIntervalMultiplier = retryIntervalMultiplier;
- this.maxRetriesBeforeFailover = maxRetriesBeforeFailover;
+ this.initialConnectAttempts = initialConnectAttempts;
- this.maxRetriesAfterFailover = maxRetriesAfterFailover;
+ this.reconnectAttempts = reconnectAttempts;
this.idsHeaderName = MessageImpl.HDR_ROUTE_TO_IDS.concat(name);
this.managementAddress = managementAddress;
- this.managementNotificationAddres = managementNotificationAddress;
+ this.managementNotificationAddress = managementNotificationAddress;
this.clusterPassword = clusterPassword;
this.flowRecord = flowRecord;
this.replicatingChannel = replicatingChannel;
-
- this.activated = activated;
+
+ this.activated = activated;
+
+ this.storageManager = storageManager;
}
public synchronized void start() throws Exception
@@ -321,7 +329,7 @@
executor.execute(new StopRunnable());
- this.waitForRunnablesToComplete();
+ waitForRunnablesToComplete();
}
public boolean isStarted()
@@ -332,7 +340,7 @@
public synchronized void activate()
{
replicatingChannel = null;
-
+
activated = true;
executor.execute(new CreateObjectsRunnable());
@@ -400,7 +408,7 @@
{
Packet packet = new ReplicateAcknowledgeMessage(name, ref.getMessage().getMessageID());
- replicatingChannel.replicatePacket(packet, 2, new Runnable()
+ replicatingChannel.replicatePacket(packet, 1, new Runnable()
{
public void run()
{
@@ -410,7 +418,7 @@
}
catch (Exception e)
{
- log.info("Failed to ack", e);
+ log.error("Failed to ack", e);
}
}
});
@@ -419,7 +427,7 @@
}
catch (Exception e)
{
- log.info("Failed to ack", e);
+ log.error("Failed to ack", e);
}
}
@@ -431,7 +439,7 @@
{
return HandleStatus.NO_MATCH;
}
-
+
if (!active)
{
return HandleStatus.BUSY;
@@ -543,7 +551,7 @@
if (!ok)
{
- log.warn("Timed out waiting for batch to be sent");
+ log.warn("Timed out waiting to stop");
}
}
@@ -561,7 +569,7 @@
{
return false;
}
-
+
try
{
queue.addConsumer(BridgeImpl.this);
@@ -571,7 +579,7 @@
DEFAULT_CONNECTION_LOAD_BALANCING_POLICY_CLASS_NAME,
DEFAULT_PING_PERIOD,
DEFAULT_CONNECTION_TTL,
- 5000,
+ DEFAULT_CALL_TIMEOUT,
DEFAULT_CONSUMER_WINDOW_SIZE,
DEFAULT_CONSUMER_MAX_RATE,
DEFAULT_SEND_WINDOW_SIZE,
@@ -586,8 +594,8 @@
DEFAULT_ACK_BATCH_SIZE,
retryInterval,
retryIntervalMultiplier,
- maxRetriesBeforeFailover,
- maxRetriesAfterFailover);
+ initialConnectAttempts,
+ reconnectAttempts);
session = (ClientSessionInternal)csf.createSession(SecurityStoreImpl.CLUSTER_ADMIN_USER,
clusterPassword,
@@ -596,7 +604,7 @@
true,
false,
1);
-
+
if (session == null)
{
// This can happen if the bridge is shutdown
@@ -616,10 +624,14 @@
{
// Get the queue data
- SimpleString notifQueueName = new SimpleString("notif-").concat(UUIDGenerator.getInstance()
- .generateSimpleStringUUID());
+ // Create a queue to catch the notifications - the name must be deterministic on live and backup, but
+ // different each time this is called
+ // Otherwise it may already exist if server is restarted before it has been deleted on backup
- // TODO - simplify this
+ String qName = "notif-" + nodeUUID.toString() + "-" + name.toString();
+
+ SimpleString notifQueueName = new SimpleString(qName);
+
SimpleString filter = new SimpleString(ManagementHelper.HDR_BINDING_TYPE + "<>" +
BindingType.DIVERT.toInt() +
" AND " +
@@ -642,7 +654,25 @@
flowRecord.getAddress() +
"%')");
- session.createQueue(managementNotificationAddres, notifQueueName, filter, false, true);
+ //The queue can't be temporary, since if the node with the bridge crashes then is restarted quickly
+ //it might get deleted on the target when it does connection cleanup
+
+ //When the backup activates the queue might already exist, so we catch this and ignore
+ try
+ {
+ session.createQueue(managementNotificationAddress, notifQueueName, filter, false, false);
+ }
+ catch (MessagingException me)
+ {
+ if (me.getCode() == MessagingException.QUEUE_EXISTS)
+ {
+ //Ok
+ }
+ else
+ {
+ throw me;
+ }
+ }
ClientConsumer notifConsumer = session.createConsumer(notifQueueName);
Modified: trunk/src/main/org/jboss/messaging/core/server/cluster/impl/BroadcastGroupImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/cluster/impl/BroadcastGroupImpl.java 2009-03-23 19:56:44 UTC (rev 6145)
+++ trunk/src/main/org/jboss/messaging/core/server/cluster/impl/BroadcastGroupImpl.java 2009-03-24 10:20:42 UTC (rev 6146)
@@ -86,8 +86,6 @@
this.groupPort = groupPort;
this.active = active;
-
- log.info("created broadcast group active "+ active);
}
public synchronized void start() throws Exception
Modified: trunk/src/main/org/jboss/messaging/core/server/cluster/impl/ClusterConnectionImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/cluster/impl/ClusterConnectionImpl.java 2009-03-23 19:56:44 UTC (rev 6145)
+++ trunk/src/main/org/jboss/messaging/core/server/cluster/impl/ClusterConnectionImpl.java 2009-03-24 10:20:42 UTC (rev 6146)
@@ -45,19 +45,18 @@
import org.jboss.messaging.core.management.ManagementService;
import org.jboss.messaging.core.management.Notification;
import org.jboss.messaging.core.management.NotificationType;
-import org.jboss.messaging.core.persistence.StorageManager;
import org.jboss.messaging.core.postoffice.Binding;
import org.jboss.messaging.core.postoffice.Bindings;
import org.jboss.messaging.core.postoffice.PostOffice;
-import org.jboss.messaging.core.postoffice.impl.LocalQueueBinding;
import org.jboss.messaging.core.remoting.Channel;
import org.jboss.messaging.core.remoting.Packet;
+import org.jboss.messaging.core.remoting.impl.wireformat.CreateQueueMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.replication.ReplicateRemoteBindingAddedMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.replication.ReplicateRemoteBindingRemovedMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.replication.ReplicateRemoteConsumerAddedMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.replication.ReplicateRemoteConsumerRemovedMessage;
+import org.jboss.messaging.core.server.MessagingServer;
import org.jboss.messaging.core.server.Queue;
-import org.jboss.messaging.core.server.QueueFactory;
import org.jboss.messaging.core.server.cluster.Bridge;
import org.jboss.messaging.core.server.cluster.ClusterConnection;
import org.jboss.messaging.core.server.cluster.MessageFlowRecord;
@@ -83,7 +82,7 @@
private final org.jboss.messaging.utils.ExecutorFactory executorFactory;
- private final StorageManager storageManager;
+ private final MessagingServer server;
private final PostOffice postOffice;
@@ -97,9 +96,9 @@
private final double retryIntervalMultiplier;
- private final int maxRetriesBeforeFailover;
+ private final int initialConnectAttempts;
- private final int maxRetriesAfterFailover;
+ private final int reconnectAttempts;
private final boolean useDuplicateDetection;
@@ -111,20 +110,18 @@
private final ScheduledExecutorService scheduledExecutor;
- private final QueueFactory queueFactory;
-
private final int maxHops;
private final UUID nodeUUID;
private final Channel replicatingChannel;
-
+
private final List<Pair<TransportConfiguration, TransportConfiguration>> staticConnectors;
private boolean backup;
private volatile boolean started;
-
+
/*
* Constructor using static list of connectors
*/
@@ -132,16 +129,15 @@
final SimpleString address,
final long retryInterval,
final double retryIntervalMultiplier,
- final int maxRetriesBeforeFailover,
- final int maxRetriesAfterFailover,
+ final int initialConnectAttempts,
+ final int reconnectAttempts,
final boolean useDuplicateDetection,
final boolean routeWhenNoConsumers,
final org.jboss.messaging.utils.ExecutorFactory executorFactory,
- final StorageManager storageManager,
+ final MessagingServer server,
final PostOffice postOffice,
final ManagementService managementService,
final ScheduledExecutorService scheduledExecutor,
- final QueueFactory queueFactory,
final List<Pair<TransportConfiguration, TransportConfiguration>> connectors,
final int maxHops,
final UUID nodeUUID,
@@ -156,9 +152,9 @@
this.retryIntervalMultiplier = retryIntervalMultiplier;
- this.maxRetriesBeforeFailover = maxRetriesBeforeFailover;
+ this.initialConnectAttempts = initialConnectAttempts;
- this.maxRetriesAfterFailover = maxRetriesAfterFailover;
+ this.reconnectAttempts = reconnectAttempts;
this.useDuplicateDetection = useDuplicateDetection;
@@ -166,7 +162,7 @@
this.executorFactory = executorFactory;
- this.storageManager = storageManager;
+ this.server = server;
this.postOffice = postOffice;
@@ -176,19 +172,25 @@
this.scheduledExecutor = scheduledExecutor;
- this.queueFactory = queueFactory;
-
this.maxHops = maxHops;
+ if (nodeUUID == null)
+ {
+ throw new IllegalArgumentException("node id is null");
+ }
+
this.nodeUUID = nodeUUID;
this.replicatingChannel = replicatingChannel;
this.backup = backup;
-
+
this.staticConnectors = connectors;
- this.updateConnectors(connectors);
+ if (!backup)
+ {
+ this.updateConnectors(connectors);
+ }
}
/*
@@ -198,16 +200,15 @@
final SimpleString address,
final long retryInterval,
final double retryIntervalMultiplier,
- final int maxRetriesBeforeFailover,
- final int maxRetriesAfterFailover,
+ final int initialConnectAttempts,
+ final int reconnectAttempts,
final boolean useDuplicateDetection,
final boolean routeWhenNoConsumers,
final ExecutorFactory executorFactory,
- final StorageManager storageManager,
+ final MessagingServer server,
final PostOffice postOffice,
final ManagementService managementService,
final ScheduledExecutorService scheduledExecutor,
- final QueueFactory queueFactory,
final DiscoveryGroup discoveryGroup,
final int maxHops,
final UUID nodeUUID,
@@ -222,13 +223,13 @@
this.retryIntervalMultiplier = retryIntervalMultiplier;
- this.maxRetriesBeforeFailover = maxRetriesBeforeFailover;
+ this.initialConnectAttempts = initialConnectAttempts;
- this.maxRetriesAfterFailover = maxRetriesAfterFailover;
+ this.reconnectAttempts = reconnectAttempts;
this.executorFactory = executorFactory;
- this.storageManager = storageManager;
+ this.server = server;
this.postOffice = postOffice;
@@ -236,8 +237,6 @@
this.scheduledExecutor = scheduledExecutor;
- this.queueFactory = queueFactory;
-
this.discoveryGroup = discoveryGroup;
this.useDuplicateDetection = useDuplicateDetection;
@@ -251,7 +250,7 @@
this.replicatingChannel = replicatingChannel;
this.backup = backup;
-
+
this.staticConnectors = null;
}
@@ -302,8 +301,13 @@
public synchronized void activate()
{
+ if (!started)
+ {
+ return;
+ }
+
backup = false;
-
+
if (discoveryGroup != null)
{
connectorsChanged();
@@ -320,7 +324,7 @@
}
}
}
-
+
// DiscoveryListener implementation ------------------------------------------------------------------
public synchronized void connectorsChanged()
@@ -329,7 +333,7 @@
{
return;
}
-
+
try
{
List<Pair<TransportConfiguration, TransportConfiguration>> connectors = discoveryGroup.getConnectors();
@@ -371,11 +375,11 @@
}
}
- for (Pair<TransportConfiguration, TransportConfiguration> connectorPair : connectors)
+ for (final Pair<TransportConfiguration, TransportConfiguration> connectorPair : connectors)
{
if (!records.containsKey(connectorPair))
{
- SimpleString queueName = generateQueueName(name, connectorPair);
+ final SimpleString queueName = generateQueueName(name, connectorPair);
Binding queueBinding = postOffice.getBinding(queueName);
@@ -384,51 +388,79 @@
if (queueBinding != null)
{
queue = (Queue)queueBinding.getBindable();
+
+ createNewRecord(connectorPair, queueName, queue);
}
else
{
- queue = queueFactory.createQueue(-1, queueName, queueName, null, true, false);
-
// Add binding in storage so the queue will get reloaded on startup and we can find it - it's never
// actually routed to at that address though
-
- Binding storeBinding = new LocalQueueBinding(queue.getName(),
- queue,
- new SimpleString(nodeUUID.toString()));
-
- storageManager.addQueueBinding(storeBinding);
+
+ if (replicatingChannel == null)
+ {
+ queue = server.createQueue(queueName, queueName, null, true, false);
+
+ createNewRecord(connectorPair, queueName, queue);
+ }
+ else
+ {
+ //Replicate the createQueue first
+ Packet packet = new CreateQueueMessage(queueName, queueName, null, true, false);
+
+ replicatingChannel.replicatePacket(packet, 1, new Runnable()
+ {
+ public void run()
+ {
+ try
+ {
+ Queue queue = server.createQueue(queueName, queueName, null, true, false);
+
+ createNewRecord(connectorPair, queueName, queue);
+ }
+ catch (Exception e)
+ {
+ log.error("Failed create record", e);
+ }
+ }
+ });
+ }
}
+ }
+ }
+ }
+
+ private void createNewRecord(final Pair<TransportConfiguration, TransportConfiguration> connectorPair, final SimpleString queueName,
+ final Queue queue) throws Exception
+ {
+ MessageFlowRecordImpl record = new MessageFlowRecordImpl(queue);
- MessageFlowRecordImpl record = new MessageFlowRecordImpl(queue);
+ Bridge bridge = new BridgeImpl(nodeUUID,
+ queueName,
+ queue,
+ connectorPair,
+ executorFactory.getExecutor(),
+ null,
+ null,
+ scheduledExecutor,
+ null,
+ retryInterval,
+ retryIntervalMultiplier,
+ initialConnectAttempts,
+ reconnectAttempts,
+ useDuplicateDetection,
+ managementService.getManagementAddress(),
+ managementService.getManagementNotificationAddress(),
+ managementService.getClusterPassword(),
+ record,
+ replicatingChannel,
+ !backup,
+ server.getStorageManager());
- Bridge bridge = new BridgeImpl(nodeUUID,
- queueName,
- queue,
- connectorPair,
- executorFactory.getExecutor(),
- null,
- null,
- scheduledExecutor,
- null,
- retryInterval,
- retryIntervalMultiplier,
- maxRetriesBeforeFailover,
- maxRetriesAfterFailover,
- false, // Duplicate detection is handled in the RemoteQueueBindingImpl,
- managementService.getManagementAddress(),
- managementService.getManagementNotificationAddress(),
- managementService.getClusterPassword(),
- record,
- replicatingChannel,
- !backup);
+ record.setBridge(bridge);
- record.setBridge(bridge);
+ records.put(connectorPair, record);
- records.put(connectorPair, record);
-
- bridge.start();
- }
- }
+ bridge.start();
}
private SimpleString generateQueueName(final SimpleString clusterName,
@@ -506,7 +538,7 @@
}
public void close() throws Exception
- {
+ {
bridge.stop();
clearBindings();
@@ -522,11 +554,10 @@
clearBindings();
}
-
public void onMessage(final ClientMessage message)
{
try
- {
+ {
// Reset the bindings
if (message.getProperty(HDR_RESET_QUEUE_DATA) != null)
{
@@ -541,7 +572,7 @@
{
return;
}
-
+
// TODO - optimised this by just passing int in header - but filter needs to be extended to support IN with
// a list of integers
SimpleString type = (SimpleString)message.getProperty(ManagementHelper.HDR_NOTIFICATION_TYPE);
@@ -598,7 +629,7 @@
bindings.clear();
}
-
+
private void doBindingAdded(final ClientMessage message, final Channel replChannel) throws Exception
{
Integer distance = (Integer)message.getProperty(ManagementHelper.HDR_DISTANCE);
@@ -637,12 +668,19 @@
{
throw new IllegalStateException("queueID is null");
}
-
+
if (replChannel != null)
{
- Packet packet = new ReplicateRemoteBindingAddedMessage(name, queueAddress, clusterName, routingName, queueID, filterString, queue.getName(), distance + 1);
-
- replChannel.replicatePacket(packet, 2, new Runnable()
+ Packet packet = new ReplicateRemoteBindingAddedMessage(name,
+ queueAddress,
+ clusterName,
+ routingName,
+ queueID,
+ filterString,
+ queue.getName(),
+ distance + 1);
+
+ replChannel.replicatePacket(packet, 1, new Runnable()
{
public void run()
{
@@ -658,36 +696,36 @@
});
}
else
- {
+ {
RemoteQueueBinding binding = new RemoteQueueBindingImpl(queueAddress,
clusterName,
routingName,
queueID,
filterString,
queue,
- useDuplicateDetection,
+ // useDuplicateDetection,
bridge.getName(),
distance + 1);
-
+
bindings.put(clusterName, binding);
-
+
if (postOffice.getBinding(clusterName) != null)
{
// Sanity check - this means the binding has already been added via another bridge, probably max
// hops is too high
// or there are multiple cluster connections for the same address
-
+
log.warn("Remoting queue binding " + clusterName +
" has already been bound in the post office. Most likely cause for this is you have a loop " +
"in your cluster due to cluster max-hops being too large or you have multiple cluster connections to the same nodes using overlapping addresses");
-
+
return;
}
-
+
postOffice.addBinding(binding);
-
+
Bindings theBindings = postOffice.getBindingsForAddress(queueAddress);
-
+
theBindings.setRouteWhenNoConsumers(routeWhenNoConsumers);
}
}
@@ -700,12 +738,12 @@
{
throw new IllegalStateException("clusterName is null");
}
-
+
if (replChannel != null)
{
Packet packet = new ReplicateRemoteBindingRemovedMessage(clusterName);
-
- replChannel.replicatePacket(packet, 2, new Runnable()
+
+ replChannel.replicatePacket(packet, 1, new Runnable()
{
public void run()
{
@@ -721,14 +759,14 @@
});
}
else
- {
+ {
RemoteQueueBinding binding = bindings.remove(clusterName);
-
+
if (binding == null)
{
throw new IllegalStateException("Cannot find binding for queue " + clusterName);
}
-
+
postOffice.removeBinding(binding.getUniqueName());
}
}
@@ -748,14 +786,16 @@
{
throw new IllegalStateException("clusterName is null");
}
+
+ message.putIntProperty(ManagementHelper.HDR_DISTANCE, distance + 1);
SimpleString filterString = (SimpleString)message.getProperty(ManagementHelper.HDR_FILTERSTRING);
-
+
if (replChannel != null)
{
- Packet packet = new ReplicateRemoteConsumerAddedMessage(clusterName, filterString);
-
- replChannel.replicatePacket(packet, 2, new Runnable()
+ Packet packet = new ReplicateRemoteConsumerAddedMessage(clusterName, filterString, message.getProperties());
+
+ replChannel.replicatePacket(packet, 1, new Runnable()
{
public void run()
{
@@ -771,21 +811,19 @@
});
}
else
- {
+ {
RemoteQueueBinding binding = bindings.get(clusterName);
-
+
if (binding == null)
{
throw new IllegalStateException("Cannot find binding for " + clusterName);
}
-
+
binding.addConsumer(filterString);
-
- message.putIntProperty(ManagementHelper.HDR_DISTANCE, distance + 1);
-
+
// Need to propagate the consumer add
Notification notification = new Notification(CONSUMER_CREATED, message.getProperties());
-
+
managementService.sendNotification(notification);
}
}
@@ -805,14 +843,16 @@
{
throw new IllegalStateException("clusterName is null");
}
+
+ message.putIntProperty(ManagementHelper.HDR_DISTANCE, distance + 1);
SimpleString filterString = (SimpleString)message.getProperty(ManagementHelper.HDR_FILTERSTRING);
-
+
if (replChannel != null)
{
- Packet packet = new ReplicateRemoteConsumerRemovedMessage(clusterName, filterString);
-
- replChannel.replicatePacket(packet, 2, new Runnable()
+ Packet packet = new ReplicateRemoteConsumerRemovedMessage(clusterName, filterString, message.getProperties());
+
+ replChannel.replicatePacket(packet, 1, new Runnable()
{
public void run()
{
@@ -828,29 +868,25 @@
});
}
else
- {
+ {
RemoteQueueBinding binding = bindings.get(clusterName);
-
+
if (binding == null)
{
throw new IllegalStateException("Cannot find binding for " + clusterName);
}
-
+
binding.removeConsumer(filterString);
-
- message.putIntProperty(ManagementHelper.HDR_DISTANCE, distance + 1);
-
+
+
// Need to propagate the consumer close
Notification notification = new Notification(CONSUMER_CLOSED, message.getProperties());
-
+
managementService.sendNotification(notification);
}
}
-
}
-
-
public void handleReplicatedAddBinding(final SimpleString address,
final SimpleString uniqueName,
@@ -875,7 +911,7 @@
queueID,
filterString,
queue,
- useDuplicateDetection,
+ // useDuplicateDetection,
queueName,
distance);
Modified: trunk/src/main/org/jboss/messaging/core/server/cluster/impl/ClusterManagerImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/cluster/impl/ClusterManagerImpl.java 2009-03-23 19:56:44 UTC (rev 6145)
+++ trunk/src/main/org/jboss/messaging/core/server/cluster/impl/ClusterManagerImpl.java 2009-03-24 10:20:42 UTC (rev 6146)
@@ -48,6 +48,7 @@
import org.jboss.messaging.core.postoffice.Binding;
import org.jboss.messaging.core.postoffice.PostOffice;
import org.jboss.messaging.core.remoting.Channel;
+import org.jboss.messaging.core.server.MessagingServer;
import org.jboss.messaging.core.server.Queue;
import org.jboss.messaging.core.server.QueueFactory;
import org.jboss.messaging.core.server.cluster.Bridge;
@@ -81,9 +82,9 @@
private final Map<String, ClusterConnection> clusters = new HashMap<String, ClusterConnection>();
private final org.jboss.messaging.utils.ExecutorFactory executorFactory;
+
+ private final MessagingServer server;
- private final StorageManager storageManager;
-
private final PostOffice postOffice;
private final ScheduledExecutorService scheduledExecutor;
@@ -92,8 +93,6 @@
private final Configuration configuration;
- private final QueueFactory queueFactory;
-
private final UUID nodeUUID;
private Channel replicatingChannel;
@@ -103,20 +102,24 @@
private boolean backup;
public ClusterManagerImpl(final org.jboss.messaging.utils.ExecutorFactory executorFactory,
- final StorageManager storageManager,
+ final MessagingServer server,
final PostOffice postOffice,
final ScheduledExecutorService scheduledExecutor,
final ManagementService managementService,
final Configuration configuration,
- final QueueFactory queueFactory,
final UUID nodeUUID,
final Channel replicatingChannel,
final boolean backup)
{
+ if (nodeUUID == null)
+ {
+ throw new IllegalArgumentException("Node uuid is null");
+ }
+
this.executorFactory = executorFactory;
+
+ this.server = server;
- this.storageManager = storageManager;
-
this.postOffice = postOffice;
this.scheduledExecutor = scheduledExecutor;
@@ -125,8 +128,6 @@
this.configuration = configuration;
- this.queueFactory = queueFactory;
-
this.nodeUUID = nodeUUID;
this.replicatingChannel = replicatingChannel;
@@ -225,7 +226,7 @@
}
public synchronized void activate()
- {
+ {
for (BroadcastGroup bg: broadcastGroups.values())
{
bg.activate();
@@ -417,8 +418,6 @@
Pair<TransportConfiguration, TransportConfiguration> pair = new Pair<TransportConfiguration, TransportConfiguration>(connector,
backupConnector);
- log.info("deploying bridge, backup is " + backup);
-
bridge = new BridgeImpl(nodeUUID,
new SimpleString(config.getName()),
queue,
@@ -430,14 +429,15 @@
transformer,
config.getRetryInterval(),
config.getRetryIntervalMultiplier(),
- config.getMaxRetriesBeforeFailover(),
- config.getMaxRetriesAfterFailover(),
+ config.getInitialConnectAttempts(),
+ config.getReconnectAttempts(),
config.isUseDuplicateDetection(),
managementService.getManagementAddress(),
managementService.getManagementNotificationAddress(),
managementService.getClusterPassword(),
replicatingChannel,
- !backup);
+ !backup,
+ server.getStorageManager());
bridges.put(config.getName(), bridge);
@@ -506,16 +506,15 @@
new SimpleString(config.getAddress()),
config.getRetryInterval(),
config.getRetryIntervalMultiplier(),
- config.getMaxRetriesBeforeFailover(),
- config.getMaxRetriesAfterFailover(),
+ config.getInitialConnectAttempts(),
+ config.getReconnectAttempts(),
config.isDuplicateDetection(),
config.isForwardWhenNoConsumers(),
executorFactory,
- storageManager,
+ server,
postOffice,
managementService,
- scheduledExecutor,
- queueFactory,
+ scheduledExecutor,
connectors,
config.getMaxHops(),
nodeUUID,
@@ -536,16 +535,15 @@
new SimpleString(config.getAddress()),
config.getRetryInterval(),
config.getRetryIntervalMultiplier(),
- config.getMaxRetriesBeforeFailover(),
- config.getMaxRetriesAfterFailover(),
+ config.getInitialConnectAttempts(),
+ config.getReconnectAttempts(),
config.isDuplicateDetection(),
config.isForwardWhenNoConsumers(),
executorFactory,
- storageManager,
+ server,
postOffice,
managementService,
- scheduledExecutor,
- queueFactory,
+ scheduledExecutor,
dg,
config.getMaxHops(),
nodeUUID,
Modified: trunk/src/main/org/jboss/messaging/core/server/cluster/impl/RemoteQueueBindingImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/cluster/impl/RemoteQueueBindingImpl.java 2009-03-23 19:56:44 UTC (rev 6145)
+++ trunk/src/main/org/jboss/messaging/core/server/cluster/impl/RemoteQueueBindingImpl.java 2009-03-24 10:20:42 UTC (rev 6146)
@@ -71,7 +71,7 @@
private int consumerCount;
- private final boolean duplicateDetection;
+ // private final boolean duplicateDetection;
private final SimpleString idsHeaderName;
@@ -85,7 +85,7 @@
final int remoteQueueID,
final SimpleString filterString,
final Queue storeAndForwardQueue,
- final boolean duplicateDetection,
+ // final boolean duplicateDetection,
final SimpleString bridgeName,
final int distance) throws Exception
{
@@ -99,7 +99,7 @@
this.remoteQueueID = remoteQueueID;
- this.duplicateDetection = duplicateDetection;
+ // this.duplicateDetection = duplicateDetection;
if (filterString != null)
{
@@ -201,7 +201,7 @@
}
public void willRoute(final ServerMessage message)
- {
+ {
//We add a header with the name of the queue, holding a list of the transient ids of the queues to route to
//TODO - this can be optimised
@@ -227,14 +227,18 @@
message.putBytesProperty(idsHeaderName, ids);
- //Now add a duplicate detection header, if required.
- //We use a GUID for this
- if (duplicateDetection)
- {
- byte[] guid = UUIDGenerator.getInstance().generateUUID().asBytes();
-
- message.putBytesProperty(MessageImpl.HDR_DUPLICATE_DETECTION_ID, guid);
- }
+ //TODO we can't use a GUID for duplicate detection, since this is not deterministic on live and backup
+ //So we just use bridge duplicate detection
+
+// //Now add a duplicate detection header, if required.
+// //This MUST be deterministic on live and backup, and globally unique
+// xx
+// if (duplicateDetection)
+// {
+// byte[] guid = UUIDGenerator.getInstance().generateUUID().asBytes();
+//
+// message.putBytesProperty(MessageImpl.HDR_DUPLICATE_DETECTION_ID, guid);
+// }
}
public synchronized void addConsumer(final SimpleString filterString) throws Exception
Modified: trunk/src/main/org/jboss/messaging/core/server/impl/MessagingServerImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/impl/MessagingServerImpl.java 2009-03-23 19:56:44 UTC (rev 6145)
+++ trunk/src/main/org/jboss/messaging/core/server/impl/MessagingServerImpl.java 2009-03-24 10:20:42 UTC (rev 6146)
@@ -50,10 +50,12 @@
import org.jboss.messaging.core.postoffice.impl.PostOfficeImpl;
import org.jboss.messaging.core.remoting.Channel;
import org.jboss.messaging.core.remoting.FailureListener;
+import org.jboss.messaging.core.remoting.Packet;
import org.jboss.messaging.core.remoting.RemotingConnection;
import org.jboss.messaging.core.remoting.impl.RemotingConnectionImpl;
import org.jboss.messaging.core.remoting.impl.wireformat.CreateSessionResponseMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.ReattachSessionResponseMessage;
+import org.jboss.messaging.core.remoting.impl.wireformat.replication.ReplicateStartupInfoMessage;
import org.jboss.messaging.core.remoting.server.RemotingService;
import org.jboss.messaging.core.remoting.spi.Connection;
import org.jboss.messaging.core.remoting.spi.ConnectionLifeCycleListener;
@@ -76,9 +78,11 @@
import org.jboss.messaging.core.transaction.ResourceManager;
import org.jboss.messaging.core.transaction.impl.ResourceManagerImpl;
import org.jboss.messaging.core.version.Version;
+import org.jboss.messaging.utils.Future;
import org.jboss.messaging.utils.Pair;
import org.jboss.messaging.utils.SimpleString;
import org.jboss.messaging.utils.UUID;
+import org.jboss.messaging.utils.UUIDGenerator;
import org.jboss.messaging.utils.VersionLoader;
/**
@@ -146,6 +150,10 @@
private Channel replicatingChannel;
private Object replicatingChannelLock = new Object();
+
+ private final Object initialiseLock = new Object();
+
+ private boolean initialised;
// plugins
@@ -166,19 +174,14 @@
{
// We need to hard code the version information into a source file
- version = VersionLoader.getVersion();
+ version = VersionLoader.getVersion();
}
// lifecycle methods
// ----------------------------------------------------------------
-
- public synchronized void start() throws Exception
- {
- if (started)
- {
- return;
- }
-
+
+ private void doStart() throws Exception
+ {
asyncDeliveryPool = Executors.newCachedThreadPool(new org.jboss.messaging.utils.JBMThreadFactory("JBM-async-session-delivery-threads"));
executorFactory = new org.jboss.messaging.utils.OrderedExecutorFactory(asyncDeliveryPool);
@@ -225,6 +228,8 @@
// The rest of the components are not pluggable and created and started
// here
+
+ initialised = !configuration.isBackup();
securityStore = new SecurityStoreImpl(configuration.getSecurityInvalidationInterval(),
configuration.isSecurityEnabled());
@@ -271,11 +276,36 @@
List<QueueBindingInfo> queueBindingInfos = new ArrayList<QueueBindingInfo>();
storageManager.loadBindingJournal(queueBindingInfos);
+
+ //TODO - this logic could be simplified
+ if (uuid == null)
+ {
+ uuid = storageManager.getPersistentID();
+
+ if (uuid == null && !configuration.isBackup())
+ {
+ uuid = UUIDGenerator.getInstance().generateUUID();
+
+ storageManager.setPersistentID(uuid);
+ }
+
+ if (uuid != null)
+ {
+ nodeID = new SimpleString(uuid.toString());
+ }
+ }
+ else
+ {
+ UUID theUUID = storageManager.getPersistentID();
+
+ if (theUUID == null)
+ {
+ //Backup being initialised
+ storageManager.setPersistentID(uuid);
+ }
+
+ }
- uuid = storageManager.getPersistentID();
-
- nodeID = new SimpleString(uuid.toString());
-
serverManagement = managementService.registerServer(postOffice,
storageManager,
configuration,
@@ -284,8 +314,9 @@
resourceManager,
remotingService,
this,
- queueFactory);
-
+ queueFactory,
+ configuration.isBackup());
+
Map<Long, Queue> queues = new HashMap<Long, Queue>();
for (QueueBindingInfo queueBindingInfo : queueBindingInfos)
@@ -341,7 +372,7 @@
deployDiverts();
String backupConnectorName = configuration.getBackupConnectorName();
-
+
if (backupConnectorName != null)
{
TransportConfiguration backupConnector = configuration.getConnectorConfigurations().get(backupConnectorName);
@@ -369,20 +400,28 @@
backupConnectorParams = backupConnector.getParams();
}
}
+
+ Channel replicatingChannel = getReplicatingChannel();
+
+ if (replicatingChannel == null && backupConnectorFactory != null)
+ {
+ log.warn("Please start backup server before starting live server");
+
+ remotingService.stop();
+
+ return;
+ }
- remotingService.setMessagingServer(this);
-
if (configuration.isClustered())
{
clusterManager = new ClusterManagerImpl(executorFactory,
- storageManager,
+ this,
postOffice,
scheduledExecutor,
managementService,
- configuration,
- queueFactory,
+ configuration,
uuid,
- getReplicatingChannel(),
+ replicatingChannel,
configuration.isBackup());
clusterManager.start();
@@ -392,10 +431,31 @@
// during last stop
// This is the last thing done at the start, after everything else is up and running
pagingManager.startGlobalDepage();
-
+
started = true;
}
+ public synchronized void start() throws Exception
+ {
+ if (started)
+ {
+ return;
+ }
+
+ //Need to start remoting service otherwise live node will never be able to connect to backup
+ remotingService.setMessagingServer(this);
+
+ if (configuration.isBackup())
+ {
+ //We defer actually initialisation until the live node has contacted the backup
+ log.info("Backup server will await live server before becoming operational");
+ }
+ else
+ {
+ doStart();
+ }
+ }
+
public synchronized void stop() throws Exception
{
if (!started)
@@ -435,7 +495,7 @@
replicatingConnection = null;
replicatingChannel = null;
}
-
+
pagingManager.stop();
pagingManager = null;
securityStore = null;
@@ -583,7 +643,7 @@
configuration.setBackup(false);
remotingService.setBackup(false);
-
+
if (clusterManager != null)
{
clusterManager.activate();
@@ -743,7 +803,53 @@
{
return new HashSet<ServerSession>(sessions.values());
}
+
+ public boolean isInitialised()
+ {
+ synchronized (initialiseLock)
+ {
+ return initialised;
+ }
+ }
+ public void initialiseBackup(final UUID theUUID, final long currentMessageID) throws Exception
+ {
+ synchronized (initialiseLock)
+ {
+ if (initialised)
+ {
+ throw new IllegalStateException("Server is already initialised");
+ }
+
+ if (uuid != null && !uuid.toString().equals(theUUID.toString()))
+ {
+ throw new IllegalStateException("Backup node already has a unique id but it's not the same as the live node id");
+ }
+
+ if (theUUID == null)
+ {
+ throw new IllegalArgumentException("node id is null");
+ }
+
+ this.uuid = theUUID;
+
+ this.nodeID = new SimpleString(uuid.toString());
+
+ doStart();
+
+ if (currentMessageID != this.storageManager.getCurrentUniqueID())
+ {
+ throw new IllegalStateException("Backup node current unique id != live node current unique id " + this.storageManager.getCurrentUniqueID() +
+ ", " +
+ currentMessageID);
+ }
+
+ initialised = true;
+
+ log.info("Backup server is now operational");
+ }
+ }
+
public Channel getReplicatingChannel()
{
synchronized (replicatingChannelLock)
@@ -759,6 +865,11 @@
ClientSessionFactoryImpl.DEFAULT_CONNECTION_TTL,
scheduledExecutor,
listener);
+
+ if (replicatingConnection == null)
+ {
+ return null;
+ }
listener.conn = replicatingConnection;
@@ -775,6 +886,28 @@
});
replicatingConnection.startPinger();
+
+ // First time we get channel we send a message down it informing the backup of our node id -
+ // backup and live must have the same node id
+
+ Packet packet = new ReplicateStartupInfoMessage(uuid, storageManager.getCurrentUniqueID());
+
+ final Future future = new Future();
+
+ replicatingChannel.replicatePacket(packet, 1, new Runnable()
+ {
+ public void run()
+ {
+ future.run();
+ }
+ });
+
+ boolean ok = future.await(10000);
+
+ if (!ok)
+ {
+ throw new IllegalStateException("Timed out waiting for response from backup for initialisation");
+ }
}
}
@@ -805,12 +938,39 @@
{
return nodeID;
}
+
+ public Queue createQueue(final SimpleString address, final SimpleString queueName, final SimpleString filterString, final boolean durable, final boolean temporary) throws Exception
+ {
+ Binding binding = postOffice.getBinding(queueName);
- public UUID getUUID()
- {
- return uuid;
+ if (binding != null)
+ {
+ throw new MessagingException(MessagingException.QUEUE_EXISTS);
+ }
+
+ Filter filter = null;
+
+ if (filterString != null)
+ {
+ filter = new FilterImpl(filterString);
+ }
+
+ final Queue queue = queueFactory.createQueue(-1, address, queueName, filter, durable, temporary);
+
+ // The unique name is given by the concatenation of the node id and the queue name - this is because it must be
+ // unique *across the entire cluster*
+ binding = new LocalQueueBinding(address, queue, nodeID);
+
+ if (durable)
+ {
+ storageManager.addQueueBinding(binding);
+ }
+
+ postOffice.addBinding(binding);
+
+ return queue;
}
-
+
// Public
// ---------------------------------------------------------------------------------------
Modified: trunk/src/main/org/jboss/messaging/core/server/impl/MessagingServerPacketHandler.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/impl/MessagingServerPacketHandler.java 2009-03-23 19:56:44 UTC (rev 6145)
+++ trunk/src/main/org/jboss/messaging/core/server/impl/MessagingServerPacketHandler.java 2009-03-24 10:20:42 UTC (rev 6146)
@@ -12,13 +12,17 @@
package org.jboss.messaging.core.server.impl;
+import static org.jboss.messaging.core.management.NotificationType.CONSUMER_CLOSED;
+import static org.jboss.messaging.core.management.NotificationType.CONSUMER_CREATED;
import static org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl.CREATESESSION;
import static org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl.CREATE_QUEUE;
import static org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl.REATTACH_SESSION;
import static org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl.REPLICATE_CREATESESSION;
+import static org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl.REPLICATE_STARTUP_INFO;
import org.jboss.messaging.core.exception.MessagingException;
import org.jboss.messaging.core.logging.Logger;
+import org.jboss.messaging.core.management.Notification;
import org.jboss.messaging.core.postoffice.Binding;
import org.jboss.messaging.core.remoting.Channel;
import org.jboss.messaging.core.remoting.ChannelHandler;
@@ -35,6 +39,7 @@
import org.jboss.messaging.core.remoting.impl.wireformat.replication.ReplicateRemoteBindingRemovedMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.replication.ReplicateRemoteConsumerAddedMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.replication.ReplicateRemoteConsumerRemovedMessage;
+import org.jboss.messaging.core.remoting.impl.wireformat.replication.ReplicateStartupInfoMessage;
import org.jboss.messaging.core.server.MessageReference;
import org.jboss.messaging.core.server.MessagingServer;
import org.jboss.messaging.core.server.Queue;
@@ -57,7 +62,7 @@
private final Channel channel1;
private final RemotingConnection connection;
-
+
public MessagingServerPacketHandler(final MessagingServer server,
final Channel channel1,
final RemotingConnection connection)
@@ -72,11 +77,31 @@
public void handlePacket(final Packet packet)
{
byte type = packet.getType();
+
+ if (!server.isInitialised() && type != PacketImpl.REPLICATE_STARTUP_INFO)
+ {
+ throw new IllegalStateException("First packet must be startup info for backup " + type);
+ }
// All these operations need to be idempotent since they are outside of the session
// reliability replay functionality
switch (type)
{
+ case REPLICATE_STARTUP_INFO:
+ {
+ ReplicateStartupInfoMessage msg = (ReplicateStartupInfoMessage)packet;
+
+ try
+ {
+ server.initialiseBackup(msg.getNodeID(), msg.getCurrentMessageID());
+ }
+ catch (Exception e)
+ {
+ log.error("Failed to initialise", e);
+ }
+
+ break;
+ }
case CREATESESSION:
{
CreateSessionMessage request = (CreateSessionMessage)packet;
@@ -282,11 +307,11 @@
{
try
{
- server.getServerManagement().createQueue(request.getAddress().toString(), request.getQueueName().toString());
+ server.createQueue(request.getAddress(), request.getQueueName(), request.getFilterString(), request.isDurable(), request.isTemporary());
}
catch (Exception e)
{
- log.error("Failed to handle cluster connection update", e);
+ log.error("Failed to handle create queue", e);
}
}
@@ -350,6 +375,18 @@
{
log.error("Failed to handle add remote consumer", e);
}
+
+ // Need to propagate the consumer add
+ Notification notification = new Notification(CONSUMER_CREATED, request.getProperties());
+
+ try
+ {
+ server.getManagementService().sendNotification(notification);
+ }
+ catch (Exception e)
+ {
+ log.error("Failed to handle add remote consumer", e);
+ }
}
private void handleRemoveRemoteConsumer(final ReplicateRemoteConsumerRemovedMessage request)
@@ -370,6 +407,18 @@
{
log.error("Failed to handle remove remote consumer", e);
}
+
+ // Need to propagate the consumer close
+ Notification notification = new Notification(CONSUMER_CLOSED, request.getProperties());
+
+ try
+ {
+ server.getManagementService().sendNotification(notification);
+ }
+ catch (Exception e)
+ {
+ log.error("Failed to handle remove remote consumer", e);
+ }
}
private void handleReplicateAcknowledge(final ReplicateAcknowledgeMessage request)
Modified: trunk/src/main/org/jboss/messaging/core/server/impl/QueueImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/impl/QueueImpl.java 2009-03-23 19:56:44 UTC (rev 6145)
+++ trunk/src/main/org/jboss/messaging/core/server/impl/QueueImpl.java 2009-03-24 10:20:42 UTC (rev 6146)
@@ -358,7 +358,7 @@
}
public void addLast(final MessageReference ref)
- {
+ {
add(ref, false);
}
Modified: trunk/src/main/org/jboss/messaging/core/server/impl/ServerConsumerImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/impl/ServerConsumerImpl.java 2009-03-23 19:56:44 UTC (rev 6145)
+++ trunk/src/main/org/jboss/messaging/core/server/impl/ServerConsumerImpl.java 2009-03-24 10:20:42 UTC (rev 6146)
@@ -211,15 +211,13 @@
}
public void close() throws Exception
- {
+ {
setStarted(false);
messageQueue.removeConsumer(this);
session.removeConsumer(this);
- // log.info(System.identityHashCode(this) + " consumer close");
-
LinkedList<MessageReference> refs = cancelRefs(false, null);
Iterator<MessageReference> iter = refs.iterator();
@@ -410,7 +408,7 @@
}
public void deliverReplicated(final long messageID) throws Exception
- {
+ {
MessageReference ref = removeFirstReference(messageID);
if (ref == null)
@@ -471,7 +469,7 @@
// force a depage
if (!store.readPage()) // This returns false if there are no pages
{
- throw new IllegalStateException("Cannot find page");
+ throw new IllegalStateException("Cannot find page " + id);
}
else
{
@@ -689,21 +687,10 @@
Packet replPacket = new SessionReplicateDeliveryMessage(id, message.getMessageID());
replPacket.setChannelID(channel.getID());
- // log.info("replicating delivery from live for queue " + messageQueue.getName() +
- // " ref " +
- // message.getMessageID() +
- // " session name " +
- // session.getName());
-
replicatingChannel.replicatePacket(replPacket, replicatedSessionID, new Runnable()
{
public void run()
{
- // log.info("got replicate delivery response " + messageQueue.getName() +
- // " ref " +
- // message.getMessageID() +
- // " session name " +
- // session.getName());
channel.send(packet);
}
});
Modified: trunk/src/main/org/jboss/messaging/core/server/impl/ServerSessionImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/impl/ServerSessionImpl.java 2009-03-23 19:56:44 UTC (rev 6145)
+++ trunk/src/main/org/jboss/messaging/core/server/impl/ServerSessionImpl.java 2009-03-24 10:20:42 UTC (rev 6146)
@@ -11,6 +11,20 @@
package org.jboss.messaging.core.server.impl;
+import static org.jboss.messaging.core.management.NotificationType.CONSUMER_CREATED;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.Executor;
+
+import javax.transaction.xa.XAException;
+import javax.transaction.xa.XAResource;
+import javax.transaction.xa.Xid;
+
import org.jboss.messaging.core.buffers.ChannelBuffers;
import org.jboss.messaging.core.client.impl.ClientMessageImpl;
import org.jboss.messaging.core.client.management.impl.ManagementHelper;
@@ -20,7 +34,6 @@
import org.jboss.messaging.core.logging.Logger;
import org.jboss.messaging.core.management.ManagementService;
import org.jboss.messaging.core.management.Notification;
-import static org.jboss.messaging.core.management.NotificationType.CONSUMER_CREATED;
import org.jboss.messaging.core.persistence.StorageManager;
import org.jboss.messaging.core.postoffice.Binding;
import org.jboss.messaging.core.postoffice.BindingType;
@@ -83,17 +96,6 @@
import org.jboss.messaging.utils.SimpleString;
import org.jboss.messaging.utils.TypedProperties;
-import javax.transaction.xa.XAException;
-import javax.transaction.xa.XAResource;
-import javax.transaction.xa.Xid;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.Executor;
-
/*
* Session implementation
*
@@ -314,7 +316,7 @@
throw new IllegalStateException("Cannot find consumer with id " + consumer.getID() + " to remove");
}
}
-
+
public void close() throws Exception
{
if (tx != null && tx.getXid() == null)
@@ -868,7 +870,7 @@
public void handleCloseConsumer(final SessionConsumerCloseMessage packet)
{
final ServerConsumer consumer = consumers.get(packet.getConsumerID());
-
+
if (replicatingChannel == null)
{
doHandleCloseConsumer(packet, consumer);
@@ -913,14 +915,6 @@
public void handleSendLargeMessage(final SessionSendMessage packet)
{
- if (packet.getMessageID() <= 0L)
- {
- // must generate message id here, so we know they are in sync on live and backup
- long id = storageManager.generateUniqueID();
-
- packet.setMessageID(id);
- }
-
// need to create the LargeMessage before continue
final LargeServerMessage msg = doCreateLargeMessage(packet);
@@ -961,29 +955,17 @@
}
currentLargeMessage = msg;
+
doSendLargeMessage(packet);
}
});
-
}
-
}
public void handleSend(final SessionSendMessage packet)
{
- // With a send we must make sure it is replicated to backup before being processed on live
- // or can end up with delivery being processed on backup before original send
-
- if (packet.getMessageID() <= 0L)
- {
- // must generate message id here, so we know they are in sync on live and backup
- long id = storageManager.generateUniqueID();
-
- packet.setMessageID(id);
- }
-
if (replicatingChannel == null)
- {
+ {
doSend(packet);
}
else
@@ -995,7 +977,6 @@
doSend(packet);
}
});
-
}
}
@@ -1020,7 +1001,7 @@
public void handleReplicatedDelivery(final SessionReplicateDeliveryMessage packet)
{
ServerConsumer consumer = consumers.get(packet.getConsumerID());
-
+
if (consumer == null)
{
throw new IllegalStateException("Cannot handle replicated delivery, consumer is closed " + packet.getConsumerID() +
@@ -1066,7 +1047,7 @@
backup = false;
}
-
+
remotingConnection.removeFailureListener(this);
channel.transferConnection(newConnection, this.id, replicatingChannel);
@@ -1137,7 +1118,7 @@
{
return tx;
}
-
+
// Private
// ----------------------------------------------------------------------------
@@ -1167,7 +1148,7 @@
channel.confirm(packet);
- channel.send(response);
+ channel.send(response);
}
private void doHandleCreateConsumer(final SessionCreateConsumerMessage packet)
@@ -1290,7 +1271,7 @@
{
SimpleString address = packet.getAddress();
- SimpleString name = packet.getQueueName();
+ final SimpleString name = packet.getQueueName();
SimpleString filterString = packet.getFilterString();
@@ -1311,33 +1292,8 @@
{
securityStore.check(address, CheckType.CREATE_NON_DURABLE_QUEUE, this);
}
- Binding binding = postOffice.getBinding(name);
+ server.createQueue(address, name, filterString, durable, temporary);
- if (binding != null)
- {
- throw new MessagingException(MessagingException.QUEUE_EXISTS);
- }
-
- Filter filter = null;
-
- if (filterString != null)
- {
- filter = new FilterImpl(filterString);
- }
-
- final Queue queue = queueFactory.createQueue(-1, address, name, filter, durable, temporary);
-
- // The unique name is given by the concatenation of the node id and the queue name - this is because it must be
- // unique *across the entire cluster*
- binding = new LocalQueueBinding(address, queue, nodeID);
-
- if (durable)
- {
- storageManager.addQueueBinding(binding);
- }
-
- postOffice.addBinding(binding);
-
if (temporary)
{
// Temporary queue in core simply means the queue will be deleted if
@@ -1352,11 +1308,11 @@
{
try
{
- postOffice.removeBinding(queue.getName());
+ postOffice.removeBinding(name);
}
catch (Exception e)
{
- log.error("Failed to remove temporary queue " + queue.getName());
+ log.error("Failed to remove temporary queue " + name);
}
}
});
@@ -1391,6 +1347,8 @@
try
{
+ //server.deleteQueue(name);
+
Binding binding = postOffice.removeBinding(name);
if (binding == null || binding.getType() != BindingType.LOCAL_QUEUE)
@@ -1404,6 +1362,7 @@
{
throw new MessagingException(MessagingException.ILLEGAL_STATE, "Cannot delete queue - it has consumers");
}
+
if (queue.isDurable())
{
// make sure the user has privileges to delete this queue
@@ -1413,18 +1372,19 @@
{
securityStore.check(binding.getAddress(), CheckType.DELETE_NON_DURABLE_QUEUE, this);
}
+
queue.deleteAllReferences();
if (queue.isDurable())
{
storageManager.deleteQueueBinding(queue.getPersistenceID());
- }
+ }
response = new NullResponseMessage();
}
catch (Exception e)
{
- log.error("Failed to delete consumer", e);
+ log.error("Failed to delete queue", e);
if (e instanceof MessagingException)
{
@@ -2200,6 +2160,7 @@
channel.confirm(packet);
+ //We flush the confirmations to make sure any send confirmations get handled on the client side
channel.flushConfirmations();
channel.send(response);
@@ -2278,6 +2239,10 @@
{
response = new NullResponseMessage();
}
+
+ long id = storageManager.generateUniqueID();
+
+ currentLargeMessage.setMessageID(id);
}
catch (Exception e)
{
@@ -2311,6 +2276,10 @@
try
{
ServerMessage message = packet.getServerMessage();
+
+ long id = storageManager.generateUniqueID();
+
+ message.setMessageID(id);
if (message.getDestination().equals(managementAddress))
{
@@ -2362,7 +2331,6 @@
try
{
-
if (currentLargeMessage == null)
{
throw new MessagingException(MessagingException.ILLEGAL_STATE, "large-message not initialized on server");
@@ -2377,7 +2345,7 @@
currentLargeMessage = null;
message.complete();
-
+
send(message);
}
Modified: trunk/src/main/org/jboss/messaging/integration/transports/netty/MessagingChannelHandler.java
===================================================================
--- trunk/src/main/org/jboss/messaging/integration/transports/netty/MessagingChannelHandler.java 2009-03-23 19:56:44 UTC (rev 6145)
+++ trunk/src/main/org/jboss/messaging/integration/transports/netty/MessagingChannelHandler.java 2009-03-24 10:20:42 UTC (rev 6146)
@@ -24,6 +24,7 @@
import org.jboss.messaging.core.exception.MessagingException;
import org.jboss.messaging.core.logging.Logger;
+import org.jboss.messaging.core.remoting.Packet;
import org.jboss.messaging.core.remoting.spi.BufferHandler;
import org.jboss.messaging.core.remoting.spi.ConnectionLifeCycleListener;
import org.jboss.netty.buffer.ChannelBuffer;
@@ -70,6 +71,7 @@
public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception
{
ChannelBuffer buffer = (ChannelBuffer)e.getMessage();
+
handler.bufferReceived(e.getChannel().getId(), new ChannelBufferWrapper(buffer));
}
@@ -102,7 +104,7 @@
{
return;
}
-
+
MessagingException me = new MessagingException(MessagingException.INTERNAL_ERROR, "Netty exception");
me.initCause(e.getCause());
try
Modified: trunk/src/main/org/jboss/messaging/integration/transports/netty/NettyAcceptor.java
===================================================================
--- trunk/src/main/org/jboss/messaging/integration/transports/netty/NettyAcceptor.java 2009-03-23 19:56:44 UTC (rev 6145)
+++ trunk/src/main/org/jboss/messaging/integration/transports/netty/NettyAcceptor.java 2009-03-24 10:20:42 UTC (rev 6146)
@@ -298,8 +298,7 @@
SocketAddress address;
if (useInvm)
{
- address = new LocalAddress(h);
- System.out.println("address = " + address);
+ address = new LocalAddress(h);
}
else
{
Modified: trunk/src/main/org/jboss/messaging/integration/transports/netty/NettyConnection.java
===================================================================
--- trunk/src/main/org/jboss/messaging/integration/transports/netty/NettyConnection.java 2009-03-23 19:56:44 UTC (rev 6145)
+++ trunk/src/main/org/jboss/messaging/integration/transports/netty/NettyConnection.java 2009-03-24 10:20:42 UTC (rev 6146)
@@ -130,8 +130,6 @@
public String getRemoteAddress()
{
- log.info("channel is " + channel);
- log.info("channel remote address " + channel.getRemoteAddress());
return channel.getRemoteAddress().toString();
}
Modified: trunk/src/main/org/jboss/messaging/integration/transports/netty/NettyConnector.java
===================================================================
--- trunk/src/main/org/jboss/messaging/integration/transports/netty/NettyConnector.java 2009-03-23 19:56:44 UTC (rev 6145)
+++ trunk/src/main/org/jboss/messaging/integration/transports/netty/NettyConnector.java 2009-03-24 10:20:42 UTC (rev 6146)
@@ -21,6 +21,25 @@
*/
package org.jboss.messaging.integration.transports.netty;
+import static org.jboss.netty.channel.Channels.pipeline;
+import static org.jboss.netty.channel.Channels.write;
+
+import java.net.InetSocketAddress;
+import java.net.SocketAddress;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.Map;
+import java.util.Set;
+import java.util.Timer;
+import java.util.TimerTask;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.SSLException;
+
import org.jboss.messaging.core.exception.MessagingException;
import org.jboss.messaging.core.logging.Logger;
import org.jboss.messaging.core.remoting.impl.ssl.SSLSupport;
@@ -40,8 +59,6 @@
import org.jboss.netty.channel.ChannelPipelineCoverage;
import org.jboss.netty.channel.ChannelPipelineFactory;
import org.jboss.netty.channel.ChannelStateEvent;
-import static org.jboss.netty.channel.Channels.pipeline;
-import static org.jboss.netty.channel.Channels.write;
import org.jboss.netty.channel.MessageEvent;
import org.jboss.netty.channel.SimpleChannelHandler;
import org.jboss.netty.channel.UpstreamMessageEvent;
@@ -65,21 +82,6 @@
import org.jboss.netty.handler.codec.http.HttpVersion;
import org.jboss.netty.handler.ssl.SslHandler;
-import javax.net.ssl.SSLContext;
-import javax.net.ssl.SSLException;
-import java.net.InetSocketAddress;
-import java.net.SocketAddress;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.Map;
-import java.util.Set;
-import java.util.Timer;
-import java.util.TimerTask;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-
/**
* A NettyConnector
*
@@ -328,6 +330,7 @@
}
connections.clear();
+
}
public boolean isStarted()
@@ -589,7 +592,7 @@
{
listener.connectionException(connectionID, me);
}
- }.start();
+ }.start();
}
}
Modified: trunk/src/main/org/jboss/messaging/jms/client/JBossConnectionFactory.java
===================================================================
--- trunk/src/main/org/jboss/messaging/jms/client/JBossConnectionFactory.java 2009-03-23 19:56:44 UTC (rev 6145)
+++ trunk/src/main/org/jboss/messaging/jms/client/JBossConnectionFactory.java 2009-03-24 10:20:42 UTC (rev 6146)
@@ -83,7 +83,7 @@
private final int transactionBatchSize;
private final long pingPeriod;
-
+
private final long connectionTTL;
private final long callTimeout;
@@ -109,15 +109,15 @@
private final int maxConnections;
private final boolean preAcknowledge;
-
+
private final long retryInterval;
private final double retryIntervalMultiplier; // For exponential backoff
-
- private final int maxRetriesBeforeFailover;
-
- private final int maxRetriesAfterFailover;
+ private final int initialConnectAttempts;
+
+ private final int reconnectAttempts;
+
// Constructors ---------------------------------------------------------------------------------
public JBossConnectionFactory(final String discoveryGroupAddress,
@@ -143,9 +143,9 @@
final int maxConnections,
final boolean preAcknowledge,
final long retryInterval,
- final double retryIntervalMultiplier,
- final int maxRetriesBeforeFailover,
- final int maxRetriesAfterFailover)
+ final double retryIntervalMultiplier,
+ final int initialConnectAttempts,
+ final int reconnectAttempts)
{
this.connectorConfigs = null;
this.discoveryGroupAddress = discoveryGroupAddress;
@@ -171,9 +171,9 @@
this.maxConnections = maxConnections;
this.preAcknowledge = preAcknowledge;
this.retryInterval = retryInterval;
- this.retryIntervalMultiplier = retryIntervalMultiplier;
- this.maxRetriesBeforeFailover = maxRetriesBeforeFailover;
- this.maxRetriesAfterFailover = maxRetriesAfterFailover;
+ this.retryIntervalMultiplier = retryIntervalMultiplier;
+ this.initialConnectAttempts = initialConnectAttempts;
+ this.reconnectAttempts = reconnectAttempts;
}
public JBossConnectionFactory(final String discoveryGroupAddress,
@@ -203,11 +203,11 @@
this.blockOnPersistentSend = ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_PERSISTENT_SEND;
this.autoGroup = ClientSessionFactoryImpl.DEFAULT_AUTO_GROUP;
this.maxConnections = ClientSessionFactoryImpl.DEFAULT_MAX_CONNECTIONS;
- this.preAcknowledge = ClientSessionFactoryImpl.DEFAULT_PRE_ACKNOWLEDGE;
+ this.preAcknowledge = ClientSessionFactoryImpl.DEFAULT_PRE_ACKNOWLEDGE;
this.retryInterval = ClientSessionFactoryImpl.DEFAULT_RETRY_INTERVAL;
- this.retryIntervalMultiplier = ClientSessionFactoryImpl.DEFAULT_RETRY_INTERVAL_MULTIPLIER;
- this.maxRetriesBeforeFailover = ClientSessionFactoryImpl.DEFAULT_MAX_RETRIES_BEFORE_FAILOVER;
- this.maxRetriesAfterFailover = ClientSessionFactoryImpl.DEFAULT_MAX_RETRIES_AFTER_FAILOVER;
+ this.retryIntervalMultiplier = ClientSessionFactoryImpl.DEFAULT_RETRY_INTERVAL_MULTIPLIER;
+ this.initialConnectAttempts = ClientSessionFactoryImpl.DEFAULT_INITIAL_CONNECT_ATTEMPTS;
+ this.reconnectAttempts = ClientSessionFactoryImpl.DEFAULT_RECONNECT_ATTEMPTS;
}
public JBossConnectionFactory(final String discoveryGroupName, final int discoveryGroupPort)
@@ -217,7 +217,7 @@
ConfigurationImpl.DEFAULT_BROADCAST_REFRESH_TIMEOUT,
ClientSessionFactoryImpl.DEFAULT_DISCOVERY_INITIAL_WAIT);
}
-
+
public JBossConnectionFactory(final List<Pair<TransportConfiguration, TransportConfiguration>> connectorConfigs,
final String loadBalancingPolicyClassName,
final long pingPeriod,
@@ -238,9 +238,9 @@
final int maxConnections,
final boolean preAcknowledge,
final long retryInterval,
- final double retryIntervalMultiplier,
- final int maxRetriesBeforeFailover,
- final int maxRetriesAfterFailover)
+ final double retryIntervalMultiplier,
+ final int initialConnectAttempts,
+ final int reconnectAttempts)
{
this.discoveryGroupAddress = null;
this.discoveryGroupPort = -1;
@@ -266,11 +266,11 @@
this.maxConnections = maxConnections;
this.preAcknowledge = preAcknowledge;
this.retryInterval = retryInterval;
- this.retryIntervalMultiplier = retryIntervalMultiplier;
- this.maxRetriesBeforeFailover = maxRetriesBeforeFailover;
- this.maxRetriesAfterFailover = maxRetriesAfterFailover;
+ this.retryIntervalMultiplier = retryIntervalMultiplier;
+ this.initialConnectAttempts = initialConnectAttempts;
+ this.reconnectAttempts = reconnectAttempts;
}
-
+
public JBossConnectionFactory(final TransportConfiguration transportConfig,
final TransportConfiguration backupConfig,
final String loadBalancingPolicyClassName,
@@ -290,11 +290,11 @@
final boolean blockOnPersistentSend,
final boolean autoGroup,
final int maxConnections,
- final boolean preAcknowledge,
+ final boolean preAcknowledge,
final long retryInterval,
- final double retryIntervalMultiplier,
- final int maxRetriesBeforeFailover,
- final int maxRetriesAfterFailover)
+ final double retryIntervalMultiplier,
+ final int initialConnectAttempts,
+ final int reconnectAttempts)
{
this.discoveryGroupAddress = null;
this.discoveryGroupPort = -1;
@@ -322,12 +322,11 @@
this.maxConnections = maxConnections;
this.preAcknowledge = preAcknowledge;
this.retryInterval = retryInterval;
- this.retryIntervalMultiplier = retryIntervalMultiplier;
- this.maxRetriesBeforeFailover = maxRetriesBeforeFailover;
- this.maxRetriesAfterFailover = maxRetriesAfterFailover;
+ this.retryIntervalMultiplier = retryIntervalMultiplier;
+ this.initialConnectAttempts = initialConnectAttempts;
+ this.reconnectAttempts = reconnectAttempts;
}
-
public JBossConnectionFactory(final List<Pair<TransportConfiguration, TransportConfiguration>> connectorConfigs)
{
this.discoveryGroupAddress = null;
@@ -354,12 +353,12 @@
this.maxConnections = ClientSessionFactoryImpl.DEFAULT_MAX_CONNECTIONS;
this.preAcknowledge = ClientSessionFactoryImpl.DEFAULT_PRE_ACKNOWLEDGE;
this.retryInterval = ClientSessionFactoryImpl.DEFAULT_RETRY_INTERVAL;
- this.retryIntervalMultiplier = ClientSessionFactoryImpl.DEFAULT_RETRY_INTERVAL_MULTIPLIER;
- this.maxRetriesBeforeFailover = ClientSessionFactoryImpl.DEFAULT_MAX_RETRIES_BEFORE_FAILOVER;
- this.maxRetriesAfterFailover = ClientSessionFactoryImpl.DEFAULT_MAX_RETRIES_AFTER_FAILOVER;
+ this.retryIntervalMultiplier = ClientSessionFactoryImpl.DEFAULT_RETRY_INTERVAL_MULTIPLIER;
+ this.initialConnectAttempts = ClientSessionFactoryImpl.DEFAULT_INITIAL_CONNECT_ATTEMPTS;
+ this.reconnectAttempts = ClientSessionFactoryImpl.DEFAULT_RECONNECT_ATTEMPTS;
}
+
-
public JBossConnectionFactory(final List<Pair<TransportConfiguration, TransportConfiguration>> connectorConfigs,
final boolean blockOnAcknowledge,
final boolean blockOnNonPersistentSend,
@@ -391,8 +390,8 @@
this.preAcknowledge = preAcknowledge;
this.retryInterval = ClientSessionFactoryImpl.DEFAULT_RETRY_INTERVAL;
this.retryIntervalMultiplier = ClientSessionFactoryImpl.DEFAULT_RETRY_INTERVAL_MULTIPLIER;
- this.maxRetriesBeforeFailover = ClientSessionFactoryImpl.DEFAULT_MAX_RETRIES_BEFORE_FAILOVER;
- this.maxRetriesAfterFailover = ClientSessionFactoryImpl.DEFAULT_MAX_RETRIES_AFTER_FAILOVER;
+ this.initialConnectAttempts = ClientSessionFactoryImpl.DEFAULT_INITIAL_CONNECT_ATTEMPTS;
+ this.reconnectAttempts = ClientSessionFactoryImpl.DEFAULT_RECONNECT_ATTEMPTS;
}
public JBossConnectionFactory(final TransportConfiguration connectorConfig)
@@ -425,9 +424,9 @@
this.maxConnections = ClientSessionFactoryImpl.DEFAULT_MAX_CONNECTIONS;
this.preAcknowledge = ClientSessionFactoryImpl.DEFAULT_PRE_ACKNOWLEDGE;
this.retryInterval = ClientSessionFactoryImpl.DEFAULT_RETRY_INTERVAL;
- this.retryIntervalMultiplier = ClientSessionFactoryImpl.DEFAULT_RETRY_INTERVAL_MULTIPLIER;
- this.maxRetriesBeforeFailover = ClientSessionFactoryImpl.DEFAULT_MAX_RETRIES_BEFORE_FAILOVER;
- this.maxRetriesAfterFailover = ClientSessionFactoryImpl.DEFAULT_MAX_RETRIES_AFTER_FAILOVER;
+ this.retryIntervalMultiplier = ClientSessionFactoryImpl.DEFAULT_RETRY_INTERVAL_MULTIPLIER;
+ this.initialConnectAttempts = ClientSessionFactoryImpl.DEFAULT_INITIAL_CONNECT_ATTEMPTS;
+ this.reconnectAttempts = ClientSessionFactoryImpl.DEFAULT_RECONNECT_ATTEMPTS;
}
// ConnectionFactory implementation -------------------------------------------------------------
@@ -574,14 +573,14 @@
return maxConnections;
}
- public int getMaxRetriesBeforeFailover()
+ public int getInitialConnectAttempts()
{
- return maxRetriesBeforeFailover;
+ return initialConnectAttempts;
}
- public int getMaxRetriesAfterFailover()
+ public int getReconnectAttempts()
{
- return maxRetriesAfterFailover;
+ return reconnectAttempts;
}
public boolean isBlockOnAcknowledge()
@@ -674,8 +673,8 @@
dupsOKBatchSize,
retryInterval,
retryIntervalMultiplier,
- maxRetriesBeforeFailover,
- maxRetriesAfterFailover);
+ initialConnectAttempts,
+ reconnectAttempts);
}
else
{
@@ -701,8 +700,8 @@
dupsOKBatchSize,
retryInterval,
retryIntervalMultiplier,
- maxRetriesBeforeFailover,
- maxRetriesAfterFailover);
+ initialConnectAttempts,
+ reconnectAttempts);
}
}
Modified: trunk/src/main/org/jboss/messaging/jms/server/JMSServerManager.java
===================================================================
--- trunk/src/main/org/jboss/messaging/jms/server/JMSServerManager.java 2009-03-23 19:56:44 UTC (rev 6145)
+++ trunk/src/main/org/jboss/messaging/jms/server/JMSServerManager.java 2009-03-24 10:20:42 UTC (rev 6146)
@@ -141,8 +141,8 @@
boolean preAcknowledge,
final long retryInterval,
final double retryIntervalMultiplier,
- final int maxRetriesBeforeFailover,
- final int maxRetriesAfterFailover,
+ final int initialConnectAttempts,
+ final int reconnectAttempts,
List<String> jndiBindings) throws Exception;
boolean createConnectionFactory(String name,
@@ -168,8 +168,8 @@
boolean preAcknowledge,
final long retryInterval,
final double retryIntervalMultiplier,
- final int maxRetriesBeforeFailover,
- final int maxRetriesAfterFailover,
+ final int initialConnectAttempts,
+ final int reconnectAttempts,
List<String> jndiBindings) throws Exception;
/**
Modified: trunk/src/main/org/jboss/messaging/jms/server/impl/JMSServerDeployer.java
===================================================================
--- trunk/src/main/org/jboss/messaging/jms/server/impl/JMSServerDeployer.java 2009-03-23 19:56:44 UTC (rev 6145)
+++ trunk/src/main/org/jboss/messaging/jms/server/impl/JMSServerDeployer.java 2009-03-24 10:20:42 UTC (rev 6146)
@@ -79,9 +79,9 @@
private static final String RETRY_INTERVAL_MULTIPLIER = "retry-interval-multiplier";
- private static final String MAX_RETRIES_BEFORE_FAILOVER = "max-retries-before-failover";
+ private static final String INITIAL_CONNECT_ATTEMPTS = "initial-connect-attempts";
- private static final String MAX_RETRIES_AFTER_FAILOVER = "max-retries-after-failover";
+ private static final String RECONNECT_ATTEMPTS = "reconnect-attempts";
private static final String CONNECTOR_LINK_ELEMENT = "connector-ref";
@@ -171,8 +171,8 @@
boolean preAcknowledge = ClientSessionFactoryImpl.DEFAULT_PRE_ACKNOWLEDGE;
long retryInterval = ClientSessionFactoryImpl.DEFAULT_RETRY_INTERVAL;
double retryIntervalMultiplier = ClientSessionFactoryImpl.DEFAULT_RETRY_INTERVAL_MULTIPLIER;
- int maxRetriesBeforeFailover = ClientSessionFactoryImpl.DEFAULT_MAX_RETRIES_BEFORE_FAILOVER;
- int maxRetriesAfterFailover = ClientSessionFactoryImpl.DEFAULT_MAX_RETRIES_AFTER_FAILOVER;
+ int initialConnectAttempts = ClientSessionFactoryImpl.DEFAULT_INITIAL_CONNECT_ATTEMPTS;
+ int reconnectAttempts = ClientSessionFactoryImpl.DEFAULT_RECONNECT_ATTEMPTS;
List<String> jndiBindings = new ArrayList<String>();
List<Pair<TransportConfiguration, TransportConfiguration>> connectorConfigs = new ArrayList<Pair<TransportConfiguration, TransportConfiguration>>();
@@ -264,13 +264,13 @@
{
retryIntervalMultiplier = org.jboss.messaging.utils.XMLUtil.parseDouble(child);
}
- else if (MAX_RETRIES_BEFORE_FAILOVER.equals(child.getNodeName()))
+ else if (INITIAL_CONNECT_ATTEMPTS.equals(child.getNodeName()))
{
- maxRetriesBeforeFailover = org.jboss.messaging.utils.XMLUtil.parseInt(child);;
+ initialConnectAttempts = org.jboss.messaging.utils.XMLUtil.parseInt(child);;
}
- else if (MAX_RETRIES_AFTER_FAILOVER.equals(child.getNodeName()))
+ else if (RECONNECT_ATTEMPTS.equals(child.getNodeName()))
{
- maxRetriesAfterFailover = org.jboss.messaging.utils.XMLUtil.parseInt(child);;
+ reconnectAttempts = org.jboss.messaging.utils.XMLUtil.parseInt(child);;
}
else if (ENTRY_NODE_NAME.equals(child.getNodeName()))
{
@@ -361,8 +361,8 @@
preAcknowledge,
retryInterval,
retryIntervalMultiplier,
- maxRetriesBeforeFailover,
- maxRetriesAfterFailover,
+ initialConnectAttempts,
+ reconnectAttempts,
jndiBindings);
}
else
@@ -389,8 +389,8 @@
preAcknowledge,
retryInterval,
retryIntervalMultiplier,
- maxRetriesBeforeFailover,
- maxRetriesAfterFailover,
+ initialConnectAttempts,
+ reconnectAttempts,
jndiBindings);
}
}
Modified: trunk/src/main/org/jboss/messaging/jms/server/impl/JMSServerManagerImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/jms/server/impl/JMSServerManagerImpl.java 2009-03-23 19:56:44 UTC (rev 6145)
+++ trunk/src/main/org/jboss/messaging/jms/server/impl/JMSServerManagerImpl.java 2009-03-24 10:20:42 UTC (rev 6146)
@@ -89,6 +89,8 @@
public static JMSServerManagerImpl newJMSServerManagerImpl(final MessagingServer server) throws Exception
{
+ log.info("Creating new msc with po " + server.getPostOffice());
+
MessagingServerControlMBean control = new MessagingServerControl(server.getPostOffice(),
server.getStorageManager(),
server.getConfiguration(),
@@ -236,8 +238,8 @@
final boolean preAcknowledge,
final long retryInterval,
final double retryIntervalMultiplier,
- final int maxRetriesBeforeFailover,
- final int maxRetriesAfterFailover,
+ final int initialConnectAttempts,
+ final int reconnectAttempts,
final List<String> jndiBindings) throws Exception
{
JBossConnectionFactory cf = connectionFactories.get(name);
@@ -264,8 +266,8 @@
preAcknowledge,
retryInterval,
retryIntervalMultiplier,
- maxRetriesBeforeFailover,
- maxRetriesAfterFailover);
+ initialConnectAttempts,
+ reconnectAttempts);
}
bindConnectionFactory(cf, name, jndiBindings);
@@ -330,8 +332,8 @@
final boolean preAcknowledge,
final long retryInterval,
final double retryIntervalMultiplier,
- final int maxRetriesBeforeFailover,
- final int maxRetriesAfterFailover,
+ final int initialConnectAttempts,
+ final int reconnectAttempts,
final List<String> jndiBindings) throws Exception
{
JBossConnectionFactory cf = connectionFactories.get(name);
@@ -361,8 +363,8 @@
preAcknowledge,
retryInterval,
retryIntervalMultiplier,
- maxRetriesBeforeFailover,
- maxRetriesAfterFailover);
+ initialConnectAttempts,
+ reconnectAttempts);
}
bindConnectionFactory(cf, name, jndiBindings);
Modified: trunk/src/main/org/jboss/messaging/jms/server/management/ConnectionFactoryControlMBean.java
===================================================================
--- trunk/src/main/org/jboss/messaging/jms/server/management/ConnectionFactoryControlMBean.java 2009-03-23 19:56:44 UTC (rev 6145)
+++ trunk/src/main/org/jboss/messaging/jms/server/management/ConnectionFactoryControlMBean.java 2009-03-24 10:20:42 UTC (rev 6146)
@@ -75,8 +75,7 @@
double getRetryIntervalMultiplier();
- int getMaxRetriesBeforeFailover();
+ int getInitialConnectAttempts();
- int getMaxRetriesAfterFailover();
-
+ int getReconnectAttempts();
}
Modified: trunk/src/main/org/jboss/messaging/jms/server/management/JMSServerControlMBean.java
===================================================================
--- trunk/src/main/org/jboss/messaging/jms/server/management/JMSServerControlMBean.java 2009-03-23 19:56:44 UTC (rev 6145)
+++ trunk/src/main/org/jboss/messaging/jms/server/management/JMSServerControlMBean.java 2009-03-24 10:20:42 UTC (rev 6146)
@@ -149,10 +149,10 @@
long retryInterval,
@Parameter(name = "retryIntervalMultiplier", desc = "The retry interval multiplier when retrying connecting to same server")
double retryIntervalMultiplier,
- @Parameter(name = "maxRetriesBeforeFailover", desc = "The maximum number of connection attempts to a server before failover. -1 means no maximum")
- int maxRetriesBeforeFailover,
- @Parameter(name = "maxRetriesAfterFailover", desc = "The maximum number of connection attempts to a server after failover. -1 means no maximum")
- int maxRetriesAfterFailover,
+ @Parameter(name = "initialConnectAttempts", desc = "The maximum number of attempts to make to establish a first connection. -1 means no maximum")
+ int initialConnectAttempts,
+ @Parameter(name = "reconnectAttempts", desc = "The maximum number of re-connection attempts to a server after failure has been detected. -1 means no maximum")
+ int reconnectAttempts,
@Parameter(name = "jndiBinding", desc = "JNDI Binding")
String jndiBinding)
throws Exception;
@@ -211,10 +211,10 @@
long retryInterval,
@Parameter(name = "retryIntervalMultiplier", desc = "The retry interval multiplier when retrying connecting to same server")
double retryIntervalMultiplier,
- @Parameter(name = "maxRetriesBeforeFailover", desc = "The maximum number of connection attempts to a server before failover. -1 means no maximum")
- int maxRetriesBeforeFailover,
- @Parameter(name = "maxRetriesAfterFailover", desc = "The maximum number of connection attempts to a server after failover. -1 means no maximum")
- int maxRetriesAfterFailover,
+ @Parameter(name = "initialConnectAttempts", desc = "The maximum number of attempts to make to establish a first connection. -1 means no maximum")
+ int initialConnectAttempts,
+ @Parameter(name = "reconnectAttempts", desc = "The maximum number of re-connection attempts to a server after failure has been detected. -1 means no maximum")
+ int reconnectAttempts,
@Parameter(name = "jndiBinding", desc = "JNDI Binding")
String jndiBinding)
throws Exception;
@@ -235,5 +235,6 @@
String[] listConnectionIDs() throws Exception;
@Operation(desc = "List the sessions for the given connectionID", impact = INFO)
+
String[] listSessions(@Parameter(desc = "a connection ID", name = "connectionID") String connectionID) throws Exception;
}
Modified: trunk/src/main/org/jboss/messaging/jms/server/management/impl/ConnectionFactoryControl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/jms/server/management/impl/ConnectionFactoryControl.java 2009-03-23 19:56:44 UTC (rev 6145)
+++ trunk/src/main/org/jboss/messaging/jms/server/management/impl/ConnectionFactoryControl.java 2009-03-24 10:20:42 UTC (rev 6146)
@@ -36,24 +36,23 @@
* @version <tt>$Revision$</tt>
*
*/
-public class ConnectionFactoryControl extends StandardMBean implements
- ConnectionFactoryControlMBean
+public class ConnectionFactoryControl extends StandardMBean implements ConnectionFactoryControlMBean
{
// Constants -----------------------------------------------------
// Attributes ----------------------------------------------------
private final JBossConnectionFactory cf;
+
private final List<String> bindings;
+
private final String name;
// Static --------------------------------------------------------
// Constructors --------------------------------------------------
- public ConnectionFactoryControl(final JBossConnectionFactory cf,
- final String name, final List<String> bindings)
- throws NotCompliantMBeanException
+ public ConnectionFactoryControl(final JBossConnectionFactory cf, final String name, final List<String> bindings) throws NotCompliantMBeanException
{
super(ConnectionFactoryControlMBean.class);
this.cf = cf;
@@ -74,19 +73,19 @@
{
return cf.getClientID();
}
-
+
public long getPingPeriod()
{
return cf.getPingPeriod();
}
-
+
public long getCallTimeout()
{
return cf.getCallTimeout();
}
-
+
public int getConsumerMaxRate()
- {
+ {
return cf.getConsumerMaxRate();
}
@@ -124,7 +123,7 @@
{
return cf.isBlockOnPersistentSend();
}
-
+
public boolean isPreAcknowledge()
{
return cf.isPreAcknowledge();
@@ -145,14 +144,14 @@
return cf.getMaxConnections();
}
- public int getMaxRetriesAfterFailover()
+ public int getInitialConnectAttempts()
{
- return cf.getMaxRetriesAfterFailover();
+ return cf.getInitialConnectAttempts();
}
- public int getMaxRetriesBeforeFailover()
+ public int getReconnectAttempts()
{
- return cf.getMaxRetriesBeforeFailover();
+ return cf.getReconnectAttempts();
}
public long getMinLargeMessageSize()
@@ -179,8 +178,6 @@
{
return cf.isAutoGroup();
}
-
-
// Package protected ---------------------------------------------
Modified: trunk/src/main/org/jboss/messaging/jms/server/management/impl/JMSServerControl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/jms/server/management/impl/JMSServerControl.java 2009-03-23 19:56:44 UTC (rev 6145)
+++ trunk/src/main/org/jboss/messaging/jms/server/management/impl/JMSServerControl.java 2009-03-24 10:20:42 UTC (rev 6146)
@@ -100,8 +100,8 @@
boolean preAcknowledge,
long retryInterval,
double retryIntervalMultiplier,
- int maxRetriesBeforeFailover,
- int maxRetriesAfterFailover,
+ int initialConnectAttempts,
+ int reconnectAttempts,
String jndiBinding) throws Exception
{
List<String> bindings = new ArrayList<String>();
@@ -132,8 +132,8 @@
preAcknowledge,
retryInterval,
retryIntervalMultiplier,
- maxRetriesBeforeFailover,
- maxRetriesAfterFailover,
+ initialConnectAttempts,
+ reconnectAttempts,
bindings);
if (created)
{
@@ -209,8 +209,8 @@
boolean preAcknowledge,
long retryInterval,
double retryIntervalMultiplier,
- int maxRetriesBeforeFailover,
- int maxRetriesAfterFailover,
+ int initialConnectAttempts,
+ int reconnectAttempts,
String jndiBinding) throws Exception
{
List<String> bindings = new ArrayList<String>();
@@ -238,8 +238,8 @@
preAcknowledge,
retryInterval,
retryIntervalMultiplier,
- maxRetriesBeforeFailover,
- maxRetriesAfterFailover,
+ initialConnectAttempts,
+ reconnectAttempts,
bindings);
if (created)
{
@@ -273,8 +273,8 @@
final boolean preAcknowledge,
final long retryInterval,
final double retryIntervalMultiplier,
- final int maxRetriesBeforeFailover,
- final int maxRetriesAfterFailover,
+ final int initialConnectAttempts,
+ final int reconnectAttempts,
final String jndiBinding) throws Exception
{
List<String> bindings = new ArrayList<String>();
@@ -305,8 +305,8 @@
preAcknowledge,
retryInterval,
retryIntervalMultiplier,
- maxRetriesBeforeFailover,
- maxRetriesAfterFailover,
+ initialConnectAttempts,
+ reconnectAttempts,
bindings);
if (created)
{
Modified: trunk/src/main/org/jboss/messaging/jms/server/management/jmx/impl/ReplicationAwareConnectionFactoryControlWrapper.java
===================================================================
--- trunk/src/main/org/jboss/messaging/jms/server/management/jmx/impl/ReplicationAwareConnectionFactoryControlWrapper.java 2009-03-23 19:56:44 UTC (rev 6145)
+++ trunk/src/main/org/jboss/messaging/jms/server/management/jmx/impl/ReplicationAwareConnectionFactoryControlWrapper.java 2009-03-24 10:20:42 UTC (rev 6146)
@@ -52,7 +52,7 @@
// Constructors --------------------------------------------------
- public ReplicationAwareConnectionFactoryControlWrapper(final ObjectName objectName,
+ public ReplicationAwareConnectionFactoryControlWrapper(final ObjectName objectName,
final ConnectionFactoryControl localControl,
final ReplicationOperationInvoker replicationInvoker) throws Exception
{
@@ -126,7 +126,7 @@
{
return localControl.isBlockOnPersistentSend();
}
-
+
public boolean isPreAcknowledge()
{
return localControl.isPreAcknowledge();
@@ -142,14 +142,14 @@
return localControl.getMaxConnections();
}
- public int getMaxRetriesAfterFailover()
+ public int getInitialConnectAttempts()
{
- return localControl.getMaxRetriesAfterFailover();
+ return localControl.getInitialConnectAttempts();
}
- public int getMaxRetriesBeforeFailover()
+ public int getReconnectAttempts()
{
- return localControl.getMaxRetriesBeforeFailover();
+ return localControl.getReconnectAttempts();
}
public long getMinLargeMessageSize()
@@ -177,7 +177,6 @@
return localControl.isAutoGroup();
}
-
// StandardMBean overrides ---------------------------------------
@Override
@@ -192,7 +191,6 @@
info.getNotifications());
}
-
// Public --------------------------------------------------------
// Package protected ---------------------------------------------
Modified: trunk/src/main/org/jboss/messaging/jms/server/management/jmx/impl/ReplicationAwareJMSServerControlWrapper.java
===================================================================
--- trunk/src/main/org/jboss/messaging/jms/server/management/jmx/impl/ReplicationAwareJMSServerControlWrapper.java 2009-03-23 19:56:44 UTC (rev 6145)
+++ trunk/src/main/org/jboss/messaging/jms/server/management/jmx/impl/ReplicationAwareJMSServerControlWrapper.java 2009-03-24 10:20:42 UTC (rev 6146)
@@ -116,8 +116,8 @@
final boolean preAcknowledge,
final long retryInterval,
final double retryIntervalMultiplier,
- final int maxRetriesBeforeFailover,
- final int maxRetriesAfterFailover,
+ final int initialConnectAttempts,
+ final int reconnectAttempts,
final String jndiBinding) throws Exception
{
replicationAwareInvoke("createSimpleConnectionFactory",
@@ -143,8 +143,8 @@
preAcknowledge,
retryInterval,
retryIntervalMultiplier,
- maxRetriesBeforeFailover,
- maxRetriesAfterFailover,
+ initialConnectAttempts,
+ reconnectAttempts,
jndiBinding);
}
@@ -170,8 +170,8 @@
final boolean preAcknowledge,
final long retryInterval,
final double retryIntervalMultiplier,
- final int maxRetriesBeforeFailover,
- final int maxRetriesAfterFailover,
+ final int initialConnectAttempts,
+ final int reconnectAttempts,
final String jndiBinding) throws Exception
{
// FIXME need to store correctly the connector configs
@@ -198,8 +198,8 @@
preAcknowledge,
retryInterval,
retryIntervalMultiplier,
- maxRetriesBeforeFailover,
- maxRetriesAfterFailover,
+ initialConnectAttempts,
+ reconnectAttempts,
jndiBinding);
}
@@ -229,8 +229,8 @@
final boolean preAcknowledge,
final long retryInterval,
final double retryIntervalMultiplier,
- final int maxRetriesBeforeFailover,
- final int maxRetriesAfterFailover,
+ final int initialConnectAttempts,
+ final int reconnectAttempts,
final String jndiBinding) throws Exception
{
replicationAwareInvoke("createConnectionFactory",
@@ -260,8 +260,8 @@
preAcknowledge,
retryInterval,
retryIntervalMultiplier,
- maxRetriesBeforeFailover,
- maxRetriesAfterFailover,
+ initialConnectAttempts,
+ reconnectAttempts,
jndiBinding);
}
Modified: trunk/src/main/org/jboss/messaging/ra/JBMRAProperties.java
===================================================================
--- trunk/src/main/org/jboss/messaging/ra/JBMRAProperties.java 2009-03-23 19:56:44 UTC (rev 6145)
+++ trunk/src/main/org/jboss/messaging/ra/JBMRAProperties.java 2009-03-24 10:20:42 UTC (rev 6146)
@@ -116,10 +116,10 @@
private Double retryIntervalMultiplier;
/** */
- private Integer maxRetriesBeforeFailover;
+ private Integer initialConnectAttempts;
/** */
- private Integer maxRetriesAfterFailover;
+ private Integer reconnectAttempts;
/** The user name */
private String userName;
@@ -173,8 +173,8 @@
preAcknowledge = null;
retryInterval = null;
retryIntervalMultiplier = null;
- maxRetriesBeforeFailover = null;
- maxRetriesAfterFailover = null;
+ initialConnectAttempts = null;
+ reconnectAttempts = null;
userName = null;
password = null;
clientID = null;
@@ -734,51 +734,51 @@
}
/**
- * Get max retries before failover
+ * Get initial connect attempts
* @return The value
*/
- public Integer getMaxRetriesBeforeFailover()
+ public Integer getInitialConnectAttempts()
{
if (trace)
- log.trace("getMaxRetriesBeforeFailover()");
+ log.trace("getInitialConnectAttempts()");
- return maxRetriesBeforeFailover;
+ return initialConnectAttempts;
}
/**
- * Set max retries before failover
- * @param maxRetriesBeforeFailover The value
+ * Set initial connect attempts
+ * @param initialConnectAttempts The value
*/
- public void setMaxRetriesBeforeFailover(Integer maxRetriesBeforeFailover)
+ public void setInitialConnectAttempts(Integer initialConnectAttempts)
{
if (trace)
- log.trace("setMaxRetriesBeforeFailover(" + maxRetriesBeforeFailover + ")");
+ log.trace("setInitialConnectAttempts(" + initialConnectAttempts + ")");
- this.maxRetriesBeforeFailover = maxRetriesBeforeFailover;
+ this.initialConnectAttempts = initialConnectAttempts;
}
/**
- * Get max retries after failover
+ * Get reconnect attempts
* @return The value
*/
- public Integer getMaxRetriesAfterFailover()
+ public Integer getReconnectAttempts()
{
if (trace)
- log.trace("getMaxRetriesAfterFailover()");
+ log.trace("getReconnectAttempts()");
- return maxRetriesAfterFailover;
+ return reconnectAttempts;
}
/**
- * Set max retries after failover
- * @param maxRetriesAfterFailover The value
+ * Set reconnect attempts
+ * @param reconnectAttempts The value
*/
- public void setMaxRetriesAfterFailover(Integer maxRetriesAfterFailover)
+ public void setReconnectAttempts(Integer reconnectAttempts)
{
if (trace)
- log.trace("setMaxRetriesAfterFailover(" + maxRetriesAfterFailover + ")");
+ log.trace("setReconnectAttempts(" + reconnectAttempts + ")");
- this.maxRetriesAfterFailover = maxRetriesAfterFailover;
+ this.reconnectAttempts = reconnectAttempts;
}
/**
@@ -931,8 +931,8 @@
Util.compare(preAcknowledge, you.getPreAcknowledge()) &&
Util.compare(retryInterval, you.getRetryInterval()) &&
Util.compare(retryIntervalMultiplier, you.getRetryIntervalMultiplier()) &&
- Util.compare(maxRetriesBeforeFailover, you.getMaxRetriesBeforeFailover()) &&
- Util.compare(maxRetriesAfterFailover, you.getMaxRetriesAfterFailover()) &&
+ Util.compare(initialConnectAttempts, you.getInitialConnectAttempts()) &&
+ Util.compare(reconnectAttempts, you.getReconnectAttempts()) &&
Util.compare(userName, you.getUserName()) &&
Util.compare(password, you.getPassword()) &&
Util.compare(clientID, you.getClientID()) &&
@@ -976,8 +976,8 @@
hash += 31 * hash + (preAcknowledge != null ? preAcknowledge.hashCode() : 0);
hash += 31 * hash + (retryInterval != null ? retryInterval.hashCode() : 0);
hash += 31 * hash + (retryIntervalMultiplier != null ? retryIntervalMultiplier.hashCode() : 0);
- hash += 31 * hash + (maxRetriesBeforeFailover != null ? maxRetriesBeforeFailover.hashCode() : 0);
- hash += 31 * hash + (maxRetriesAfterFailover != null ? maxRetriesAfterFailover.hashCode() : 0);
+ hash += 31 * hash + (initialConnectAttempts != null ? initialConnectAttempts.hashCode() : 0);
+ hash += 31 * hash + (reconnectAttempts != null ? reconnectAttempts.hashCode() : 0);
hash += 31 * hash + (userName != null ? userName.hashCode() : 0);
hash += 31 * hash + (password != null ? password.hashCode() : 0);
hash += 31 * hash + (clientID != null ? clientID.hashCode() : 0);
Modified: trunk/src/main/org/jboss/messaging/ra/JBMResourceAdapter.java
===================================================================
--- trunk/src/main/org/jboss/messaging/ra/JBMResourceAdapter.java 2009-03-23 19:56:44 UTC (rev 6145)
+++ trunk/src/main/org/jboss/messaging/ra/JBMResourceAdapter.java 2009-03-24 10:20:42 UTC (rev 6146)
@@ -119,7 +119,7 @@
*/
public void endpointActivation(MessageEndpointFactory endpointFactory, ActivationSpec spec) throws ResourceException
{
- if(!configured.getAndSet(true))
+ if (!configured.getAndSet(true))
{
try
{
@@ -135,7 +135,7 @@
log.trace("endpointActivation(" + endpointFactory + ", " + spec + ")");
}
- JBMActivation activation = new JBMActivation(this, endpointFactory, (JBMActivationSpec) spec);
+ JBMActivation activation = new JBMActivation(this, endpointFactory, (JBMActivationSpec)spec);
activations.put(spec, activation);
activation.start();
}
@@ -153,7 +153,7 @@
log.trace("endpointDeactivation(" + endpointFactory + ", " + spec + ")");
}
- JBMActivation activation = (JBMActivation) activations.remove(spec);
+ JBMActivation activation = (JBMActivation)activations.remove(spec);
if (activation != null)
{
activation.stop();
@@ -208,10 +208,10 @@
for (Iterator i = activations.entrySet().iterator(); i.hasNext();)
{
- Map.Entry entry = (Map.Entry) i.next();
+ Map.Entry entry = (Map.Entry)i.next();
try
{
- JBMActivation activation = (JBMActivation) entry.getValue();
+ JBMActivation activation = (JBMActivation)entry.getValue();
if (activation != null)
{
activation.stop();
@@ -275,7 +275,6 @@
}
}
-
public String getBackUpTransportType()
{
return raProperties.getBackUpTransportType();
@@ -1014,63 +1013,63 @@
}
/**
- * Get max retries before failover
+ * Get max number of initial connect attempts
*
* @return The value
*/
- public Integer getMaxRetriesBeforeFailover()
+ public Integer getInitialConnectAttempts()
{
if (trace)
{
- log.trace("getMaxRetriesBeforeFailover()");
+ log.trace("getInitialConnectAttempts()");
}
- return raProperties.getMaxRetriesBeforeFailover();
+ return raProperties.getInitialConnectAttempts();
}
/**
- * Set max retries before failover
+ * Set max number of initial connect attempts
*
- * @param maxRetriesBeforeFailover The value
+ * @param initialConnectAttempts The value
*/
- public void setMaxRetriesBeforeFailover(Integer maxRetriesBeforeFailover)
+ public void setInitialConnectAttempts(Integer initialConnectAttempts)
{
if (trace)
{
- log.trace("setMaxRetriesBeforeFailover(" + maxRetriesBeforeFailover + ")");
+ log.trace("setInitialConnectAttempts(" + initialConnectAttempts + ")");
}
- raProperties.setMaxRetriesBeforeFailover(maxRetriesBeforeFailover);
+ raProperties.setInitialConnectAttempts(initialConnectAttempts);
}
/**
- * Get max retries after failover
+ * Get reconnect attempts
*
* @return The value
*/
- public Integer getMaxRetriesAfterFailover()
+ public Integer getReconnectAttempts()
{
if (trace)
{
- log.trace("getMaxRetriesAfterFailover()");
+ log.trace("getReconnectAttempts()");
}
- return raProperties.getMaxRetriesAfterFailover();
+ return raProperties.getReconnectAttempts();
}
/**
- * Set max retries after failover
+ * Set reconnect attempts
*
- * @param maxRetriesAfterFailover The value
+ * @param reconnectAttempts The value
*/
- public void setMaxRetriesAfterFailover(Integer maxRetriesAfterFailover)
+ public void setReconnectAttempts(Integer reconnectAttempts)
{
if (trace)
{
- log.trace("setMaxRetriesAfterFailover(" + maxRetriesAfterFailover + ")");
+ log.trace("setReconnectAttempts(" + reconnectAttempts + ")");
}
- raProperties.setMaxRetriesAfterFailover(maxRetriesAfterFailover);
+ raProperties.setReconnectAttempts(reconnectAttempts);
}
/**
@@ -1213,7 +1212,7 @@
if (obj instanceof JBMResourceAdapter)
{
- return raProperties.equals(((JBMResourceAdapter) obj).getProperties());
+ return raProperties.equals(((JBMResourceAdapter)obj).getProperties());
}
else
{
@@ -1256,30 +1255,68 @@
return ctx.getWorkManager();
}
- public ClientSession createSession(int ackMode, String user, String pass, Boolean preAck, Integer dupsOkBatchSize, Integer transactionBatchSize, boolean deliveryTransacted) throws Exception
+ public ClientSession createSession(int ackMode,
+ String user,
+ String pass,
+ Boolean preAck,
+ Integer dupsOkBatchSize,
+ Integer transactionBatchSize,
+ boolean deliveryTransacted) throws Exception
{
ClientSession result;
boolean actPreAck = preAck != null ? preAck : ClientSessionFactoryImpl.DEFAULT_PRE_ACKNOWLEDGE;
- int actDupsOkBatchSize = dupsOkBatchSize != null ? dupsOkBatchSize : ClientSessionFactoryImpl.DEFAULT_ACK_BATCH_SIZE;
- int actTxBatchSize = transactionBatchSize != null ? transactionBatchSize : ClientSessionFactoryImpl.DEFAULT_ACK_BATCH_SIZE;
+ int actDupsOkBatchSize = dupsOkBatchSize != null ? dupsOkBatchSize
+ : ClientSessionFactoryImpl.DEFAULT_ACK_BATCH_SIZE;
+ int actTxBatchSize = transactionBatchSize != null ? transactionBatchSize
+ : ClientSessionFactoryImpl.DEFAULT_ACK_BATCH_SIZE;
switch (ackMode)
{
case Session.SESSION_TRANSACTED:
- result = sessionFactory.createSession(user, pass, deliveryTransacted, false, false, actPreAck, actTxBatchSize);
+ result = sessionFactory.createSession(user,
+ pass,
+ deliveryTransacted,
+ false,
+ false,
+ actPreAck,
+ actTxBatchSize);
break;
case Session.AUTO_ACKNOWLEDGE:
- result = sessionFactory.createSession(user, pass, deliveryTransacted, true, false, actPreAck, actTxBatchSize);
+ result = sessionFactory.createSession(user,
+ pass,
+ deliveryTransacted,
+ true,
+ false,
+ actPreAck,
+ actTxBatchSize);
break;
case Session.DUPS_OK_ACKNOWLEDGE:
- result = sessionFactory.createSession(user, pass, deliveryTransacted, true, false, actPreAck, actDupsOkBatchSize);
+ result = sessionFactory.createSession(user,
+ pass,
+ deliveryTransacted,
+ true,
+ false,
+ actPreAck,
+ actDupsOkBatchSize);
break;
case Session.CLIENT_ACKNOWLEDGE:
- result = sessionFactory.createSession(user, pass, deliveryTransacted, false, false, actPreAck, actTxBatchSize);
+ result = sessionFactory.createSession(user,
+ pass,
+ deliveryTransacted,
+ false,
+ false,
+ actPreAck,
+ actTxBatchSize);
break;
case JBossSession.SERVER_ACKNOWLEDGE:
- result = sessionFactory.createSession(user, pass, deliveryTransacted, false, true, actPreAck, actTxBatchSize);
+ result = sessionFactory.createSession(user,
+ pass,
+ deliveryTransacted,
+ false,
+ true,
+ actPreAck,
+ actTxBatchSize);
break;
default:
throw new IllegalArgumentException("Invalid ackmode: " + ackMode);
@@ -1313,73 +1350,117 @@
{
if (getTransportType() != null)
{
- TransportConfiguration transportConf = new TransportConfiguration(getTransportType(), getTransportConfiguration());
- TransportConfiguration backup = getBackUpTransportType() == null ? null : new TransportConfiguration(getBackUpTransportType(), getBackupTransportConfiguration());
+ TransportConfiguration transportConf = new TransportConfiguration(getTransportType(),
+ getTransportConfiguration());
+ TransportConfiguration backup = getBackUpTransportType() == null ? null
+ : new TransportConfiguration(getBackUpTransportType(),
+ getBackupTransportConfiguration());
jBossConnectionFactory = new JBossConnectionFactory(transportConf,
backup,
- getLoadBalancingPolicyClassName() == null ? ClientSessionFactoryImpl.DEFAULT_CONNECTION_LOAD_BALANCING_POLICY_CLASS_NAME : getLoadBalancingPolicyClassName(),
- getPingPeriod() == null ? ClientSessionFactoryImpl.DEFAULT_PING_PERIOD : getPingPeriod(),
- getConnectionTTL() == null ? ClientSessionFactoryImpl.DEFAULT_CONNECTION_TTL : getConnectionTTL(),
- getCallTimeout() == null ? ClientSessionFactoryImpl.DEFAULT_CALL_TIMEOUT : getCallTimeout(),
+ getLoadBalancingPolicyClassName() == null ? ClientSessionFactoryImpl.DEFAULT_CONNECTION_LOAD_BALANCING_POLICY_CLASS_NAME
+ : getLoadBalancingPolicyClassName(),
+ getPingPeriod() == null ? ClientSessionFactoryImpl.DEFAULT_PING_PERIOD
+ : getPingPeriod(),
+ getConnectionTTL() == null ? ClientSessionFactoryImpl.DEFAULT_CONNECTION_TTL
+ : getConnectionTTL(),
+ getCallTimeout() == null ? ClientSessionFactoryImpl.DEFAULT_CALL_TIMEOUT
+ : getCallTimeout(),
getClientID(),
- getDupsOKBatchSize() == null ? ClientSessionFactoryImpl.DEFAULT_ACK_BATCH_SIZE : getDupsOKBatchSize(),
- getTransactionBatchSize() == null ? ClientSessionFactoryImpl.DEFAULT_ACK_BATCH_SIZE : getTransactionBatchSize(),
- getConsumerWindowSize() == null ? ClientSessionFactoryImpl.DEFAULT_CONSUMER_WINDOW_SIZE : getConsumerWindowSize(),
- getConsumerMaxRate() == null ? ClientSessionFactoryImpl.DEFAULT_CONSUMER_MAX_RATE : getConsumerMaxRate(),
- getSendWindowSize() == null ? ClientSessionFactoryImpl.DEFAULT_SEND_WINDOW_SIZE : getSendWindowSize(),
- getProducerMaxRate() == null ? ClientSessionFactoryImpl.DEFAULT_PRODUCER_MAX_RATE : getProducerMaxRate(),
- getMinLargeMessageSize() == null ? ClientSessionFactoryImpl.DEFAULT_MIN_LARGE_MESSAGE_SIZE : getMinLargeMessageSize(),
- getBlockOnAcknowledge() == null ? ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_ACKNOWLEDGE : getBlockOnAcknowledge(),
- getBlockOnNonPersistentSend() == null ? ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_NON_PERSISTENT_SEND : getBlockOnNonPersistentSend(),
- getBlockOnPersistentSend() == null ? ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_PERSISTENT_SEND : getBlockOnPersistentSend(),
- getAutoGroup() == null ? ClientSessionFactoryImpl.DEFAULT_AUTO_GROUP : getAutoGroup(),
- getMaxConnections() == null ? ClientSessionFactoryImpl.DEFAULT_MAX_CONNECTIONS : getMaxConnections(),
- getPreAcknowledge() == null ? ClientSessionFactoryImpl.DEFAULT_PRE_ACKNOWLEDGE : getPreAcknowledge(),
- getRetryInterval() == null ? ClientSessionFactoryImpl.DEFAULT_RETRY_INTERVAL : getRetryInterval(),
- getRetryIntervalMultiplier() == null ? ClientSessionFactoryImpl.DEFAULT_RETRY_INTERVAL_MULTIPLIER : getRetryIntervalMultiplier(),
- getMaxRetriesBeforeFailover() == null ? ClientSessionFactoryImpl.DEFAULT_MAX_RETRIES_BEFORE_FAILOVER : getMaxRetriesBeforeFailover(),
- getMaxRetriesAfterFailover() == null ? ClientSessionFactoryImpl.DEFAULT_MAX_RETRIES_AFTER_FAILOVER : getMaxRetriesAfterFailover()
- );
+ getDupsOKBatchSize() == null ? ClientSessionFactoryImpl.DEFAULT_ACK_BATCH_SIZE
+ : getDupsOKBatchSize(),
+ getTransactionBatchSize() == null ? ClientSessionFactoryImpl.DEFAULT_ACK_BATCH_SIZE
+ : getTransactionBatchSize(),
+ getConsumerWindowSize() == null ? ClientSessionFactoryImpl.DEFAULT_CONSUMER_WINDOW_SIZE
+ : getConsumerWindowSize(),
+ getConsumerMaxRate() == null ? ClientSessionFactoryImpl.DEFAULT_CONSUMER_MAX_RATE
+ : getConsumerMaxRate(),
+ getSendWindowSize() == null ? ClientSessionFactoryImpl.DEFAULT_SEND_WINDOW_SIZE
+ : getSendWindowSize(),
+ getProducerMaxRate() == null ? ClientSessionFactoryImpl.DEFAULT_PRODUCER_MAX_RATE
+ : getProducerMaxRate(),
+ getMinLargeMessageSize() == null ? ClientSessionFactoryImpl.DEFAULT_MIN_LARGE_MESSAGE_SIZE
+ : getMinLargeMessageSize(),
+ getBlockOnAcknowledge() == null ? ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_ACKNOWLEDGE
+ : getBlockOnAcknowledge(),
+ getBlockOnNonPersistentSend() == null ? ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_NON_PERSISTENT_SEND
+ : getBlockOnNonPersistentSend(),
+ getBlockOnPersistentSend() == null ? ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_PERSISTENT_SEND
+ : getBlockOnPersistentSend(),
+ getAutoGroup() == null ? ClientSessionFactoryImpl.DEFAULT_AUTO_GROUP
+ : getAutoGroup(),
+ getMaxConnections() == null ? ClientSessionFactoryImpl.DEFAULT_MAX_CONNECTIONS
+ : getMaxConnections(),
+ getPreAcknowledge() == null ? ClientSessionFactoryImpl.DEFAULT_PRE_ACKNOWLEDGE
+ : getPreAcknowledge(),
+ getRetryInterval() == null ? ClientSessionFactoryImpl.DEFAULT_RETRY_INTERVAL
+ : getRetryInterval(),
+ getRetryIntervalMultiplier() == null ? ClientSessionFactoryImpl.DEFAULT_RETRY_INTERVAL_MULTIPLIER
+ : getRetryIntervalMultiplier(),
+ getInitialConnectAttempts() == null ? ClientSessionFactoryImpl.DEFAULT_INITIAL_CONNECT_ATTEMPTS
+ : getInitialConnectAttempts(),
+ getReconnectAttempts() == null ? ClientSessionFactoryImpl.DEFAULT_RECONNECT_ATTEMPTS
+ : getReconnectAttempts());
}
else if (getDiscoveryGroupAddress() != null && getDiscoveryGroupPort() != null)
{
jBossConnectionFactory = new JBossConnectionFactory(getDiscoveryGroupAddress(),
getDiscoveryGroupPort(),
- getDiscoveryRefreshTimeout() == null ? ConfigurationImpl.DEFAULT_BROADCAST_REFRESH_TIMEOUT : getDiscoveryRefreshTimeout(),
- getDiscoveryInitialWaitTimeout() == null ? ClientSessionFactoryImpl.DEFAULT_DISCOVERY_INITIAL_WAIT : getDiscoveryInitialWaitTimeout(),
- getLoadBalancingPolicyClassName() == null ? ClientSessionFactoryImpl.DEFAULT_CONNECTION_LOAD_BALANCING_POLICY_CLASS_NAME : getLoadBalancingPolicyClassName(),
- getPingPeriod() == null ? ClientSessionFactoryImpl.DEFAULT_PING_PERIOD : getPingPeriod(),
- getConnectionTTL() == null ? ClientSessionFactoryImpl.DEFAULT_CONNECTION_TTL : getConnectionTTL(),
- getCallTimeout() == null ? ClientSessionFactoryImpl.DEFAULT_CALL_TIMEOUT : getCallTimeout(),
+ getDiscoveryRefreshTimeout() == null ? ConfigurationImpl.DEFAULT_BROADCAST_REFRESH_TIMEOUT
+ : getDiscoveryRefreshTimeout(),
+ getDiscoveryInitialWaitTimeout() == null ? ClientSessionFactoryImpl.DEFAULT_DISCOVERY_INITIAL_WAIT
+ : getDiscoveryInitialWaitTimeout(),
+ getLoadBalancingPolicyClassName() == null ? ClientSessionFactoryImpl.DEFAULT_CONNECTION_LOAD_BALANCING_POLICY_CLASS_NAME
+ : getLoadBalancingPolicyClassName(),
+ getPingPeriod() == null ? ClientSessionFactoryImpl.DEFAULT_PING_PERIOD
+ : getPingPeriod(),
+ getConnectionTTL() == null ? ClientSessionFactoryImpl.DEFAULT_CONNECTION_TTL
+ : getConnectionTTL(),
+ getCallTimeout() == null ? ClientSessionFactoryImpl.DEFAULT_CALL_TIMEOUT
+ : getCallTimeout(),
getClientID(),
- getDupsOKBatchSize() == null ? ClientSessionFactoryImpl.DEFAULT_ACK_BATCH_SIZE : getDupsOKBatchSize(),
- getTransactionBatchSize() == null ? ClientSessionFactoryImpl.DEFAULT_ACK_BATCH_SIZE : getTransactionBatchSize(),
- getConsumerWindowSize() == null ? ClientSessionFactoryImpl.DEFAULT_CONSUMER_WINDOW_SIZE : getConsumerWindowSize(),
- getConsumerMaxRate() == null ? ClientSessionFactoryImpl.DEFAULT_CONSUMER_MAX_RATE : getConsumerMaxRate(),
- getSendWindowSize() == null ? ClientSessionFactoryImpl.DEFAULT_SEND_WINDOW_SIZE : getSendWindowSize(),
- getProducerMaxRate() == null ? ClientSessionFactoryImpl.DEFAULT_PRODUCER_MAX_RATE : getProducerMaxRate(),
- getMinLargeMessageSize() == null ? ClientSessionFactoryImpl.DEFAULT_MIN_LARGE_MESSAGE_SIZE : getMinLargeMessageSize(),
- getBlockOnAcknowledge() == null ? ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_ACKNOWLEDGE : getBlockOnAcknowledge(),
- getBlockOnNonPersistentSend() == null ? ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_NON_PERSISTENT_SEND : getBlockOnNonPersistentSend(),
- getBlockOnPersistentSend() == null ? ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_PERSISTENT_SEND : getBlockOnPersistentSend(),
- getAutoGroup() == null ? ClientSessionFactoryImpl.DEFAULT_AUTO_GROUP : getAutoGroup(),
- getMaxConnections() == null ? ClientSessionFactoryImpl.DEFAULT_MAX_CONNECTIONS : getMaxConnections(),
- getPreAcknowledge() == null ? ClientSessionFactoryImpl.DEFAULT_PRE_ACKNOWLEDGE : getPreAcknowledge(),
- getRetryInterval() == null ? ClientSessionFactoryImpl.DEFAULT_RETRY_INTERVAL : getRetryInterval(),
- getRetryIntervalMultiplier() == null ? ClientSessionFactoryImpl.DEFAULT_RETRY_INTERVAL_MULTIPLIER : getRetryIntervalMultiplier(),
- getMaxRetriesBeforeFailover() == null ? ClientSessionFactoryImpl.DEFAULT_MAX_RETRIES_BEFORE_FAILOVER : getMaxRetriesBeforeFailover(),
- getMaxRetriesAfterFailover() == null ? ClientSessionFactoryImpl.DEFAULT_MAX_RETRIES_AFTER_FAILOVER : getMaxRetriesAfterFailover()
- );
+ getDupsOKBatchSize() == null ? ClientSessionFactoryImpl.DEFAULT_ACK_BATCH_SIZE
+ : getDupsOKBatchSize(),
+ getTransactionBatchSize() == null ? ClientSessionFactoryImpl.DEFAULT_ACK_BATCH_SIZE
+ : getTransactionBatchSize(),
+ getConsumerWindowSize() == null ? ClientSessionFactoryImpl.DEFAULT_CONSUMER_WINDOW_SIZE
+ : getConsumerWindowSize(),
+ getConsumerMaxRate() == null ? ClientSessionFactoryImpl.DEFAULT_CONSUMER_MAX_RATE
+ : getConsumerMaxRate(),
+ getSendWindowSize() == null ? ClientSessionFactoryImpl.DEFAULT_SEND_WINDOW_SIZE
+ : getSendWindowSize(),
+ getProducerMaxRate() == null ? ClientSessionFactoryImpl.DEFAULT_PRODUCER_MAX_RATE
+ : getProducerMaxRate(),
+ getMinLargeMessageSize() == null ? ClientSessionFactoryImpl.DEFAULT_MIN_LARGE_MESSAGE_SIZE
+ : getMinLargeMessageSize(),
+ getBlockOnAcknowledge() == null ? ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_ACKNOWLEDGE
+ : getBlockOnAcknowledge(),
+ getBlockOnNonPersistentSend() == null ? ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_NON_PERSISTENT_SEND
+ : getBlockOnNonPersistentSend(),
+ getBlockOnPersistentSend() == null ? ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_PERSISTENT_SEND
+ : getBlockOnPersistentSend(),
+ getAutoGroup() == null ? ClientSessionFactoryImpl.DEFAULT_AUTO_GROUP
+ : getAutoGroup(),
+ getMaxConnections() == null ? ClientSessionFactoryImpl.DEFAULT_MAX_CONNECTIONS
+ : getMaxConnections(),
+ getPreAcknowledge() == null ? ClientSessionFactoryImpl.DEFAULT_PRE_ACKNOWLEDGE
+ : getPreAcknowledge(),
+ getRetryInterval() == null ? ClientSessionFactoryImpl.DEFAULT_RETRY_INTERVAL
+ : getRetryInterval(),
+ getRetryIntervalMultiplier() == null ? ClientSessionFactoryImpl.DEFAULT_RETRY_INTERVAL_MULTIPLIER
+ : getRetryIntervalMultiplier(),
+ getInitialConnectAttempts() == null ? ClientSessionFactoryImpl.DEFAULT_INITIAL_CONNECT_ATTEMPTS
+ : getInitialConnectAttempts(),
+ getReconnectAttempts() == null ? ClientSessionFactoryImpl.DEFAULT_RECONNECT_ATTEMPTS
+ : getReconnectAttempts());
}
else
{
log.fatal("must provide either TransportTyoe or DiscoveryGroupAddress and DiscoveryGroupPort for JBM ResourceAdapter");
}
- sessionFactory = jBossConnectionFactory.getCoreFactory();
+ sessionFactory = jBossConnectionFactory.getCoreFactory();
}
-
private Object getTransportParam(String[] conf)
{
Object val = null;
@@ -1390,7 +1471,7 @@
val = Integer.parseInt(conf[1]);
}
catch (NumberFormatException e)
- {//ok warning at end wll pick up
+ {// ok warning at end wll pick up
}
}
else if ("Long".equals(conf[2]))
@@ -1400,7 +1481,7 @@
val = Long.parseLong(conf[1]);
}
catch (NumberFormatException e)
- {//ok warning at end wll pick up
+ {// ok warning at end wll pick up
}
}
else if ("Boolean".equals(conf[2]))
@@ -1410,7 +1491,7 @@
val = Boolean.parseBoolean(conf[1]);
}
catch (NumberFormatException e)
- {//ok warning at end wll pick up
+ {// ok warning at end wll pick up
}
}
else if ("String".equals(conf[2]))
Modified: trunk/tests/config/log4j.xml
===================================================================
--- trunk/tests/config/log4j.xml 2009-03-23 19:56:44 UTC (rev 6145)
+++ trunk/tests/config/log4j.xml 2009-03-24 10:20:42 UTC (rev 6146)
@@ -14,12 +14,6 @@
| owebsite: http://jakarta.apache.org/log4j
-->
- <!--
- Only to be used for stress tests
- Stress tests cannot be run using TRACE or DEBUG level since they produce too much output
- hence they have their own log4j config
- -->
-
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">
<!-- ================================= -->
Modified: trunk/tests/jms-tests/src/org/jboss/test/messaging/jms/CTSMiscellaneousTest.java
===================================================================
--- trunk/tests/jms-tests/src/org/jboss/test/messaging/jms/CTSMiscellaneousTest.java 2009-03-23 19:56:44 UTC (rev 6145)
+++ trunk/tests/jms-tests/src/org/jboss/test/messaging/jms/CTSMiscellaneousTest.java 2009-03-24 10:20:42 UTC (rev 6146)
@@ -22,8 +22,8 @@
package org.jboss.test.messaging.jms;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_CONNECTION_TTL;
-import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_MAX_RETRIES_AFTER_FAILOVER;
-import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_MAX_RETRIES_BEFORE_FAILOVER;
+import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_INITIAL_CONNECT_ATTEMPTS;
+import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_RECONNECT_ATTEMPTS;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_RETRY_INTERVAL;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_RETRY_INTERVAL_MULTIPLIER;
@@ -102,8 +102,8 @@
ClientSessionFactoryImpl.DEFAULT_PRE_ACKNOWLEDGE,
DEFAULT_RETRY_INTERVAL,
DEFAULT_RETRY_INTERVAL_MULTIPLIER,
- DEFAULT_MAX_RETRIES_BEFORE_FAILOVER,
- DEFAULT_MAX_RETRIES_AFTER_FAILOVER,
+ DEFAULT_INITIAL_CONNECT_ATTEMPTS,
+ DEFAULT_RECONNECT_ATTEMPTS,
jndiBindings);
cf = (JBossConnectionFactory)getInitialContext().lookup("/StrictTCKConnectionFactory");
Modified: trunk/tests/jms-tests/src/org/jboss/test/messaging/jms/JMSTestCase.java
===================================================================
--- trunk/tests/jms-tests/src/org/jboss/test/messaging/jms/JMSTestCase.java 2009-03-23 19:56:44 UTC (rev 6145)
+++ trunk/tests/jms-tests/src/org/jboss/test/messaging/jms/JMSTestCase.java 2009-03-24 10:20:42 UTC (rev 6146)
@@ -1,8 +1,8 @@
package org.jboss.test.messaging.jms;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_CONNECTION_TTL;
-import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_MAX_RETRIES_AFTER_FAILOVER;
-import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_MAX_RETRIES_BEFORE_FAILOVER;
+import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_INITIAL_CONNECT_ATTEMPTS;
+import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_RECONNECT_ATTEMPTS;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_RETRY_INTERVAL;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_RETRY_INTERVAL_MULTIPLIER;
@@ -78,8 +78,8 @@
ClientSessionFactoryImpl.DEFAULT_PRE_ACKNOWLEDGE,
DEFAULT_RETRY_INTERVAL,
DEFAULT_RETRY_INTERVAL_MULTIPLIER,
- DEFAULT_MAX_RETRIES_BEFORE_FAILOVER,
- DEFAULT_MAX_RETRIES_AFTER_FAILOVER,
+ DEFAULT_INITIAL_CONNECT_ATTEMPTS,
+ DEFAULT_RECONNECT_ATTEMPTS,
jndiBindings);
cf = (JBossConnectionFactory)getInitialContext().lookup("/testsuitecf");
Modified: trunk/tests/jms-tests/src/org/jboss/test/messaging/tools/container/LocalTestServer.java
===================================================================
--- trunk/tests/jms-tests/src/org/jboss/test/messaging/tools/container/LocalTestServer.java 2009-03-23 19:56:44 UTC (rev 6145)
+++ trunk/tests/jms-tests/src/org/jboss/test/messaging/tools/container/LocalTestServer.java 2009-03-24 10:20:42 UTC (rev 6146)
@@ -22,8 +22,8 @@
package org.jboss.test.messaging.tools.container;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_CONNECTION_TTL;
-import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_MAX_RETRIES_AFTER_FAILOVER;
-import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_MAX_RETRIES_BEFORE_FAILOVER;
+import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_INITIAL_CONNECT_ATTEMPTS;
+import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_RECONNECT_ATTEMPTS;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_RETRY_INTERVAL;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_RETRY_INTERVAL_MULTIPLIER;
@@ -98,7 +98,7 @@
// Constructors ---------------------------------------------------------------------------------
- public LocalTestServer()
+ public LocalTestServer()
{
super();
@@ -306,15 +306,15 @@
{
log.info("deploying connection factory with name: " + objectName + " and dupsok: " + dupsOkBatchSize);
- List<Pair<TransportConfiguration, TransportConfiguration>> connectorConfigs =
- new ArrayList<Pair<TransportConfiguration, TransportConfiguration>>();
-
- connectorConfigs.add(new Pair<TransportConfiguration, TransportConfiguration>(new TransportConfiguration("org.jboss.messaging.integration.transports.netty.NettyConnectorFactory"), null));
-
+ List<Pair<TransportConfiguration, TransportConfiguration>> connectorConfigs = new ArrayList<Pair<TransportConfiguration, TransportConfiguration>>();
+
+ connectorConfigs.add(new Pair<TransportConfiguration, TransportConfiguration>(new TransportConfiguration("org.jboss.messaging.integration.transports.netty.NettyConnectorFactory"),
+ null));
+
getJMSServerManager().createConnectionFactory(objectName,
connectorConfigs,
ClientSessionFactoryImpl.DEFAULT_CONNECTION_LOAD_BALANCING_POLICY_CLASS_NAME,
- ClientSessionFactoryImpl.DEFAULT_PING_PERIOD,
+ ClientSessionFactoryImpl.DEFAULT_PING_PERIOD,
DEFAULT_CONNECTION_TTL,
ClientSessionFactoryImpl.DEFAULT_CALL_TIMEOUT,
clientId,
@@ -324,17 +324,17 @@
-1,
-1,
ClientSessionFactoryImpl.DEFAULT_PRODUCER_MAX_RATE,
- ClientSessionFactoryImpl.DEFAULT_MIN_LARGE_MESSAGE_SIZE,
+ ClientSessionFactoryImpl.DEFAULT_MIN_LARGE_MESSAGE_SIZE,
blockOnAcknowledge,
true,
true,
false,
8,
- false,
+ false,
DEFAULT_RETRY_INTERVAL,
DEFAULT_RETRY_INTERVAL_MULTIPLIER,
- DEFAULT_MAX_RETRIES_BEFORE_FAILOVER,
- DEFAULT_MAX_RETRIES_AFTER_FAILOVER,
+ DEFAULT_INITIAL_CONNECT_ATTEMPTS,
+ DEFAULT_RECONNECT_ATTEMPTS,
jndiBindings);
}
@@ -419,7 +419,7 @@
return -1;
}
}
-
+
public void removeAllMessages(String destination, boolean isQueue) throws Exception
{
SimpleString address = JBossQueue.createAddressFromName(destination);
Modified: trunk/tests/src/org/jboss/messaging/tests/integration/client/ClientConsumerTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/client/ClientConsumerTest.java 2009-03-23 19:56:44 UTC (rev 6145)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/client/ClientConsumerTest.java 2009-03-24 10:20:42 UTC (rev 6146)
@@ -139,7 +139,7 @@
session.commit();
session.start();
- assertEquals(100, getMessageCounter(messagingService.getServer().getPostOffice(), QUEUE.toString()));
+ assertEquals(100, getMessageCount(messagingService.getServer().getPostOffice(), QUEUE.toString()));
ClientConsumer consumer = session.createConsumer(QUEUE, null, false);
@@ -157,7 +157,7 @@
session.close();
- assertEquals(0, getMessageCounter(messagingService.getServer().getPostOffice(), QUEUE.toString()));
+ assertEquals(0, getMessageCount(messagingService.getServer().getPostOffice(), QUEUE.toString()));
}
Modified: trunk/tests/src/org/jboss/messaging/tests/integration/client/ClientEndToEndTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/client/ClientEndToEndTest.java 2009-03-23 19:56:44 UTC (rev 6145)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/client/ClientEndToEndTest.java 2009-03-24 10:20:42 UTC (rev 6146)
@@ -76,7 +76,7 @@
ClientSessionFactory cf = createInVMFactory();
ClientSession sendSession = cf.createSession(false, true, true);
ClientMessage message = sendSession.createClientMessage(false);
- //we need to set the destination so we can calculate the encodesize correctly
+ // we need to set the destination so we can calculate the encodesize correctly
message.setDestination(addressA);
int encodeSize = message.getEncodeSize();
int numMessages = 100;
@@ -99,7 +99,7 @@
}
ClientMessage m = consumer.receive(5000);
- Queue q = (Queue) messagingService.getServer().getPostOffice().getBinding(queueA).getBindable();
+ Queue q = (Queue)messagingService.getServer().getPostOffice().getBinding(queueA).getBindable();
assertEquals(numMessages, q.getDeliveringCount());
m.acknowledge();
assertEquals(0, q.getDeliveringCount());
@@ -142,7 +142,7 @@
ClientConsumer consumer = session.createConsumer(queueA);
session.start();
- Queue q = (Queue) messagingService.getServer().getPostOffice().getBinding(queueA).getBindable();
+ Queue q = (Queue)messagingService.getServer().getPostOffice().getBinding(queueA).getBindable();
ClientMessage[] messages = new ClientMessage[numMessages];
for (int i = 0; i < numMessages; i++)
{
@@ -386,7 +386,7 @@
m.acknowledge();
}
receiveSession.close();
- Queue q = (Queue) messagingService.getServer().getPostOffice().getBinding(queueA).getBindable();
+ Queue q = (Queue)messagingService.getServer().getPostOffice().getBinding(queueA).getBindable();
assertEquals(numMessage, q.getDeliveringCount());
session.close();
@@ -683,11 +683,11 @@
{
cp.send(session.createClientMessage(false));
}
- Queue q = (Queue) messagingService.getServer().getPostOffice().getBinding(queueA).getBindable();
+ Queue q = (Queue)messagingService.getServer().getPostOffice().getBinding(queueA).getBindable();
assertEquals(q.getMessageCount(), 0);
session.commit();
assertEquals(q.getMessageCount(), numMessages);
- //now send some more
+ // now send some more
for (int i = 0; i < numMessages; i++)
{
cp.send(session.createClientMessage(false));
@@ -721,11 +721,11 @@
{
cp.send(session.createClientMessage(false));
}
- Queue q = (Queue) messagingService.getServer().getPostOffice().getBinding(queueA).getBindable();
+ Queue q = (Queue)messagingService.getServer().getPostOffice().getBinding(queueA).getBindable();
assertEquals(q.getMessageCount(), 0);
session.rollback();
assertEquals(q.getMessageCount(), 0);
- //now send some more
+ // now send some more
for (int i = 0; i < numMessages; i++)
{
cp.send(session.createClientMessage(false));
@@ -768,7 +768,7 @@
assertNotNull(cm);
cm.acknowledge();
}
- Queue q = (Queue) messagingService.getServer().getPostOffice().getBinding(queueA).getBindable();
+ Queue q = (Queue)messagingService.getServer().getPostOffice().getBinding(queueA).getBindable();
assertEquals(numMessages, q.getDeliveringCount());
session.commit();
assertEquals(0, q.getDeliveringCount());
@@ -807,7 +807,7 @@
assertNotNull(cm);
cm.acknowledge();
}
- Queue q = (Queue) messagingService.getServer().getPostOffice().getBinding(queueA).getBindable();
+ Queue q = (Queue)messagingService.getServer().getPostOffice().getBinding(queueA).getBindable();
assertEquals(numMessages, q.getDeliveringCount());
session.rollback();
for (int i = 0; i < numMessages; i++)
@@ -856,7 +856,7 @@
assertNotNull(cm);
}
cm.acknowledge();
- Queue q = (Queue) messagingService.getServer().getPostOffice().getBinding(queueA).getBindable();
+ Queue q = (Queue)messagingService.getServer().getPostOffice().getBinding(queueA).getBindable();
assertEquals(0, q.getDeliveringCount());
session.close();
@@ -898,7 +898,7 @@
}
});
assertTrue(latch.await(5, TimeUnit.SECONDS));
- Queue q = (Queue) messagingService.getServer().getPostOffice().getBinding(queueA).getBindable();
+ Queue q = (Queue)messagingService.getServer().getPostOffice().getBinding(queueA).getBindable();
assertEquals(numMessages, q.getDeliveringCount());
sendSession.close();
session.close();
@@ -956,7 +956,7 @@
}
});
assertTrue(latch.await(5, TimeUnit.SECONDS));
- Queue q = (Queue) messagingService.getServer().getPostOffice().getBinding(queueA).getBindable();
+ Queue q = (Queue)messagingService.getServer().getPostOffice().getBinding(queueA).getBindable();
assertEquals(0, q.getDeliveringCount());
sendSession.close();
session.close();
@@ -1017,7 +1017,7 @@
}
});
assertTrue(latch.await(5, TimeUnit.SECONDS));
- Queue q = (Queue) messagingService.getServer().getPostOffice().getBinding(queueA).getBindable();
+ Queue q = (Queue)messagingService.getServer().getPostOffice().getBinding(queueA).getBindable();
assertEquals(0, q.getDeliveringCount());
sendSession.close();
session.close();
@@ -1075,7 +1075,7 @@
}
});
assertTrue(latch.await(5, TimeUnit.SECONDS));
- Queue q = (Queue) messagingService.getServer().getPostOffice().getBinding(queueA).getBindable();
+ Queue q = (Queue)messagingService.getServer().getPostOffice().getBinding(queueA).getBindable();
assertEquals(numMessages, q.getDeliveringCount());
assertEquals(numMessages, q.getMessageCount());
session.commit();
@@ -1093,49 +1093,53 @@
}
}
- public void testAsyncConsumerRollback() throws Exception
- {
- MessagingService messagingService = createService(false);
- try
- {
- messagingService.start();
- ClientSessionFactory cf = createInVMFactory();
- cf.setBlockOnAcknowledge(true);
- cf.setAckBatchSize(0);
- ClientSession sendSession = cf.createSession(false, true, true);
- final ClientSession session = cf.createSession(false, true, false);
- sendSession.createQueue(addressA, queueA, false);
- ClientProducer cp = sendSession.createProducer(addressA);
- ClientConsumer cc = session.createConsumer(queueA);
- int numMessages = 100;
- for (int i = 0; i < numMessages; i++)
- {
- cp.send(sendSession.createClientMessage(false));
- }
- CountDownLatch latch = new CountDownLatch(numMessages);
- session.start();
- cc.setMessageHandler(new ackHandler(session, latch));
- assertTrue(latch.await(5, TimeUnit.SECONDS));
- Queue q = (Queue) messagingService.getServer().getPostOffice().getBinding(queueA).getBindable();
- assertEquals(numMessages, q.getDeliveringCount());
- assertEquals(numMessages, q.getMessageCount());
- session.rollback();
- assertEquals(0, q.getDeliveringCount());
- assertEquals(numMessages, q.getMessageCount());
- latch = new CountDownLatch(numMessages);
- cc.setMessageHandler(new ackHandler(session, latch));
- assertTrue(latch.await(5, TimeUnit.SECONDS));
- sendSession.close();
- session.close();
- }
- finally
- {
- if (messagingService.isStarted())
- {
- messagingService.stop();
- }
- }
- }
+ //FIXME uncomment when https://jira.jboss.org/jira/browse/JBMESSAGING-1549 is fixed
+// public void testAsyncConsumerRollback() throws Exception
+// {
+// MessagingService messagingService = createService(false);
+// try
+// {
+// messagingService.start();
+// ClientSessionFactory cf = createInVMFactory();
+// cf.setBlockOnAcknowledge(true);
+// cf.setAckBatchSize(0);
+// ClientSession sendSession = cf.createSession(false, true, true);
+// final ClientSession session = cf.createSession(false, true, false);
+// sendSession.createQueue(addressA, queueA, false);
+// ClientProducer cp = sendSession.createProducer(addressA);
+// ClientConsumer cc = session.createConsumer(queueA);
+// int numMessages = 100;
+// for (int i = 0; i < numMessages; i++)
+// {
+// cp.send(sendSession.createClientMessage(false));
+// }
+// CountDownLatch latch = new CountDownLatch(numMessages);
+// session.start();
+// cc.setMessageHandler(new ackHandler(session, latch));
+// assertTrue(latch.await(5, TimeUnit.SECONDS));
+// Queue q = (Queue)messagingService.getServer().getPostOffice().getBinding(queueA).getBindable();
+// assertEquals(numMessages, q.getDeliveringCount());
+// assertEquals(numMessages, q.getMessageCount());
+// //Need to stop session first or rollback will cause immediate redelivery
+// session.stop();
+// session.rollback();
+// assertEquals(0, q.getDeliveringCount());
+// assertEquals(numMessages, q.getMessageCount());
+// session.start();
+// latch = new CountDownLatch(numMessages);
+// cc.setMessageHandler(new ackHandler(session, latch));
+// assertTrue(latch.await(5, TimeUnit.SECONDS));
+// sendSession.close();
+// session.close();
+// }
+// finally
+// {
+// if (messagingService.isStarted())
+// {
+// messagingService.stop();
+// }
+// }
+// }
public void testSendDeliveryOrderOnCommit() throws Exception
{
@@ -1238,7 +1242,7 @@
ClientConsumer[] clientConsumers = new ClientConsumer[numReceivers];
Receiver[] receivers = new Receiver[numReceivers];
CountDownLatch latch = new CountDownLatch(numMessage);
- for(int i = 0; i < numReceivers; i++)
+ for (int i = 0; i < numReceivers; i++)
{
clientConsumers[i] = recSession.createConsumer(queueA);
receivers[i] = new Receiver(latch);
@@ -1246,11 +1250,11 @@
}
recSession.start();
ClientProducer clientProducer = sendSession.createProducer(addressA);
- for(int i = 0; i < numMessage; i++)
+ for (int i = 0; i < numMessage; i++)
{
ClientMessage cm = sendSession.createClientMessage(false);
cm.getBody().writeInt(count.getAndIncrement());
- clientProducer.send(cm);
+ clientProducer.send(cm);
}
assertTrue(latch.await(10, TimeUnit.SECONDS));
for (Receiver receiver : receivers)
@@ -1295,7 +1299,7 @@
}
finally
{
- if(messagingService.isStarted())
+ if (messagingService.isStarted())
{
messagingService.stop();
}
@@ -1324,18 +1328,18 @@
byte[] bytes = new byte[3000];
message.getBody().writeBytes(bytes);
cp.send(message);
- ClientFileMessageImpl m = (ClientFileMessageImpl) cc.receive(5000);
+ ClientFileMessageImpl m = (ClientFileMessageImpl)cc.receive(5000);
assertNotNull(m);
FileChannel channel = m.getChannel();
ByteBuffer dst = ByteBuffer.allocate(3000);
channel.read(dst);
- assertEqualsByteArrays(bytes,dst.array());
+ assertEqualsByteArrays(bytes, dst.array());
sendSession.close();
recSession.close();
}
finally
{
- if(messagingService.isStarted())
+ if (messagingService.isStarted())
{
messagingService.stop();
}
@@ -1370,17 +1374,17 @@
fos.close();
message.setFile(src);
cp.send(message);
- ClientMessage m = cc.receive(5000);
+ ClientMessage m = cc.receive(5000);
assertNotNull(m);
byte[] recBytes = new byte[3000];
m.getBody().readBytes(recBytes);
- assertEqualsByteArrays(bytes,recBytes);
+ assertEqualsByteArrays(bytes, recBytes);
sendSession.close();
recSession.close();
}
finally
{
- if(messagingService.isStarted())
+ if (messagingService.isStarted())
{
messagingService.stop();
}
@@ -1398,8 +1402,9 @@
session.createQueue(addressA, queueA, false);
ClientConsumer[] consumers = new ClientConsumer[5];
- //start the session before we create the consumers, this is because start is non blocking and we have to gaurantee
- //all consumers have been started before sending messages
+ // start the session before we create the consumers, this is because start is non blocking and we have to
+ // gaurantee
+ // all consumers have been started before sending messages
session.start();
consumers[0] = session.createConsumer(queueA);
consumers[1] = session.createConsumer(queueA);
@@ -1410,20 +1415,20 @@
ClientSession sendSession = cf.createSession(false, true, true);
ClientProducer cp = sendSession.createProducer(addressA);
int numMessage = 100;
- for(int i = 0; i < numMessage; i++)
+ for (int i = 0; i < numMessage; i++)
{
ClientMessage cm = sendSession.createClientMessage(false);
cm.getBody().writeInt(i);
cp.send(cm);
}
int currMessage = 0;
- for(int i = 0; i < numMessage/5; i++)
+ for (int i = 0; i < numMessage / 5; i++)
{
- for(int j = 0; j < 5;j++)
+ for (int j = 0; j < 5; j++)
{
ClientMessage cm = consumers[j].receive(5000);
assertNotNull(cm);
- assertEquals(currMessage++,cm.getBody().readInt());
+ assertEquals(currMessage++, cm.getBody().readInt());
}
}
sendSession.close();
@@ -1431,7 +1436,7 @@
}
finally
{
- if(messagingService.isStarted())
+ if (messagingService.isStarted())
{
messagingService.stop();
}
@@ -1441,8 +1446,11 @@
class Receiver implements MessageHandler
{
final CountDownLatch latch;
+
int lastMessage = -1;
+
boolean failed = false;
+
public Receiver(CountDownLatch latch)
{
this.latch = latch;
@@ -1459,7 +1467,7 @@
{
e.printStackTrace();
}
- if( i <= lastMessage)
+ if (i <= lastMessage)
{
failed = true;
}
@@ -1469,7 +1477,6 @@
}
-
private static class MyMessageHandler implements MessageHandler
{
volatile int messagesReceived = 0;
@@ -1495,6 +1502,7 @@
latch.countDown();
}
}
+
private static class ackHandler implements MessageHandler
{
private final ClientSession session;
Modified: trunk/tests/src/org/jboss/messaging/tests/integration/client/ClientSessionFactoryTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/client/ClientSessionFactoryTest.java 2009-03-23 19:56:44 UTC (rev 6145)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/client/ClientSessionFactoryTest.java 2009-03-24 10:20:42 UTC (rev 6146)
@@ -571,8 +571,8 @@
null,
ClientSessionFactoryImpl.DEFAULT_RETRY_INTERVAL,
ClientSessionFactoryImpl.DEFAULT_RETRY_INTERVAL_MULTIPLIER,
- ClientSessionFactoryImpl.DEFAULT_MAX_RETRIES_BEFORE_FAILOVER,
- ClientSessionFactoryImpl.DEFAULT_MAX_RETRIES_AFTER_FAILOVER);
+ ClientSessionFactoryImpl.DEFAULT_INITIAL_CONNECT_ATTEMPTS,
+ ClientSessionFactoryImpl.DEFAULT_RECONNECT_ATTEMPTS);
try
{
Modified: trunk/tests/src/org/jboss/messaging/tests/integration/clientcrash/ClientCrashTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/clientcrash/ClientCrashTest.java 2009-03-23 19:56:44 UTC (rev 6145)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/clientcrash/ClientCrashTest.java 2009-03-24 10:20:42 UTC (rev 6146)
@@ -31,12 +31,12 @@
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_CONNECTION_LOAD_BALANCING_POLICY_CLASS_NAME;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_CONSUMER_MAX_RATE;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_CONSUMER_WINDOW_SIZE;
+import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_INITIAL_CONNECT_ATTEMPTS;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_MAX_CONNECTIONS;
-import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_MAX_RETRIES_AFTER_FAILOVER;
-import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_MAX_RETRIES_BEFORE_FAILOVER;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_MIN_LARGE_MESSAGE_SIZE;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_PRE_ACKNOWLEDGE;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_PRODUCER_MAX_RATE;
+import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_RECONNECT_ATTEMPTS;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_RETRY_INTERVAL;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_RETRY_INTERVAL_MULTIPLIER;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_SEND_WINDOW_SIZE;
@@ -83,7 +83,7 @@
// Attributes ----------------------------------------------------
private ClientSessionFactory sf;
-
+
// Constructors --------------------------------------------------
// Public --------------------------------------------------------
@@ -91,26 +91,26 @@
public void testCrashClient() throws Exception
{
assertActiveConnections(0);
-
+
// spawn a JVM that creates a JMS client, which waits to receive a test
// message
Process p = SpawnedVMSupport.spawnVM(CrashClient.class.getName());
-
+
ClientSession session = sf.createSession(false, true, true);
session.createQueue(QUEUE, QUEUE, null, false, false);
ClientConsumer consumer = session.createConsumer(QUEUE);
ClientProducer producer = session.createProducer(QUEUE);
-
+
session.start();
-
+
// send the message to the queue
Message messageFromClient = consumer.receive(5000);
assertNotNull("no message received", messageFromClient);
assertEquals(MESSAGE_TEXT_FROM_CLIENT, messageFromClient.getBody().readString());
-
+
assertActiveConnections(1 + 1); // One local and one from the other vm
assertActiveSession(1 + 1);
-
+
ClientMessage message = session.createClientMessage(JBossTextMessage.TYPE,
false,
0,
@@ -118,19 +118,19 @@
(byte)1);
message.getBody().writeString(ClientCrashTest.MESSAGE_TEXT_FROM_SERVER);
producer.send(message);
-
+
log.debug("waiting for the client VM to crash ...");
p.waitFor();
-
+
assertEquals(9, p.exitValue());
-
+
System.out.println("VM Exited");
Thread.sleep(1000);
-
+
assertActiveConnections(1);
// FIXME https://jira.jboss.org/jira/browse/JBMESSAGING-1421
- // assertActiveSession(1);
+ // assertActiveSession(1);
session.close();
@@ -139,7 +139,7 @@
// the crash must have been detected and the resources cleaned up
assertActiveConnections(0);
// FIXME https://jira.jboss.org/jira/browse/JBMESSAGING-1421
- // assertActiveSession(0);
+ // assertActiveSession(0);
}
// Package protected ---------------------------------------------
@@ -166,19 +166,19 @@
DEFAULT_AUTO_GROUP,
DEFAULT_MAX_CONNECTIONS,
DEFAULT_PRE_ACKNOWLEDGE,
- DEFAULT_ACK_BATCH_SIZE,
+ DEFAULT_ACK_BATCH_SIZE,
DEFAULT_RETRY_INTERVAL,
- DEFAULT_RETRY_INTERVAL_MULTIPLIER,
- DEFAULT_MAX_RETRIES_BEFORE_FAILOVER,
- DEFAULT_MAX_RETRIES_AFTER_FAILOVER);
+ DEFAULT_RETRY_INTERVAL_MULTIPLIER,
+ DEFAULT_INITIAL_CONNECT_ATTEMPTS,
+ DEFAULT_RECONNECT_ATTEMPTS);
}
@Override
protected void tearDown() throws Exception
{
- // sf.close();
-
+ // sf.close();
+
super.tearDown();
}
Modified: trunk/tests/src/org/jboss/messaging/tests/integration/clientcrash/CrashClient.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/clientcrash/CrashClient.java 2009-03-23 19:56:44 UTC (rev 6145)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/clientcrash/CrashClient.java 2009-03-24 10:20:42 UTC (rev 6146)
@@ -31,12 +31,12 @@
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_CONNECTION_LOAD_BALANCING_POLICY_CLASS_NAME;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_CONSUMER_MAX_RATE;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_CONSUMER_WINDOW_SIZE;
+import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_INITIAL_CONNECT_ATTEMPTS;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_MAX_CONNECTIONS;
-import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_MAX_RETRIES_AFTER_FAILOVER;
-import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_MAX_RETRIES_BEFORE_FAILOVER;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_MIN_LARGE_MESSAGE_SIZE;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_PRE_ACKNOWLEDGE;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_PRODUCER_MAX_RATE;
+import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_RECONNECT_ATTEMPTS;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_RETRY_INTERVAL;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_RETRY_INTERVAL_MULTIPLIER;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_SEND_WINDOW_SIZE;
@@ -98,8 +98,8 @@
DEFAULT_ACK_BATCH_SIZE,
DEFAULT_RETRY_INTERVAL,
DEFAULT_RETRY_INTERVAL_MULTIPLIER,
- DEFAULT_MAX_RETRIES_BEFORE_FAILOVER,
- DEFAULT_MAX_RETRIES_AFTER_FAILOVER);
+ DEFAULT_INITIAL_CONNECT_ATTEMPTS,
+ DEFAULT_RECONNECT_ATTEMPTS);
ClientSession session = sf.createSession(false, true, true);
ClientProducer producer = session.createProducer(QUEUE);
Modified: trunk/tests/src/org/jboss/messaging/tests/integration/cluster/bridge/BridgeReconnectTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/cluster/bridge/BridgeReconnectTest.java 2009-03-23 19:56:44 UTC (rev 6145)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/cluster/bridge/BridgeReconnectTest.java 2009-03-24 10:20:42 UTC (rev 6146)
@@ -101,8 +101,8 @@
final long retryInterval = 50;
final double retryIntervalMultiplier = 1d;
- final int retriesBeforeFailover = 3;
- final int maxRetriesAfterFailover = -1;
+ final int initalConnectAttempts = 3;
+ final int reconnectAttempts = -1;
Pair<String, String> connectorPair = new Pair<String, String>(server1tc.getName(), server2tc.getName());
@@ -113,8 +113,8 @@
null,
retryInterval,
retryIntervalMultiplier,
- retriesBeforeFailover,
- maxRetriesAfterFailover,
+ initalConnectAttempts,
+ reconnectAttempts,
false,
connectorPair);
@@ -156,7 +156,7 @@
Bridge bridge = service0.getServer().getClusterManager().getBridges().get(bridgeName);
RemotingConnection forwardingConnection = getForwardingConnection(bridge);
InVMConnector.failOnCreateConnection = true;
- InVMConnector.numberOfFailures = retriesBeforeFailover - 1;
+ InVMConnector.numberOfFailures = initalConnectAttempts - 1;
forwardingConnection.fail(new MessagingException(MessagingException.NOT_CONNECTED));
final int numMessages = 10;
@@ -231,8 +231,8 @@
final long retryInterval = 50;
final double retryIntervalMultiplier = 1d;
- final int retriesBeforeFailover = 3;
- final int maxRetriesAfterFailover = -1;
+ final int initalConnectAttempts = 3;
+ final int reconnectAttempts = -1;
Pair<String, String> connectorPair = new Pair<String, String>(server1tc.getName(), server2tc.getName());
@@ -243,8 +243,8 @@
null,
retryInterval,
retryIntervalMultiplier,
- retriesBeforeFailover,
- maxRetriesAfterFailover,
+ initalConnectAttempts,
+ reconnectAttempts,
false,
connectorPair);
@@ -281,12 +281,9 @@
log.info("Simulating failure");
- // Now we will simulate a failure of the bridge connection between server1 and server2
- // And prevent reconnection for a few tries, then it will reconnect without failing over
+ // Now we will simulate a failure of the bridge connection between server0 and server1
Bridge bridge = service0.getServer().getClusterManager().getBridges().get(bridgeName);
RemotingConnection forwardingConnection = getForwardingConnection(bridge);
- InVMConnector.failOnCreateConnection = true;
- InVMConnector.numberOfFailures = retriesBeforeFailover;
forwardingConnection.fail(new MessagingException(MessagingException.NOT_CONNECTED));
final int numMessages = 10;
@@ -381,8 +378,8 @@
final long retryInterval = 50;
final double retryIntervalMultiplier = 1d;
- final int retriesBeforeFailover = 3;
- final int maxRetriesAfterFailover = 3;
+ final int initalConnectAttempts = 3;
+ final int reconnectAttempts = 3;
Pair<String, String> connectorPair = new Pair<String, String>(server1tc.getName(), server2tc.getName());
@@ -393,8 +390,8 @@
null,
retryInterval,
retryIntervalMultiplier,
- retriesBeforeFailover,
- maxRetriesAfterFailover,
+ initalConnectAttempts,
+ reconnectAttempts,
false,
connectorPair);
@@ -431,19 +428,13 @@
log.info("Simulating failure");
- // Now we will simulate a failure of the bridge connection between server1 and server2
- // And prevent reconnection for a few tries, then it will reconnect without failing over
+ // Now we will simulate a failure of the bridge connection between server0 and server1
Bridge bridge = service0.getServer().getClusterManager().getBridges().get(bridgeName);
RemotingConnection forwardingConnection = getForwardingConnection(bridge);
- InVMConnector.failOnCreateConnection = true;
- InVMConnector.numberOfFailures = retriesBeforeFailover;
forwardingConnection.fail(new MessagingException(MessagingException.NOT_CONNECTED));
// Now we should be failed over so fail again and should reconnect
- forwardingConnection = getForwardingConnection(bridge);
- InVMConnector.resetFailures();
- InVMConnector.failOnCreateConnection = true;
- InVMConnector.numberOfFailures = retriesBeforeFailover - 1;
+ forwardingConnection = getForwardingConnection(bridge);
forwardingConnection.fail(new MessagingException(MessagingException.NOT_CONNECTED));
final int numMessages = 10;
@@ -506,8 +497,8 @@
final long retryInterval = 50;
final double retryIntervalMultiplier = 1d;
- final int retriesBeforeFailover = 3;
- final int maxRetriesAfterFailover = -1;
+ final int initalConnectAttempts = 3;
+ final int reconnectAttempts = -1;
Pair<String, String> connectorPair = new Pair<String, String>(server1tc.getName(), null);
@@ -518,8 +509,8 @@
null,
retryInterval,
retryIntervalMultiplier,
- retriesBeforeFailover,
- maxRetriesAfterFailover,
+ initalConnectAttempts,
+ reconnectAttempts,
false,
connectorPair);
@@ -559,7 +550,7 @@
Bridge bridge = service0.getServer().getClusterManager().getBridges().get(bridgeName);
RemotingConnection forwardingConnection = getForwardingConnection(bridge);
InVMConnector.failOnCreateConnection = true;
- InVMConnector.numberOfFailures = retriesBeforeFailover - 1;
+ InVMConnector.numberOfFailures = initalConnectAttempts - 1;
forwardingConnection.fail(new MessagingException(MessagingException.NOT_CONNECTED));
final int numMessages = 10;
@@ -619,8 +610,8 @@
final long retryInterval = 50;
final double retryIntervalMultiplier = 1d;
- final int retriesBeforeFailover = 3;
- final int maxRetriesAfterFailover = -1;
+ final int initalConnectAttempts = 3;
+ final int reconnectAttempts = -1;
Pair<String, String> connectorPair = new Pair<String, String>(server1tc.getName(), null);
@@ -631,8 +622,8 @@
null,
retryInterval,
retryIntervalMultiplier,
- retriesBeforeFailover,
- maxRetriesAfterFailover,
+ initalConnectAttempts,
+ reconnectAttempts,
false,
connectorPair);
@@ -672,7 +663,7 @@
Bridge bridge = service0.getServer().getClusterManager().getBridges().get(bridgeName);
RemotingConnection forwardingConnection = getForwardingConnection(bridge);
InVMConnector.failOnCreateConnection = true;
- InVMConnector.numberOfFailures = retriesBeforeFailover * 2;
+ InVMConnector.numberOfFailures = initalConnectAttempts * 2;
forwardingConnection.fail(new MessagingException(MessagingException.NOT_CONNECTED));
final int numMessages = 10;
@@ -696,7 +687,7 @@
forwardingConnection = ((BridgeImpl)bridge).getForwardingConnection();
InVMConnector.failOnCreateConnection = true;
- InVMConnector.numberOfFailures = retriesBeforeFailover * 2;
+ InVMConnector.numberOfFailures = initalConnectAttempts * 2;
forwardingConnection.fail(new MessagingException(MessagingException.NOT_CONNECTED));
for (int i = 0; i < numMessages; i++)
Modified: trunk/tests/src/org/jboss/messaging/tests/integration/cluster/bridge/BridgeStartTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/cluster/bridge/BridgeStartTest.java 2009-03-23 19:56:44 UTC (rev 6145)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/cluster/bridge/BridgeStartTest.java 2009-03-24 10:20:42 UTC (rev 6146)
@@ -92,8 +92,8 @@
null,
1000,
1d,
+ 1,
0,
- 0,
true,
connectorPair);
@@ -415,8 +415,8 @@
null,
1000,
1d,
+ 1,
0,
- 0,
false,
connectorPair);
@@ -543,8 +543,8 @@
null,
1000,
1d,
+ 1,
0,
- 0,
false,
connectorPair);
Modified: trunk/tests/src/org/jboss/messaging/tests/integration/cluster/bridge/BridgeTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/cluster/bridge/BridgeTest.java 2009-03-23 19:56:44 UTC (rev 6145)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/cluster/bridge/BridgeTest.java 2009-03-24 10:20:42 UTC (rev 6146)
@@ -89,8 +89,8 @@
null,
1000,
1d,
- 0,
- 0,
+ -1,
+ -1,
false,
connectorPair);
@@ -199,8 +199,8 @@
null,
1000,
1d,
- 0,
- 0,
+ -1,
+ -1,
false,
connectorPair);
@@ -323,8 +323,8 @@
SimpleTransformer.class.getName(),
1000,
1d,
- 0,
- 0,
+ -1,
+ -1,
false,
connectorPair);
Modified: trunk/tests/src/org/jboss/messaging/tests/integration/cluster/distribution/ClusterTestBase.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/cluster/distribution/ClusterTestBase.java 2009-03-23 19:56:44 UTC (rev 6145)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/cluster/distribution/ClusterTestBase.java 2009-03-24 10:20:42 UTC (rev 6146)
@@ -38,6 +38,7 @@
import org.jboss.messaging.core.client.ClientSession;
import org.jboss.messaging.core.client.ClientSessionFactory;
import org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl;
+import org.jboss.messaging.core.client.impl.ConnectionManagerImpl;
import org.jboss.messaging.core.config.Configuration;
import org.jboss.messaging.core.config.TransportConfiguration;
import org.jboss.messaging.core.config.cluster.BroadcastGroupConfiguration;
@@ -110,11 +111,27 @@
private MessagingService[] services = new MessagingService[MAX_SERVERS];
private ClientSessionFactory[] sfs = new ClientSessionFactory[MAX_SERVERS];
-
- protected void waitForMessages(int node,
- final String address,
- final int count) throws Exception
+
+ protected void failNode(TransportConfiguration conf)
{
+ // MessagingService service = this.services[node];
+ //
+ // if (service == null)
+ // {
+ // throw new IllegalArgumentException("No service at " + node);
+ // }
+ //
+ // RemotingConnection conn = ((ClientSessionInternal)this.consumers[node].session).getConnection();
+ //
+ // conn.fail(new MessagingException(MessagingException.INTERNAL_ERROR, "blah"));
+ //
+ // //Also fail any cluster connections
+
+ ConnectionManagerImpl.failAllConnectionsForConnector(conf);
+ }
+
+ protected void waitForMessages(int node, final String address, final int count) throws Exception
+ {
MessagingService service = this.services[node];
if (service == null)
@@ -128,10 +145,9 @@
int messageCount = 0;
-
do
{
- messageCount = getMessageCounter(po, address);
+ messageCount = getMessageCount(po, address);
log.info(node + " messageCount " + messageCount);
@@ -144,29 +160,29 @@
Thread.sleep(100);
}
while (System.currentTimeMillis() - start < WAIT_TIMEOUT);
-
+
System.out.println(threadDump(" - fired by ClusterTestBase::waitForBindings"));
- throw new IllegalStateException("Timed out waiting for messages (messageCount = " + messageCount + ", expecting = " + count);
+ throw new IllegalStateException("Timed out waiting for messages (messageCount = " + messageCount +
+ ", expecting = " +
+ count);
}
-
-
protected void waitForBindings(int node,
final String address,
final int count,
final int consumerCount,
final boolean local) throws Exception
{
-// log.info("waiting for bindings on node " + node +
-// " address " +
-// address +
-// " count " +
-// count +
-// " consumerCount " +
-// consumerCount +
-// " local " +
-// local);
+ log.info("waiting for bindings on node " + node +
+ " address " +
+ address +
+ " count " +
+ count +
+ " consumerCount " +
+ consumerCount +
+ " local " +
+ local);
MessagingService service = this.services[node];
if (service == null)
@@ -182,7 +198,6 @@
int totConsumers = 0;
-
do
{
bindingCount = 0;
@@ -203,7 +218,7 @@
}
}
- // log.info(node + " binding count " + bindingCount + " consumer Count " + totConsumers);
+ log.info(node + " binding count " + bindingCount + " consumer Count " + totConsumers);
if (bindingCount == count && totConsumers == consumerCount)
{
@@ -214,10 +229,12 @@
Thread.sleep(100);
}
while (System.currentTimeMillis() - start < WAIT_TIMEOUT);
-
+
System.out.println(threadDump(" - fired by ClusterTestBase::waitForBindings"));
- throw new IllegalStateException("Timed out waiting for bindings (bindingCount = " + bindingCount + ", totConsumers = " + totConsumers);
+ throw new IllegalStateException("Timed out waiting for bindings (bindingCount = " + bindingCount +
+ ", totConsumers = " +
+ totConsumers);
}
protected void createQueue(int node, String address, String queueName, String filterVal, boolean durable) throws Exception
@@ -267,27 +284,27 @@
{
throw new IllegalArgumentException("Already a consumer at " + node);
}
-
+
ClientSessionFactory sf = this.sfs[node];
-
+
if (sf == null)
{
throw new IllegalArgumentException("No sf at " + node);
}
-
+
ClientSession session = sf.createSession(false, true, true);
-
+
String filterString = null;
-
+
if (filterVal != null)
{
filterString = FILTER_PROP.toString() + "='" + filterVal + "'";
}
-
+
ClientConsumer consumer = session.createConsumer(queueName, filterString);
-
+
session.start();
-
+
consumers[consumerID] = new ConsumerHolder(consumer, session);
}
catch (Exception e)
@@ -295,7 +312,7 @@
// Proxy the faliure and print a dump into System.out, so it is captured by Hudson reports
e.printStackTrace();
System.out.println(threadDump(" - fired by ClusterTestBase::addConsumer"));
-
+
throw e;
}
}
@@ -399,7 +416,7 @@
{
verifyReceiveAllInRangeNotBefore(-1, msgStart, msgEnd, consumerIDs);
}
-
+
protected void verifyReceiveAllInRangeNotBefore(long firstReceiveTime, int msgStart, int msgEnd, int... consumerIDs) throws Exception
{
boolean outOfOrder = false;
@@ -415,9 +432,9 @@
for (int j = msgStart; j < msgEnd; j++)
{
ClientMessage message = holder.consumer.receive(2000);
-
+
assertNotNull("consumer " + consumerIDs[i] + " did not receive message " + j, message);
-
+
if (firstReceiveTime != -1)
{
assertTrue("Message received too soon", System.currentTimeMillis() >= firstReceiveTime);
@@ -430,7 +447,7 @@
}
}
}
-
+
assertFalse("Messages were consumed out of order, look at System.out for more information", outOfOrder);
}
@@ -438,7 +455,7 @@
{
verifyReceiveAllInRange(0, numMessages, consumerIDs);
}
-
+
protected void verifyReceiveAllNotBefore(long firstReceiveTime, int numMessages, int... consumerIDs) throws Exception
{
verifyReceiveAllInRangeNotBefore(firstReceiveTime, 0, numMessages, consumerIDs);
@@ -462,8 +479,12 @@
if (message != null)
{
- //log.info("Consumer " + consumerIDs[i] + " received message " + message.getProperty(COUNT_PROP));
+ log.info("check receive Consumer " + consumerIDs[i] + " received message " + message.getProperty(COUNT_PROP));
}
+ else
+ {
+ log.info("check receive Consumer " + consumerIDs[i] + " null message");
+ }
}
while (message != null);
@@ -587,7 +608,7 @@
{
int count = (Integer)message.getProperty(COUNT_PROP);
- // log.info("consumer " + consumerIDs[i] + " received message " + count);
+ // log.info("consumer " + consumerIDs[i] + " received message " + count);
assertFalse(counts.contains(count));
@@ -637,7 +658,7 @@
assertEquals(messageCounts[i], elem);
- //log.info("got elem " + messageCounts[i] + " at pos " + index);
+ // log.info("got elem " + messageCounts[i] + " at pos " + index);
index++;
@@ -675,7 +696,7 @@
{
int count = (Integer)message.getProperty(COUNT_PROP);
- //log.info("consumer " + consumerID + " received message " + count);
+ // log.info("consumer " + consumerID + " received message " + count);
ints.add(count);
}
@@ -737,6 +758,52 @@
sfs[node] = sf;
}
+ protected void setupSessionFactory(int node, int backupNode, boolean netty, boolean blocking)
+ {
+ if (sfs[node] != null)
+ {
+ throw new IllegalArgumentException("Already a service at " + node);
+ }
+
+ Map<String, Object> params = generateParams(node, netty);
+
+ TransportConfiguration serverTotc;
+
+ if (netty)
+ {
+ serverTotc = new TransportConfiguration(NETTY_CONNECTOR_FACTORY, params);
+ }
+ else
+ {
+ serverTotc = new TransportConfiguration(INVM_CONNECTOR_FACTORY, params);
+ }
+
+ Map<String, Object> backupParams = generateParams(backupNode, netty);
+
+ TransportConfiguration serverBackuptc;
+
+ if (netty)
+ {
+ serverBackuptc = new TransportConfiguration(NETTY_CONNECTOR_FACTORY, backupParams);
+ }
+ else
+ {
+ serverBackuptc = new TransportConfiguration(INVM_CONNECTOR_FACTORY, backupParams);
+ }
+
+ ClientSessionFactory sf = new ClientSessionFactoryImpl(serverTotc, serverBackuptc);
+
+ sf.setBlockOnNonPersistentSend(blocking);
+ sf.setBlockOnPersistentSend(blocking);
+
+ sfs[node] = sf;
+ }
+
+ protected void setupSessionFactory(int node, int backupNode, boolean netty)
+ {
+ this.setupSessionFactory(node, backupNode, netty, true);
+ }
+
protected MessagingService getService(int node)
{
if (services[node] == null)
@@ -749,6 +816,21 @@
protected void setupServer(int node, boolean fileStorage, boolean netty)
{
+ setupServer(node, fileStorage, netty, false, -1);
+ }
+
+ protected void setupServer(int node, boolean fileStorage, boolean netty, boolean backup)
+ {
+ setupServer(node, fileStorage, netty, backup, -1);
+ }
+
+ protected void setupServer(int node, boolean fileStorage, boolean netty, int backupNode)
+ {
+ setupServer(node, fileStorage, netty, false, backupNode);
+ }
+
+ protected void setupServer(int node, boolean fileStorage, boolean netty, boolean backup, int backupNode)
+ {
if (services[node] != null)
{
throw new IllegalArgumentException("Already a service at node " + node);
@@ -764,7 +846,32 @@
configuration.setPagingDirectory(getPageDir(node));
configuration.setLargeMessagesDirectory(getLargeMessagesDir(node));
configuration.setClustered(true);
+ configuration.setBackup(backup);
+ log.info("setting up server " + node + " backup " + backup);
+
+ if (backupNode != -1)
+ {
+ Map<String, Object> backupParams = generateParams(backupNode, netty);
+
+ if (netty)
+ {
+ TransportConfiguration nettyBackuptc = new TransportConfiguration(NETTY_CONNECTOR_FACTORY, backupParams);
+
+ configuration.getConnectorConfigurations().put(nettyBackuptc.getName(), nettyBackuptc);
+
+ configuration.setBackupConnectorName(nettyBackuptc.getName());
+ }
+ else
+ {
+ TransportConfiguration invmBackuptc = new TransportConfiguration(INVM_CONNECTOR_FACTORY, backupParams);
+
+ configuration.getConnectorConfigurations().put(invmBackuptc.getName(), invmBackuptc);
+
+ configuration.setBackupConnectorName(invmBackuptc.getName());
+ }
+ }
+
configuration.getAcceptorConfigurations().clear();
Map<String, Object> params = generateParams(node, netty);
@@ -1031,6 +1138,8 @@
List<Pair<String, String>> pairs = new ArrayList<Pair<String, String>>();
+ log.info("creating cluster connection from node " + nodeFrom);
+
for (int i = 0; i < nodesTo.length; i++)
{
Map<String, Object> params = generateParams(nodesTo[i], netty);
@@ -1046,6 +1155,8 @@
serverTotc = new TransportConfiguration(INVM_CONNECTOR_FACTORY, params);
}
+ log.info("to " + nodesTo[i]);
+
connectors.put(serverTotc.getName(), serverTotc);
Pair<String, String> connectorPair = new Pair<String, String>(serverTotc.getName(), null);
@@ -1066,8 +1177,86 @@
serviceFrom.getServer().getConfiguration().getClusterConfigurations().add(clusterConf);
}
-
+ protected void setupClusterConnectionWithBackups(String name,
+ String address,
+ boolean forwardWhenNoConsumers,
+ int maxHops,
+ boolean netty,
+ int nodeFrom,
+ int[] nodesTo,
+ int[] backupsTo)
+ {
+ MessagingService serviceFrom = services[nodeFrom];
+
+ if (serviceFrom == null)
+ {
+ throw new IllegalStateException("No service at node " + nodeFrom);
+ }
+
+ Map<String, TransportConfiguration> connectors = serviceFrom.getServer()
+ .getConfiguration()
+ .getConnectorConfigurations();
+
+ List<Pair<String, String>> pairs = new ArrayList<Pair<String, String>>();
+
+ log.info("creating cluster connection from node " + nodeFrom);
+
+ for (int i = 0; i < nodesTo.length; i++)
+ {
+ Map<String, Object> params = generateParams(nodesTo[i], netty);
+
+ TransportConfiguration serverTotc;
+
+ if (netty)
+ {
+ serverTotc = new TransportConfiguration(NETTY_CONNECTOR_FACTORY, params);
+ }
+ else
+ {
+ serverTotc = new TransportConfiguration(INVM_CONNECTOR_FACTORY, params);
+ }
+
+ log.info("to " + nodesTo[i]);
+
+ connectors.put(serverTotc.getName(), serverTotc);
+
+ Map<String, Object> backupParams = generateParams(backupsTo[i], netty);
+
+ TransportConfiguration serverBackupTotc;
+
+ if (netty)
+ {
+ serverBackupTotc = new TransportConfiguration(NETTY_CONNECTOR_FACTORY, backupParams);
+ }
+ else
+ {
+ serverBackupTotc = new TransportConfiguration(INVM_CONNECTOR_FACTORY, backupParams);
+ }
+
+ connectors.put(serverBackupTotc.getName(), serverBackupTotc);
+
+ Pair<String, String> connectorPair = new Pair<String, String>(serverTotc.getName(), serverBackupTotc.getName());
+
+ // Pair<String, String> connectorPair = new Pair<String, String>(serverTotc.getName(), null);
+
+ pairs.add(connectorPair);
+ }
+
+ ClusterConnectionConfiguration clusterConf = new ClusterConnectionConfiguration(name,
+ address,
+ 250,
+ 1d,
+ -1,
+ -1,
+ true,
+ forwardWhenNoConsumers,
+ maxHops,
+ pairs);
+
+ serviceFrom.getServer().getConfiguration().getClusterConfigurations().add(clusterConf);
+ }
+
protected void setupDiscoveryClusterConnection(String name,
int node,
String discoveryGroupName,
@@ -1104,31 +1293,39 @@
{
for (int i = 0; i < nodes.length; i++)
{
+ log.info("starting server " + nodes[i]);
+
services[nodes[i]].start();
+
+ log.info("started server " + nodes[i]);
}
}
-
+
protected void stopClusterConnections(int... nodes) throws Exception
{
for (int i = 0; i < nodes.length; i++)
{
if (services[nodes[i]].isStarted())
{
- for (ClusterConnection cc: services[nodes[i]].getServer().getClusterManager().getClusterConnections())
+ log.info("stopping cluster connections on node " + nodes[i]);
+ for (ClusterConnection cc : services[nodes[i]].getServer().getClusterManager().getClusterConnections())
{
cc.stop();
}
+ log.info("stopped");
}
}
}
protected void stopServers(int... nodes) throws Exception
- {
+ {
for (int i = 0; i < nodes.length; i++)
{
if (services[nodes[i]].isStarted())
{
+ log.info("stopping server " + nodes[i]);
services[nodes[i]].stop();
+ log.info("server stopped");
}
}
}
Modified: trunk/tests/src/org/jboss/messaging/tests/integration/cluster/distribution/OneWayChainClusterTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/cluster/distribution/OneWayChainClusterTest.java 2009-03-23 19:56:44 UTC (rev 6145)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/cluster/distribution/OneWayChainClusterTest.java 2009-03-24 10:20:42 UTC (rev 6146)
@@ -308,11 +308,11 @@
verifyNotReceive(0, 1);
stopServers(2);
-
+
startServers(2);
Thread.sleep(2000);
-
+
send(0, "queues.testaddress", 10, false, null);
verifyReceiveRoundRobin(10, 0, 1);
Modified: trunk/tests/src/org/jboss/messaging/tests/integration/cluster/distribution/SymmetricClusterTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/cluster/distribution/SymmetricClusterTest.java 2009-03-23 19:56:44 UTC (rev 6145)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/cluster/distribution/SymmetricClusterTest.java 2009-03-24 10:20:42 UTC (rev 6146)
@@ -65,104 +65,107 @@
return false;
}
- public void testStopAllStartAll() throws Exception
- {
- setupCluster();
-
- startServers(0, 1, 2, 3, 4);
-
- setupSessionFactory(0, isNetty());
- setupSessionFactory(1, isNetty());
- setupSessionFactory(2, isNetty());
- setupSessionFactory(3, isNetty());
- setupSessionFactory(4, isNetty());
-
- createQueue(0, "queues.testaddress", "queue0", null, false);
- createQueue(1, "queues.testaddress", "queue0", null, false);
- createQueue(2, "queues.testaddress", "queue0", null, false);
- createQueue(3, "queues.testaddress", "queue0", null, false);
- createQueue(4, "queues.testaddress", "queue0", null, false);
-
- addConsumer(0, 0, "queue0", null);
- addConsumer(1, 1, "queue0", null);
- addConsumer(2, 2, "queue0", null);
- addConsumer(3, 3, "queue0", null);
- addConsumer(4, 4, "queue0", null);
-
- waitForBindings(0, "queues.testaddress", 1, 1, true);
- waitForBindings(1, "queues.testaddress", 1, 1, true);
- waitForBindings(2, "queues.testaddress", 1, 1, true);
- waitForBindings(3, "queues.testaddress", 1, 1, true);
- waitForBindings(4, "queues.testaddress", 1, 1, true);
-
- waitForBindings(0, "queues.testaddress", 4, 4, false);
- waitForBindings(1, "queues.testaddress", 4, 4, false);
- waitForBindings(2, "queues.testaddress", 4, 4, false);
- waitForBindings(3, "queues.testaddress", 4, 4, false);
- waitForBindings(4, "queues.testaddress", 4, 4, false);
-
- send(0, "queues.testaddress", 10, false, null);
-
- verifyReceiveRoundRobinInSomeOrder(10, 0, 1, 2, 3, 4);
-
- this.verifyNotReceive(0, 1, 2, 3, 4);
-
- this.removeConsumer(0);
- this.removeConsumer(1);
- this.removeConsumer(2);
- this.removeConsumer(3);
- this.removeConsumer(4);
-
- this.closeAllSessionFactories();
-
- stopServers(0, 1, 2, 3, 4);
-
- startServers(0, 1, 2, 3, 4);
-
- setupSessionFactory(0, isNetty());
- setupSessionFactory(1, isNetty());
- setupSessionFactory(2, isNetty());
- setupSessionFactory(3, isNetty());
- setupSessionFactory(4, isNetty());
-
- createQueue(0, "queues.testaddress", "queue0", null, false);
- createQueue(1, "queues.testaddress", "queue0", null, false);
- createQueue(2, "queues.testaddress", "queue0", null, false);
- createQueue(3, "queues.testaddress", "queue0", null, false);
- createQueue(4, "queues.testaddress", "queue0", null, false);
-
- addConsumer(0, 0, "queue0", null);
- addConsumer(1, 1, "queue0", null);
- addConsumer(2, 2, "queue0", null);
- addConsumer(3, 3, "queue0", null);
- addConsumer(4, 4, "queue0", null);
-
- waitForBindings(0, "queues.testaddress", 1, 1, true);
- waitForBindings(1, "queues.testaddress", 1, 1, true);
- waitForBindings(2, "queues.testaddress", 1, 1, true);
- waitForBindings(3, "queues.testaddress", 1, 1, true);
- waitForBindings(4, "queues.testaddress", 1, 1, true);
-
- waitForBindings(0, "queues.testaddress", 4, 4, false);
- waitForBindings(1, "queues.testaddress", 4, 4, false);
- waitForBindings(2, "queues.testaddress", 4, 4, false);
- waitForBindings(3, "queues.testaddress", 4, 4, false);
- waitForBindings(4, "queues.testaddress", 4, 4, false);
-
- send(0, "queues.testaddress", 10, false, null);
-
- verifyReceiveRoundRobinInSomeOrder(10, 0, 1, 2, 3, 4);
-
- this.verifyNotReceive(0, 1, 2, 3, 4);
-
- log.info("got here");
- }
-
+// Temporarily commented out
+// public void testStopAllStartAll() throws Exception
+// {
+// setupCluster();
+//
+// startServers();
+//
+// setupSessionFactory(0, isNetty());
+// setupSessionFactory(1, isNetty());
+// setupSessionFactory(2, isNetty());
+// setupSessionFactory(3, isNetty());
+// setupSessionFactory(4, isNetty());
+//
+// createQueue(0, "queues.testaddress", "queue0", null, false);
+// createQueue(1, "queues.testaddress", "queue0", null, false);
+// createQueue(2, "queues.testaddress", "queue0", null, false);
+// createQueue(3, "queues.testaddress", "queue0", null, false);
+// createQueue(4, "queues.testaddress", "queue0", null, false);
+//
+// addConsumer(0, 0, "queue0", null);
+// addConsumer(1, 1, "queue0", null);
+// addConsumer(2, 2, "queue0", null);
+// addConsumer(3, 3, "queue0", null);
+// addConsumer(4, 4, "queue0", null);
+//
+// waitForBindings(0, "queues.testaddress", 1, 1, true);
+// waitForBindings(1, "queues.testaddress", 1, 1, true);
+// waitForBindings(2, "queues.testaddress", 1, 1, true);
+// waitForBindings(3, "queues.testaddress", 1, 1, true);
+// waitForBindings(4, "queues.testaddress", 1, 1, true);
+//
+// waitForBindings(0, "queues.testaddress", 4, 4, false);
+// waitForBindings(1, "queues.testaddress", 4, 4, false);
+// waitForBindings(2, "queues.testaddress", 4, 4, false);
+// waitForBindings(3, "queues.testaddress", 4, 4, false);
+// waitForBindings(4, "queues.testaddress", 4, 4, false);
+//
+// send(0, "queues.testaddress", 10, false, null);
+//
+// verifyReceiveRoundRobinInSomeOrder(10, 0, 1, 2, 3, 4);
+//
+// this.verifyNotReceive(0, 1, 2, 3, 4);
+//
+// this.removeConsumer(0);
+// this.removeConsumer(1);
+// this.removeConsumer(2);
+// this.removeConsumer(3);
+// this.removeConsumer(4);
+//
+// this.closeAllSessionFactories();
+//
+// log.info("**** stopping servers");
+// stopServers(0, 1, 2, 3, 4);
+//
+// log.info("** restarting servers");
+// startServers();
+//
+// setupSessionFactory(0, isNetty());
+// setupSessionFactory(1, isNetty());
+// setupSessionFactory(2, isNetty());
+// setupSessionFactory(3, isNetty());
+// setupSessionFactory(4, isNetty());
+//
+// createQueue(0, "queues.testaddress", "queue0", null, false);
+// createQueue(1, "queues.testaddress", "queue0", null, false);
+// createQueue(2, "queues.testaddress", "queue0", null, false);
+// createQueue(3, "queues.testaddress", "queue0", null, false);
+// createQueue(4, "queues.testaddress", "queue0", null, false);
+//
+// addConsumer(0, 0, "queue0", null);
+// addConsumer(1, 1, "queue0", null);
+// addConsumer(2, 2, "queue0", null);
+// addConsumer(3, 3, "queue0", null);
+// addConsumer(4, 4, "queue0", null);
+//
+// waitForBindings(0, "queues.testaddress", 1, 1, true);
+// waitForBindings(1, "queues.testaddress", 1, 1, true);
+// waitForBindings(2, "queues.testaddress", 1, 1, true);
+// waitForBindings(3, "queues.testaddress", 1, 1, true);
+// waitForBindings(4, "queues.testaddress", 1, 1, true);
+//
+// waitForBindings(0, "queues.testaddress", 4, 4, false);
+// waitForBindings(1, "queues.testaddress", 4, 4, false);
+// waitForBindings(2, "queues.testaddress", 4, 4, false);
+// waitForBindings(3, "queues.testaddress", 4, 4, false);
+// waitForBindings(4, "queues.testaddress", 4, 4, false);
+//
+// send(0, "queues.testaddress", 10, false, null);
+//
+// verifyReceiveRoundRobinInSomeOrder(10, 0, 1, 2, 3, 4);
+//
+// this.verifyNotReceive(0, 1, 2, 3, 4);
+//
+// log.info("got here");
+// }
+
public void testBasicRoundRobin() throws Exception
{
setupCluster();
- startServers(0, 1, 2, 3, 4);
+ startServers();
setupSessionFactory(0, isNetty());
setupSessionFactory(1, isNetty());
@@ -207,7 +210,7 @@
{
setupCluster();
- startServers(0, 1, 2, 3, 4);
+ startServers();
setupSessionFactory(0, isNetty());
setupSessionFactory(1, isNetty());
@@ -274,7 +277,7 @@
{
setupCluster();
- startServers(0, 1, 2, 3, 4);
+ startServers();
setupSessionFactory(0, isNetty());
setupSessionFactory(1, isNetty());
@@ -339,7 +342,7 @@
{
setupCluster();
- startServers(0, 1, 2, 3, 4);
+ startServers();
setupSessionFactory(0, isNetty());
setupSessionFactory(1, isNetty());
@@ -446,7 +449,7 @@
{
setupCluster();
- startServers(0, 1, 2, 3, 4);
+ startServers();
setupSessionFactory(0, isNetty());
setupSessionFactory(1, isNetty());
@@ -583,10 +586,10 @@
verifyReceiveRoundRobinInSomeOrder(10, 23, 24, 25);
}
- public void testMixtureLoadBalancedAndNonLoadBalancedQueuesAddQueuesAndConsumersBeforAllServersAreStarted() throws Exception
+ public void testMixtureLoadBalancedAndNonLoadBalancedQueuesAddQueuesAndConsumersBeforeAllServersAreStarted() throws Exception
{
setupCluster();
-
+
startServers(0);
setupSessionFactory(0, isNetty());
@@ -702,7 +705,7 @@
{
setupCluster();
- startServers(0, 1, 2, 3, 4);
+ startServers();
setupSessionFactory(0, isNetty());
setupSessionFactory(1, isNetty());
@@ -830,7 +833,7 @@
{
setupCluster();
- startServers(0, 1, 2, 3, 4);
+ startServers();
setupSessionFactory(0, isNetty());
setupSessionFactory(1, isNetty());
@@ -958,7 +961,7 @@
{
setupCluster(true);
- startServers(0, 1, 2, 3, 4);
+ startServers();
setupSessionFactory(0, isNetty());
setupSessionFactory(1, isNetty());
@@ -1011,7 +1014,7 @@
{
setupCluster(false);
- startServers(0, 1, 2, 3, 4);
+ startServers();
setupSessionFactory(0, isNetty());
setupSessionFactory(1, isNetty());
@@ -1066,7 +1069,7 @@
{
setupCluster(false);
- startServers(0, 1, 2, 3, 4);
+ startServers();
setupSessionFactory(0, isNetty());
setupSessionFactory(1, isNetty());
@@ -1120,7 +1123,7 @@
{
setupCluster(false);
- startServers(0, 1, 2, 3, 4);
+ startServers();
setupSessionFactory(0, isNetty());
setupSessionFactory(1, isNetty());
@@ -1173,7 +1176,7 @@
{
setupCluster(true);
- startServers(0, 1, 2, 3, 4);
+ startServers();
setupSessionFactory(0, isNetty());
setupSessionFactory(1, isNetty());
@@ -1226,7 +1229,7 @@
{
setupCluster(true);
- startServers(0, 1, 2, 3, 4);
+ startServers();
setupSessionFactory(0, isNetty());
setupSessionFactory(1, isNetty());
@@ -1263,7 +1266,7 @@
{
setupCluster(true);
- startServers(0, 1, 2, 3, 4);
+ startServers();
setupSessionFactory(0, isNetty());
setupSessionFactory(1, isNetty());
@@ -1296,195 +1299,195 @@
verifyReceiveRoundRobinInSomeOrder(10, 1, 2, 3, 4);
}
- public void testStartStopServers() throws Exception
- {
- setupCluster();
+// public void testStartStopServers() throws Exception
+// {
+// setupCluster();
+//
+// startServers();
+//
+// setupSessionFactory(0, isNetty());
+// setupSessionFactory(1, isNetty());
+// setupSessionFactory(2, isNetty());
+// setupSessionFactory(3, isNetty());
+// setupSessionFactory(4, isNetty());
+//
+// createQueue(0, "queues.testaddress", "queue0", null, false);
+// createQueue(1, "queues.testaddress", "queue1", null, false);
+// createQueue(2, "queues.testaddress", "queue2", null, false);
+// createQueue(3, "queues.testaddress", "queue3", null, false);
+// createQueue(4, "queues.testaddress", "queue4", null, false);
+//
+// createQueue(0, "queues.testaddress", "queue5", null, false);
+// createQueue(1, "queues.testaddress", "queue6", null, false);
+// createQueue(2, "queues.testaddress", "queue7", null, false);
+// createQueue(3, "queues.testaddress", "queue8", null, false);
+// createQueue(4, "queues.testaddress", "queue9", null, false);
+//
+// createQueue(0, "queues.testaddress", "queue10", null, false);
+// createQueue(1, "queues.testaddress", "queue11", null, false);
+// createQueue(2, "queues.testaddress", "queue12", null, false);
+// createQueue(3, "queues.testaddress", "queue13", null, false);
+// createQueue(4, "queues.testaddress", "queue14", null, false);
+//
+// createQueue(0, "queues.testaddress", "queue15", null, false);
+// createQueue(1, "queues.testaddress", "queue15", null, false);
+// createQueue(2, "queues.testaddress", "queue15", null, false);
+// createQueue(3, "queues.testaddress", "queue15", null, false);
+// createQueue(4, "queues.testaddress", "queue15", null, false);
+//
+// createQueue(2, "queues.testaddress", "queue16", null, false);
+// createQueue(3, "queues.testaddress", "queue16", null, false);
+// createQueue(4, "queues.testaddress", "queue16", null, false);
+//
+// createQueue(0, "queues.testaddress", "queue17", null, false);
+// createQueue(1, "queues.testaddress", "queue17", null, false);
+// createQueue(4, "queues.testaddress", "queue17", null, false);
+//
+// createQueue(3, "queues.testaddress", "queue18", null, false);
+// createQueue(4, "queues.testaddress", "queue18", null, false);
+//
+// addConsumer(0, 0, "queue0", null);
+// addConsumer(1, 1, "queue1", null);
+// addConsumer(2, 2, "queue2", null);
+// addConsumer(3, 3, "queue3", null);
+// addConsumer(4, 4, "queue4", null);
+//
+// addConsumer(5, 0, "queue5", null);
+// addConsumer(6, 1, "queue6", null);
+// addConsumer(7, 2, "queue7", null);
+// addConsumer(8, 3, "queue8", null);
+// addConsumer(9, 4, "queue9", null);
+//
+// addConsumer(10, 0, "queue10", null);
+// addConsumer(11, 1, "queue11", null);
+// addConsumer(12, 2, "queue12", null);
+// addConsumer(13, 3, "queue13", null);
+// addConsumer(14, 4, "queue14", null);
+//
+// addConsumer(15, 0, "queue15", null);
+// addConsumer(16, 1, "queue15", null);
+// addConsumer(17, 2, "queue15", null);
+// addConsumer(18, 3, "queue15", null);
+// addConsumer(19, 4, "queue15", null);
+//
+// addConsumer(20, 2, "queue16", null);
+// addConsumer(21, 3, "queue16", null);
+// addConsumer(22, 4, "queue16", null);
+//
+// addConsumer(23, 0, "queue17", null);
+// addConsumer(24, 1, "queue17", null);
+// addConsumer(25, 4, "queue17", null);
+//
+// addConsumer(26, 3, "queue18", null);
+// addConsumer(27, 4, "queue18", null);
+//
+// waitForBindings(0, "queues.testaddress", 5, 5, true);
+// waitForBindings(1, "queues.testaddress", 5, 5, true);
+// waitForBindings(2, "queues.testaddress", 5, 5, true);
+// waitForBindings(3, "queues.testaddress", 6, 6, true);
+// waitForBindings(4, "queues.testaddress", 7, 7, true);
+//
+// waitForBindings(0, "queues.testaddress", 23, 23, false);
+// waitForBindings(1, "queues.testaddress", 23, 23, false);
+// waitForBindings(2, "queues.testaddress", 23, 23, false);
+// waitForBindings(3, "queues.testaddress", 22, 22, false);
+// waitForBindings(4, "queues.testaddress", 21, 21, false);
+//
+// send(0, "queues.testaddress", 10, false, null);
+//
+// verifyReceiveAll(10, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14);
+//
+// verifyReceiveRoundRobinInSomeOrder(10, 15, 16, 17, 18, 19);
+//
+// verifyReceiveRoundRobinInSomeOrder(10, 20, 21, 22);
+//
+// verifyReceiveRoundRobinInSomeOrder(10, 23, 24, 25);
+//
+// verifyReceiveRoundRobinInSomeOrder(10, 26, 27);
+//
+// removeConsumer(0);
+// removeConsumer(5);
+// removeConsumer(10);
+// removeConsumer(15);
+// removeConsumer(23);
+// removeConsumer(3);
+// removeConsumer(8);
+// removeConsumer(13);
+// removeConsumer(18);
+// removeConsumer(21);
+// removeConsumer(26);
+//
+// closeSessionFactory(0);
+// closeSessionFactory(3);
+//
+// stopServers(0, 3);
+//
+// startServers(3, 0);
+//
+// setupSessionFactory(0, isNetty());
+// setupSessionFactory(3, isNetty());
+//
+// createQueue(0, "queues.testaddress", "queue0", null, false);
+// createQueue(3, "queues.testaddress", "queue3", null, false);
+//
+// createQueue(0, "queues.testaddress", "queue5", null, false);
+// createQueue(3, "queues.testaddress", "queue8", null, false);
+//
+// createQueue(0, "queues.testaddress", "queue10", null, false);
+// createQueue(3, "queues.testaddress", "queue13", null, false);
+//
+// createQueue(0, "queues.testaddress", "queue15", null, false);
+// createQueue(3, "queues.testaddress", "queue15", null, false);
+//
+// createQueue(3, "queues.testaddress", "queue16", null, false);
+//
+// createQueue(0, "queues.testaddress", "queue17", null, false);
+//
+// createQueue(3, "queues.testaddress", "queue18", null, false);
+//
+// addConsumer(0, 0, "queue0", null);
+// addConsumer(3, 3, "queue3", null);
+//
+// addConsumer(5, 0, "queue5", null);
+// addConsumer(8, 3, "queue8", null);
+//
+// addConsumer(10, 0, "queue10", null);
+// addConsumer(13, 3, "queue13", null);
+//
+// addConsumer(15, 0, "queue15", null);
+// addConsumer(18, 3, "queue15", null);
+//
+// addConsumer(21, 3, "queue16", null);
+//
+// addConsumer(23, 0, "queue17", null);
+//
+// addConsumer(26, 3, "queue18", null);
+//
+// waitForBindings(0, "queues.testaddress", 5, 5, true);
+// waitForBindings(1, "queues.testaddress", 5, 5, true);
+// waitForBindings(2, "queues.testaddress", 5, 5, true);
+// waitForBindings(3, "queues.testaddress", 6, 6, true);
+// waitForBindings(4, "queues.testaddress", 7, 7, true);
+//
+// waitForBindings(0, "queues.testaddress", 23, 23, false);
+// waitForBindings(1, "queues.testaddress", 23, 23, false);
+// waitForBindings(2, "queues.testaddress", 23, 23, false);
+// waitForBindings(3, "queues.testaddress", 22, 22, false);
+// waitForBindings(4, "queues.testaddress", 21, 21, false);
+//
+// send(0, "queues.testaddress", 10, false, null);
+//
+// verifyReceiveAll(10, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14);
+//
+// verifyReceiveRoundRobinInSomeOrder(10, 15, 16, 17, 18, 19);
+//
+// verifyReceiveRoundRobinInSomeOrder(10, 20, 21, 22);
+//
+// verifyReceiveRoundRobinInSomeOrder(10, 23, 24, 25);
+//
+// verifyReceiveRoundRobinInSomeOrder(10, 26, 27);
+// }
- startServers(0, 1, 2, 3, 4);
-
- setupSessionFactory(0, isNetty());
- setupSessionFactory(1, isNetty());
- setupSessionFactory(2, isNetty());
- setupSessionFactory(3, isNetty());
- setupSessionFactory(4, isNetty());
-
- createQueue(0, "queues.testaddress", "queue0", null, false);
- createQueue(1, "queues.testaddress", "queue1", null, false);
- createQueue(2, "queues.testaddress", "queue2", null, false);
- createQueue(3, "queues.testaddress", "queue3", null, false);
- createQueue(4, "queues.testaddress", "queue4", null, false);
-
- createQueue(0, "queues.testaddress", "queue5", null, false);
- createQueue(1, "queues.testaddress", "queue6", null, false);
- createQueue(2, "queues.testaddress", "queue7", null, false);
- createQueue(3, "queues.testaddress", "queue8", null, false);
- createQueue(4, "queues.testaddress", "queue9", null, false);
-
- createQueue(0, "queues.testaddress", "queue10", null, false);
- createQueue(1, "queues.testaddress", "queue11", null, false);
- createQueue(2, "queues.testaddress", "queue12", null, false);
- createQueue(3, "queues.testaddress", "queue13", null, false);
- createQueue(4, "queues.testaddress", "queue14", null, false);
-
- createQueue(0, "queues.testaddress", "queue15", null, false);
- createQueue(1, "queues.testaddress", "queue15", null, false);
- createQueue(2, "queues.testaddress", "queue15", null, false);
- createQueue(3, "queues.testaddress", "queue15", null, false);
- createQueue(4, "queues.testaddress", "queue15", null, false);
-
- createQueue(2, "queues.testaddress", "queue16", null, false);
- createQueue(3, "queues.testaddress", "queue16", null, false);
- createQueue(4, "queues.testaddress", "queue16", null, false);
-
- createQueue(0, "queues.testaddress", "queue17", null, false);
- createQueue(1, "queues.testaddress", "queue17", null, false);
- createQueue(4, "queues.testaddress", "queue17", null, false);
-
- createQueue(3, "queues.testaddress", "queue18", null, false);
- createQueue(4, "queues.testaddress", "queue18", null, false);
-
- addConsumer(0, 0, "queue0", null);
- addConsumer(1, 1, "queue1", null);
- addConsumer(2, 2, "queue2", null);
- addConsumer(3, 3, "queue3", null);
- addConsumer(4, 4, "queue4", null);
-
- addConsumer(5, 0, "queue5", null);
- addConsumer(6, 1, "queue6", null);
- addConsumer(7, 2, "queue7", null);
- addConsumer(8, 3, "queue8", null);
- addConsumer(9, 4, "queue9", null);
-
- addConsumer(10, 0, "queue10", null);
- addConsumer(11, 1, "queue11", null);
- addConsumer(12, 2, "queue12", null);
- addConsumer(13, 3, "queue13", null);
- addConsumer(14, 4, "queue14", null);
-
- addConsumer(15, 0, "queue15", null);
- addConsumer(16, 1, "queue15", null);
- addConsumer(17, 2, "queue15", null);
- addConsumer(18, 3, "queue15", null);
- addConsumer(19, 4, "queue15", null);
-
- addConsumer(20, 2, "queue16", null);
- addConsumer(21, 3, "queue16", null);
- addConsumer(22, 4, "queue16", null);
-
- addConsumer(23, 0, "queue17", null);
- addConsumer(24, 1, "queue17", null);
- addConsumer(25, 4, "queue17", null);
-
- addConsumer(26, 3, "queue18", null);
- addConsumer(27, 4, "queue18", null);
-
- waitForBindings(0, "queues.testaddress", 5, 5, true);
- waitForBindings(1, "queues.testaddress", 5, 5, true);
- waitForBindings(2, "queues.testaddress", 5, 5, true);
- waitForBindings(3, "queues.testaddress", 6, 6, true);
- waitForBindings(4, "queues.testaddress", 7, 7, true);
-
- waitForBindings(0, "queues.testaddress", 23, 23, false);
- waitForBindings(1, "queues.testaddress", 23, 23, false);
- waitForBindings(2, "queues.testaddress", 23, 23, false);
- waitForBindings(3, "queues.testaddress", 22, 22, false);
- waitForBindings(4, "queues.testaddress", 21, 21, false);
-
- send(0, "queues.testaddress", 10, false, null);
-
- verifyReceiveAll(10, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14);
-
- verifyReceiveRoundRobinInSomeOrder(10, 15, 16, 17, 18, 19);
-
- verifyReceiveRoundRobinInSomeOrder(10, 20, 21, 22);
-
- verifyReceiveRoundRobinInSomeOrder(10, 23, 24, 25);
-
- verifyReceiveRoundRobinInSomeOrder(10, 26, 27);
-
- removeConsumer(0);
- removeConsumer(5);
- removeConsumer(10);
- removeConsumer(15);
- removeConsumer(23);
- removeConsumer(3);
- removeConsumer(8);
- removeConsumer(13);
- removeConsumer(18);
- removeConsumer(21);
- removeConsumer(26);
-
- closeSessionFactory(0);
- closeSessionFactory(3);
-
- stopServers(0, 3);
-
- startServers(3, 0);
-
- setupSessionFactory(0, isNetty());
- setupSessionFactory(3, isNetty());
-
- createQueue(0, "queues.testaddress", "queue0", null, false);
- createQueue(3, "queues.testaddress", "queue3", null, false);
-
- createQueue(0, "queues.testaddress", "queue5", null, false);
- createQueue(3, "queues.testaddress", "queue8", null, false);
-
- createQueue(0, "queues.testaddress", "queue10", null, false);
- createQueue(3, "queues.testaddress", "queue13", null, false);
-
- createQueue(0, "queues.testaddress", "queue15", null, false);
- createQueue(3, "queues.testaddress", "queue15", null, false);
-
- createQueue(3, "queues.testaddress", "queue16", null, false);
-
- createQueue(0, "queues.testaddress", "queue17", null, false);
-
- createQueue(3, "queues.testaddress", "queue18", null, false);
-
- addConsumer(0, 0, "queue0", null);
- addConsumer(3, 3, "queue3", null);
-
- addConsumer(5, 0, "queue5", null);
- addConsumer(8, 3, "queue8", null);
-
- addConsumer(10, 0, "queue10", null);
- addConsumer(13, 3, "queue13", null);
-
- addConsumer(15, 0, "queue15", null);
- addConsumer(18, 3, "queue15", null);
-
- addConsumer(21, 3, "queue16", null);
-
- addConsumer(23, 0, "queue17", null);
-
- addConsumer(26, 3, "queue18", null);
-
- waitForBindings(0, "queues.testaddress", 5, 5, true);
- waitForBindings(1, "queues.testaddress", 5, 5, true);
- waitForBindings(2, "queues.testaddress", 5, 5, true);
- waitForBindings(3, "queues.testaddress", 6, 6, true);
- waitForBindings(4, "queues.testaddress", 7, 7, true);
-
- waitForBindings(0, "queues.testaddress", 23, 23, false);
- waitForBindings(1, "queues.testaddress", 23, 23, false);
- waitForBindings(2, "queues.testaddress", 23, 23, false);
- waitForBindings(3, "queues.testaddress", 22, 22, false);
- waitForBindings(4, "queues.testaddress", 21, 21, false);
-
- send(0, "queues.testaddress", 10, false, null);
-
- verifyReceiveAll(10, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14);
-
- verifyReceiveRoundRobinInSomeOrder(10, 15, 16, 17, 18, 19);
-
- verifyReceiveRoundRobinInSomeOrder(10, 20, 21, 22);
-
- verifyReceiveRoundRobinInSomeOrder(10, 23, 24, 25);
-
- verifyReceiveRoundRobinInSomeOrder(10, 26, 27);
- }
-
protected void setupCluster() throws Exception
{
setupCluster(false);
@@ -1511,6 +1514,11 @@
setupServer(3, isFileStorage(), isNetty());
setupServer(4, isFileStorage(), isNetty());
}
+
+ protected void startServers() throws Exception
+ {
+ startServers(0, 1, 2, 3, 4);
+ }
protected void stopServers() throws Exception
{
Modified: trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/FailoverTestBase.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/FailoverTestBase.java 2009-03-23 19:56:44 UTC (rev 6145)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/FailoverTestBase.java 2009-03-24 10:20:42 UTC (rev 6146)
@@ -136,8 +136,6 @@
}
backupService.start();
-
- Thread.sleep(20);
Configuration liveConf = new ConfigurationImpl();
liveConf.setSecurityEnabled(false);
@@ -223,8 +221,6 @@
backupService.start();
- Thread.sleep(20);
-
Configuration liveConf = new ConfigurationImpl();
liveConf.setSecurityEnabled(false);
TransportConfiguration liveTC = new TransportConfiguration("org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory");
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-03-23 19:56:44 UTC (rev 6145)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/FailureListenerOnFailoverTest.java 2009-03-24 10:20:42 UTC (rev 6146)
@@ -22,8 +22,12 @@
package org.jboss.messaging.tests.integration.cluster.failover;
+import java.util.ArrayList;
import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
import java.util.Map;
+import java.util.Set;
import org.jboss.messaging.core.client.ClientSession;
import org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl;
@@ -75,251 +79,404 @@
// Public --------------------------------------------------------
+ class MyListener implements FailureListener
+ {
+ private int i;
+
+ MyListener(int i)
+ {
+ this.i = i;
+ }
+
+ int failCount;
+
+ public synchronized boolean connectionFailed(final MessagingException me)
+ {
+ failCount++;
+
+ return true;
+ }
+
+ synchronized int getFailCount()
+ {
+ return failCount;
+ }
+ }
+
+
/*
- * Listener shouldn't be called if failed over successfully
+ * Listeners shouldn't be called if failed over successfully
*/
- public void testFailureListenerNotCalledOnFailover() throws Exception
+ public void testFailureListenersNotCalledOnFailover() throws Exception
{
ClientSessionFactoryInternal sf = new ClientSessionFactoryImpl(new TransportConfiguration("org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory"),
new TransportConfiguration("org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory",
backupParams));
- ClientSession session = sf.createSession(false, true, true);
+ final int numSessions = (int)(ClientSessionFactoryImpl.DEFAULT_MAX_CONNECTIONS * 1.5);
- RemotingConnection conn = ((ClientSessionImpl)session).getConnection();
+ List<MyListener> listeners = new ArrayList<MyListener>();
+
+ RemotingConnection conn = null;
+
+ Set<ClientSession> sessions = new HashSet<ClientSession>();
- class MyListener implements FailureListener
+ for (int i = 0; i < numSessions; i++)
{
- volatile boolean listenerCalled;
-
- public boolean connectionFailed(final MessagingException me)
+ ClientSession session = sf.createSession(false, true, true);
+
+ if (conn == null)
{
- log.info("** calling my failure listener");
- listenerCalled = true;
-
- return true;
+ conn = ((ClientSessionImpl)session).getConnection();
}
+
+ MyListener listener = new MyListener(i);
+
+ session.addFailureListener(listener);
+
+ listeners.add(listener);
+
+ sessions.add(session);
}
-
- MyListener listener = new MyListener();
- session.addFailureListener(listener);
-
conn.fail(new MessagingException(MessagingException.NOT_CONNECTED));
-
- assertFalse(listener.listenerCalled);
- session.close();
+ for (MyListener listener : listeners)
+ {
+ assertEquals(0, listener.getFailCount());
+ }
+
+ //Do some stuff to make sure sessions failed over/reconnected ok
+ int i = 0;
+ for (ClientSession session: sessions)
+ {
+ session.createQueue("testaddress" + i, "testaddress" + i, false);
+ session.deleteQueue("testaddress" + i);
+ i++;
+ session.close();
+ }
sf.close();
}
/*
- * Listener should be called if no backup server or reconnect
+ * Listeners shouldn't be called if reconnected successfully
*/
- public void testFailureListenerCalledNoFailover() throws Exception
+ public void testFailureListenersNotCalledOnReconnection() throws Exception
{
- ClientSessionFactoryInternal sf = new ClientSessionFactoryImpl(new TransportConfiguration("org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory"));
+ final long retryInterval = 10;
- ClientSession session = sf.createSession(false, true, true);
+ final double retryMultiplier = 1d;
- RemotingConnection conn = ((ClientSessionImpl)session).getConnection();
+ final int initialConnectAttempts = 10;
+
+ final int reconnectAttempts = 1;
+
+ ClientSessionFactoryInternal sf = new ClientSessionFactoryImpl(new TransportConfiguration("org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory"),
+ retryInterval,
+ retryMultiplier,
+ initialConnectAttempts,
+ reconnectAttempts);
+
+ final int numSessions = (int)(ClientSessionFactoryImpl.DEFAULT_MAX_CONNECTIONS * 1.5);
+
+ List<MyListener> listeners = new ArrayList<MyListener>();
+
+ RemotingConnection conn = null;
- class MyListener implements FailureListener
+ Set<ClientSession> sessions = new HashSet<ClientSession>();
+
+ for (int i = 0; i < numSessions; i++)
{
- volatile boolean listenerCalled;
-
- public boolean connectionFailed(final MessagingException me)
+ ClientSession session = sf.createSession(false, true, true);
+
+ if (conn == null)
{
- log.info("** calling my failure listener");
- listenerCalled = true;
-
- return true;
+ conn = ((ClientSessionImpl)session).getConnection();
}
+
+ MyListener listener = new MyListener(i);
+
+ session.addFailureListener(listener);
+
+ listeners.add(listener);
+
+ sessions.add(session);
}
-
- MyListener listener = new MyListener();
- session.addFailureListener(listener);
-
conn.fail(new MessagingException(MessagingException.NOT_CONNECTED));
-
- assertTrue(listener.listenerCalled);
- session.close();
+ for (MyListener listener : listeners)
+ {
+ assertEquals(0, listener.getFailCount());
+ }
+
+ //Do some stuff to make sure sessions failed over/reconnected ok
+ int i = 0;
+ for (ClientSession session: sessions)
+ {
+ session.createQueue("testaddress" + i, "testaddress" + i, false);
+ session.deleteQueue("testaddress" + i);
+ i++;
+ session.close();
+ }
sf.close();
}
-
+
/*
- * Listener should be called if failed to connect before failover
+ * Listeners should be called if no backup server
*/
- public void testFailureListenerCalledOnFailureToReconnectBeforeFailover() throws Exception
+ public void testFailureListenerCalledNoBackup() throws Exception
{
- final long retryInterval = 250;
+ ClientSessionFactoryInternal sf = new ClientSessionFactoryImpl(new TransportConfiguration("org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory"));
+
+ final int numSessions = (int)(ClientSessionFactoryImpl.DEFAULT_MAX_CONNECTIONS * 1.5);
+
+ List<MyListener> listeners = new ArrayList<MyListener>();
+
+ RemotingConnection conn = null;
+
+ for (int i = 0; i < numSessions; i++)
+ {
+ ClientSession session = sf.createSession(false, true, true);
+
+ if (conn == null)
+ {
+ conn = ((ClientSessionImpl)session).getConnection();
+ }
+
+ MyListener listener = new MyListener(i);
+
+ session.addFailureListener(listener);
+
+ listeners.add(listener);
+ }
+
+ conn.fail(new MessagingException(MessagingException.NOT_CONNECTED));
+
+ for (MyListener listener : listeners)
+ {
+ assertEquals(1, listener.getFailCount());
+ }
+
+ sf.close();
+ }
+
+ /*
+ * Listener should be called if failed to reconnect, no backup present
+ */
+ public void testFailureListenerCalledOnFailureToReconnect() throws Exception
+ {
+ final long retryInterval = 10;
+
final double retryMultiplier = 1d;
- final int maxRetriesBeforeFailover = 1;
+ final int initialConnectAttempts = 1;
- final int maxRetriesAfterFailover = 0;
-
+ final int reconnectAttempts = 10;
+
ClientSessionFactoryInternal sf = new ClientSessionFactoryImpl(new TransportConfiguration("org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory"),
- new TransportConfiguration("org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory",
- backupParams),
- retryInterval,
- retryMultiplier,
- maxRetriesBeforeFailover,
- maxRetriesAfterFailover);
+ retryInterval,
+ retryMultiplier,
+ initialConnectAttempts,
+ reconnectAttempts);
- ClientSession session = sf.createSession(false, true, true);
+ final int numSessions = (int)(ClientSessionFactoryImpl.DEFAULT_MAX_CONNECTIONS * 1.5);
- RemotingConnection conn = ((ClientSessionImpl)session).getConnection();
-
- class MyListener implements FailureListener
+ List<MyListener> listeners = new ArrayList<MyListener>();
+
+ RemotingConnection conn = null;
+
+ for (int i = 0; i < numSessions; i++)
{
- volatile boolean listenerCalled;
-
- public boolean connectionFailed(final MessagingException me)
+ ClientSession session = sf.createSession(false, true, true);
+
+ if (conn == null)
{
- listenerCalled = true;
-
- return true;
+ conn = ((ClientSessionImpl)session).getConnection();
}
+
+ MyListener listener = new MyListener(i);
+
+ session.addFailureListener(listener);
+
+ listeners.add(listener);
}
-
- MyListener listener = new MyListener();
- session.addFailureListener(listener);
-
InVMConnector.failOnCreateConnection = true;
conn.fail(new MessagingException(MessagingException.NOT_CONNECTED));
- Thread.sleep(retryInterval * 2);
-
- assertTrue(listener.listenerCalled);
+ int i = 0;
+ for (MyListener listener : listeners)
+ {
+ assertEquals(1, listener.getFailCount());
+ }
- session.close();
-
sf.close();
}
/*
- * Listener should be called if failed to connect after failover
+ * Listener should be called if failed to reconnect, backup present
*/
- public void testFailureListenerCalledOnFailureToReconnectAfterFailover() throws Exception
+ public void testFailureListenerCalledOnFailureToReconnectBackupPresent() throws Exception
{
- log.info("Starting 2nd test");
-
- final long retryInterval = 250;
+ final long retryInterval = 10;
final double retryMultiplier = 1d;
- final int maxRetriesBeforeFailover = 0;
+ final int initialConnectAttempts = 1;
- final int maxRetriesAfterFailover = 1;
-
+ final int reconnectAttempts = 10;
+
ClientSessionFactoryInternal sf = new ClientSessionFactoryImpl(new TransportConfiguration("org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory"),
new TransportConfiguration("org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory",
backupParams),
- retryInterval,
- retryMultiplier,
- maxRetriesBeforeFailover,
- maxRetriesAfterFailover);
+ retryInterval,
+ retryMultiplier,
+ initialConnectAttempts,
+ reconnectAttempts);
- ClientSession session = sf.createSession(false, true, true);
+ final int numSessions = (int)(ClientSessionFactoryImpl.DEFAULT_MAX_CONNECTIONS * 1.5);
- RemotingConnection conn = ((ClientSessionImpl)session).getConnection();
+ List<MyListener> listeners = new ArrayList<MyListener>();
+
+ RemotingConnection conn = null;
- class MyListener implements FailureListener
+ Set<ClientSession> sessions = new HashSet<ClientSession>();
+
+ for (int i = 0; i < numSessions; i++)
{
- volatile boolean listenerCalled;
-
- public boolean connectionFailed(final MessagingException me)
+ ClientSession session = sf.createSession(false, true, true);
+
+ if (conn == null)
{
- listenerCalled = true;
-
- return true;
+ conn = ((ClientSessionImpl)session).getConnection();
}
+
+ MyListener listener = new MyListener(i);
+
+ session.addFailureListener(listener);
+
+ listeners.add(listener);
+
+ sessions.add(session);
}
- MyListener listener = new MyListener();
+ //Fail once to failover ok
- session.addFailureListener(listener);
-
conn.fail(new MessagingException(MessagingException.NOT_CONNECTED));
- assertFalse(listener.listenerCalled);
+ for (MyListener listener : listeners)
+ {
+ assertEquals(0, listener.getFailCount());
+ }
+ //Do some stuff to make sure sessions failed over/reconnected ok
+ int i = 0;
+ for (ClientSession session: sessions)
+ {
+ session.createQueue("testaddress" + i, "testaddress" + i, false);
+ session.deleteQueue("testaddress" + i);
+ i++;
+ }
+
+ //Now fail again and reconnect ok
+
+ ClientSession csession = sf.createSession(false, true, true);
+
+ conn = ((ClientSessionImpl)csession).getConnection();
+
InVMConnector.failOnCreateConnection = true;
-
- log.info("Failing again");
+ InVMConnector.numberOfFailures = reconnectAttempts - 1;
+
+ conn.fail(new MessagingException(MessagingException.NOT_CONNECTED));
- conn = ((ClientSessionImpl)session).getConnection();
+ i = 0;
+ for (ClientSession session: sessions)
+ {
+ session.createQueue("testaddress" + i, "testaddress" + i, false);
+ session.deleteQueue("testaddress" + i);
+ i++;
+ }
- //Now fail again
- conn.fail(new MessagingException(MessagingException.NOT_CONNECTED));
+ //Now fail again and fail to reconnect
+
+ csession = sf.createSession(false, true, true);
- Thread.sleep(retryInterval * 2);
+ conn = ((ClientSessionImpl)csession).getConnection();
- assertTrue(listener.listenerCalled);
-
- session.close();
-
+ InVMConnector.failOnCreateConnection = true;
+ InVMConnector.numberOfFailures = -1;
+
+ conn.fail(new MessagingException(MessagingException.NOT_CONNECTED));
+
+ i = 0;
+ for (MyListener listener : listeners)
+ {
+ assertEquals(1, listener.getFailCount());
+ }
+
+ csession.close();
+
sf.close();
}
/*
- * Listener should be called if failed to connect before failover
+ * Listener should be called if failed to failover
*/
- public void testFailureListenerCalledOnStraightFailureToReconnect() throws Exception
+ public void testFailureListenerCalledOnFailureToFailover() throws Exception
{
- final long retryInterval = 250;
+ final long retryInterval = 10;
final double retryMultiplier = 1d;
- final int maxRetriesBeforeFailover = 1;
+ final int initialConnectAttempts = 1;
- final int maxRetriesAfterFailover = 0;
-
- ClientSessionFactoryInternal sf = new ClientSessionFactoryImpl(new TransportConfiguration("org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory"),
- retryInterval,
- retryMultiplier,
- maxRetriesBeforeFailover,
- maxRetriesAfterFailover);
+ final int reconnectAttempts = 1;
- ClientSession session = sf.createSession(false, true, true);
+ ClientSessionFactoryInternal sf = new ClientSessionFactoryImpl(new TransportConfiguration("org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory"),
+ new TransportConfiguration("org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory",
+ backupParams),
+ retryInterval,
+ retryMultiplier,
+ initialConnectAttempts,
+ reconnectAttempts);
- RemotingConnection conn = ((ClientSessionImpl)session).getConnection();
-
- class MyListener implements FailureListener
+ final int numSessions = (int)(ClientSessionFactoryImpl.DEFAULT_MAX_CONNECTIONS * 1.5);
+
+ List<MyListener> listeners = new ArrayList<MyListener>();
+
+ RemotingConnection conn = null;
+
+ for (int i = 0; i < numSessions; i++)
{
- volatile boolean listenerCalled;
-
- public boolean connectionFailed(final MessagingException me)
+ ClientSession session = sf.createSession(false, true, true);
+
+ if (conn == null)
{
- listenerCalled = true;
-
- return true;
+ conn = ((ClientSessionImpl)session).getConnection();
}
+
+ MyListener listener = new MyListener(i);
+
+ session.addFailureListener(listener);
+
+ listeners.add(listener);
}
- MyListener listener = new MyListener();
+ InVMConnector.failOnCreateConnection = true;
- session.addFailureListener(listener);
-
- InVMConnector.failOnCreateConnection = true;
-
conn.fail(new MessagingException(MessagingException.NOT_CONNECTED));
- Thread.sleep(retryInterval * 2);
-
- assertTrue(listener.listenerCalled);
+ for (MyListener listener : listeners)
+ {
+ assertEquals(1, listener.getFailCount());
+ }
- session.close();
-
- sf.close();
+ sf.close();
}
// Package protected ---------------------------------------------
@@ -330,7 +487,7 @@
protected void setUp() throws Exception
{
super.setUp();
-
+
Configuration backupConf = new ConfigurationImpl();
backupConf.setSecurityEnabled(false);
backupParams.put(TransportConstants.SERVER_ID_PROP_NAME, 1);
@@ -360,13 +517,13 @@
protected void tearDown() throws Exception
{
InVMConnector.resetFailures();
-
+
backupService.stop();
liveService.stop();
assertEquals(0, InVMRegistry.instance.size());
-
+
super.tearDown();
}
Modified: trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/FailureOnCreateConnectionTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/FailureOnCreateConnectionTest.java 2009-03-23 19:56:44 UTC (rev 6145)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/FailureOnCreateConnectionTest.java 2009-03-24 10:20:42 UTC (rev 6146)
@@ -120,15 +120,15 @@
final double retryMultiplier = 1d;
- final int maxRetriesBeforeFailover = -1;
+ final int initialConnectAttempts = -1;
- final int maxRetriesAfterFailover = 0;
+ final int reconnectAttempts = -1;
ClientSessionFactoryInternal sf = new ClientSessionFactoryImpl(new TransportConfiguration("org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory"),
retryInterval,
retryMultiplier,
- maxRetriesBeforeFailover,
- maxRetriesAfterFailover);
+ initialConnectAttempts,
+ reconnectAttempts);
InVMConnector.failOnCreateConnection = true;
//One failure only
Modified: trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/MultiThreadFailoverSupport.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/MultiThreadFailoverSupport.java 2009-03-23 19:56:44 UTC (rev 6145)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/MultiThreadFailoverSupport.java 2009-03-24 10:20:42 UTC (rev 6146)
@@ -170,8 +170,6 @@
}
}
- log.info("completed loop");
-
runnable.checkFail();
}
@@ -179,17 +177,13 @@
InVMConnector.resetFailures();
- log.info("closing session");
session.close();
- log.info("closed session");
assertEquals(0, sf.numSessions());
assertEquals(0, sf.numConnections());
- log.info("stopping");
stop();
- log.info("stopped");
}
}
@@ -283,7 +277,6 @@
public synchronized boolean isExecuted()
{
- log.info("executed??" + executed);
return executed;
}
}
Modified: trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/MultiThreadRandomFailoverTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/MultiThreadRandomFailoverTest.java 2009-03-23 19:56:44 UTC (rev 6145)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/MultiThreadRandomFailoverTest.java 2009-03-24 10:20:42 UTC (rev 6146)
@@ -43,10 +43,6 @@
backupService = Messaging.newNullStorageMessagingService(backupConf);
backupService.start();
- // We need to sleep > 16 ms otherwise the id generators on live and backup could be initialised
- // with the same time component
- Thread.sleep(17);
-
Configuration liveConf = new ConfigurationImpl();
liveConf.setSecurityEnabled(false);
liveConf.getAcceptorConfigurations()
Modified: trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/MultiThreadRandomFailoverTestBase.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/MultiThreadRandomFailoverTestBase.java 2009-03-23 19:56:44 UTC (rev 6145)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/MultiThreadRandomFailoverTestBase.java 2009-03-24 10:20:42 UTC (rev 6146)
@@ -293,8 +293,6 @@
sendMessages(session, producer, numMessages, threadNum);
- // log.info("sent messages");
-
session.start();
MyHandler handler = new MyHandler(threadNum, numMessages);
@@ -322,8 +320,6 @@
session.deleteQueue(subName);
session.close();
-
- log.info("** done");
}
protected void doTestA(final ClientSessionFactory sf, final int threadNum) throws Exception
@@ -1056,8 +1052,6 @@
sessCreate.deleteQueue(new SimpleString(threadNum + ADDRESS.toString()));
sessCreate.close();
-
- log.info("completed testi");
}
protected void doTestJ(final ClientSessionFactory sf, final int threadNum) throws Exception
@@ -1087,9 +1081,7 @@
message2.acknowledge();
- log.info("** closing session");
sess.close();
- log.info("** closed session");
sessCreate.deleteQueue(new SimpleString(threadNum + ADDRESS.toString()));
@@ -1357,8 +1349,8 @@
backupParams),
0,
1,
- ClientSessionFactoryImpl.DEFAULT_MAX_RETRIES_BEFORE_FAILOVER,
- ClientSessionFactoryImpl.DEFAULT_MAX_RETRIES_AFTER_FAILOVER);
+ ClientSessionFactoryImpl.DEFAULT_INITIAL_CONNECT_ATTEMPTS,
+ ClientSessionFactoryImpl.DEFAULT_RECONNECT_ATTEMPTS);
sf.setSendWindowSize(32 * 1024);
return sf;
@@ -1478,7 +1470,6 @@
public synchronized void onMessage(final ClientMessage message)
{
- // log.info("*** handler got message");
try
{
message.acknowledge();
@@ -1502,8 +1493,6 @@
c = new Integer(cnt);
}
- // log.info(System.identityHashCode(this) + " consumed message " + threadNum + ":" + cnt);
-
if (tn == threadNum && cnt != c.intValue())
{
failure = "Invalid count, expected " + threadNum + ":" + c + " got " + cnt;
Modified: trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/RandomFailoverTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/RandomFailoverTest.java 2009-03-23 19:56:44 UTC (rev 6145)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/RandomFailoverTest.java 2009-03-24 10:20:42 UTC (rev 6146)
@@ -229,8 +229,8 @@
backupParams),
0,
1,
- ClientSessionFactoryImpl.DEFAULT_MAX_RETRIES_BEFORE_FAILOVER,
- ClientSessionFactoryImpl.DEFAULT_MAX_RETRIES_AFTER_FAILOVER);
+ ClientSessionFactoryImpl.DEFAULT_INITIAL_CONNECT_ATTEMPTS,
+ ClientSessionFactoryImpl.DEFAULT_RECONNECT_ATTEMPTS);
sf.setSendWindowSize(32 * 1024);
@@ -1455,10 +1455,6 @@
backupService = Messaging.newNullStorageMessagingService(backupConf);
backupService.start();
- // We need to sleep > 16 ms otherwise the id generators on live and backup could be initialised
- // with the same time component
- Thread.sleep(17);
-
Configuration liveConf = new ConfigurationImpl();
liveConf.setSecurityEnabled(false);
liveConf.getAcceptorConfigurations()
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-03-23 19:56:44 UTC (rev 6145)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/ReconnectTest.java 2009-03-24 10:20:42 UTC (rev 6146)
@@ -80,15 +80,15 @@
final double retryMultiplier = 1d;
- final int maxRetriesBeforeFailover = -1;
+ final int initialConnectAttempts = -1;
- final int maxRetriesAfterFailover = 0;
+ final int reconnectAttempts = 1;
ClientSessionFactoryInternal sf = new ClientSessionFactoryImpl(new TransportConfiguration("org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory"),
retryInterval,
retryMultiplier,
- maxRetriesBeforeFailover,
- maxRetriesAfterFailover);
+ initialConnectAttempts,
+ reconnectAttempts);
ClientSession session = sf.createSession(false, true, true);
@@ -161,15 +161,15 @@
final double retryMultiplier = 1d;
- final int maxRetriesBeforeFailover = -1;
+ final int initialConnectAttempts = -1;
- final int maxRetriesAfterFailover = 0;
+ final int reconnectAttempts = -1;
ClientSessionFactoryInternal sf = new ClientSessionFactoryImpl(new TransportConfiguration("org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory"),
retryInterval,
retryMultiplier,
- maxRetriesBeforeFailover,
- maxRetriesAfterFailover);
+ initialConnectAttempts,
+ reconnectAttempts);
ClientSession session = sf.createSession(false, true, true);
@@ -250,15 +250,15 @@
final double retryMultiplier = 1d;
- final int maxRetriesBeforeFailover = 3;
+ final int initialConnectAttempts = 3;
- final int maxRetriesAfterFailover = 0;
+ final int reconnectAttempts = 0;
ClientSessionFactoryInternal sf = new ClientSessionFactoryImpl(new TransportConfiguration("org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory"),
retryInterval,
retryMultiplier,
- maxRetriesBeforeFailover,
- maxRetriesAfterFailover);
+ initialConnectAttempts,
+ reconnectAttempts);
ClientSession session = sf.createSession(false, true, true);
@@ -295,7 +295,7 @@
{
try
{
- Thread.sleep(retryInterval * (maxRetriesBeforeFailover + 1));
+ Thread.sleep(retryInterval * (initialConnectAttempts + 1));
}
catch (InterruptedException ignore)
{
@@ -329,15 +329,15 @@
final double retryMultiplier = 1d;
- final int maxRetriesBeforeFailover = 3;
+ final int initialConnectAttempts = -1;
- final int maxRetriesAfterFailover = 0;
+ final int reconnectAttempts = 10;
ClientSessionFactoryInternal sf = new ClientSessionFactoryImpl(new TransportConfiguration("org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory"),
retryInterval,
retryMultiplier,
- maxRetriesBeforeFailover,
- maxRetriesAfterFailover);
+ initialConnectAttempts,
+ reconnectAttempts);
ClientSession session = sf.createSession(false, true, true);
@@ -363,7 +363,7 @@
ClientConsumer consumer = session.createConsumer(ADDRESS);
InVMConnector.failOnCreateConnection = true;
- InVMConnector.numberOfFailures = 3;
+ InVMConnector.numberOfFailures = reconnectAttempts - 1;
RemotingConnection conn = ((ClientSessionImpl)session).getConnection();
@@ -399,15 +399,15 @@
final double retryMultiplier = 1d;
- final int maxRetriesBeforeFailover = -1;
+ final int initialConnectAttempts = -1;
- final int maxRetriesAfterFailover = 0;
+ final int reconnectAttempts = -1;
ClientSessionFactoryInternal sf = new ClientSessionFactoryImpl(new TransportConfiguration("org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory"),
retryInterval,
retryMultiplier,
- maxRetriesBeforeFailover,
- maxRetriesAfterFailover);
+ initialConnectAttempts,
+ reconnectAttempts);
ClientSession session = sf.createSession(false, true, true);
@@ -493,15 +493,15 @@
final double retryMultiplier = 4d;
- final int maxRetriesBeforeFailover = -1;
+ final int initialConnectAttempts = -1;
- final int maxRetriesAfterFailover = 0;
+ final int reconnectAttempts = -1;
ClientSessionFactoryInternal sf = new ClientSessionFactoryImpl(new TransportConfiguration("org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory"),
retryInterval,
retryMultiplier,
- maxRetriesBeforeFailover,
- maxRetriesAfterFailover);
+ initialConnectAttempts,
+ reconnectAttempts);
ClientSession session = sf.createSession(false, true, true);
Modified: trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/ReconnectWithBackupTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/ReconnectWithBackupTest.java 2009-03-23 19:56:44 UTC (rev 6145)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/ReconnectWithBackupTest.java 2009-03-24 10:20:42 UTC (rev 6146)
@@ -87,17 +87,17 @@
final double retryMultiplier = 1d;
- final int maxRetriesBeforeFailover = 3;
+ final int initialConnectAttempts = -1;
- final int maxRetriesAfterFailover = 0;
+ final int reconnectAttempts = -1;
ClientSessionFactoryInternal sf = new ClientSessionFactoryImpl(new TransportConfiguration("org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory"),
new TransportConfiguration("org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory",
backupParams),
retryInterval,
retryMultiplier,
- maxRetriesBeforeFailover,
- maxRetriesAfterFailover);
+ initialConnectAttempts,
+ reconnectAttempts);
ClientSession session = sf.createSession(false, true, true);
@@ -164,17 +164,17 @@
final double retryMultiplier = 1d;
- final int maxRetriesBeforeFailover = 0;
+ final int initialConnectAttempts = -1;
- final int maxRetriesAfterFailover = 3;
+ final int reconnectAttempts = -1;
ClientSessionFactoryInternal sf = new ClientSessionFactoryImpl(new TransportConfiguration("org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory"),
new TransportConfiguration("org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory",
backupParams),
retryInterval,
retryMultiplier,
- maxRetriesBeforeFailover,
- maxRetriesAfterFailover);
+ initialConnectAttempts,
+ reconnectAttempts);
ClientSession session = sf.createSession(false, true, true);
Modified: trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/ReplicateConnectionFailureTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/ReplicateConnectionFailureTest.java 2009-03-23 19:56:44 UTC (rev 6145)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/ReplicateConnectionFailureTest.java 2009-03-24 10:20:42 UTC (rev 6146)
@@ -31,12 +31,12 @@
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_CONNECTION_LOAD_BALANCING_POLICY_CLASS_NAME;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_CONSUMER_MAX_RATE;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_CONSUMER_WINDOW_SIZE;
+import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_INITIAL_CONNECT_ATTEMPTS;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_MAX_CONNECTIONS;
-import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_MAX_RETRIES_AFTER_FAILOVER;
-import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_MAX_RETRIES_BEFORE_FAILOVER;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_MIN_LARGE_MESSAGE_SIZE;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_PRE_ACKNOWLEDGE;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_PRODUCER_MAX_RATE;
+import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_RECONNECT_ATTEMPTS;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_RETRY_INTERVAL;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_RETRY_INTERVAL_MULTIPLIER;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_SEND_WINDOW_SIZE;
@@ -115,25 +115,31 @@
DEFAULT_ACK_BATCH_SIZE,
DEFAULT_RETRY_INTERVAL,
DEFAULT_RETRY_INTERVAL_MULTIPLIER,
- DEFAULT_MAX_RETRIES_BEFORE_FAILOVER,
- DEFAULT_MAX_RETRIES_AFTER_FAILOVER);
+ DEFAULT_INITIAL_CONNECT_ATTEMPTS,
+ DEFAULT_RECONNECT_ATTEMPTS);
sf1.setSendWindowSize(32 * 1024);
assertEquals(0, liveService.getServer().getRemotingService().getConnections().size());
- assertEquals(0, backupService.getServer().getRemotingService().getConnections().size());
+ assertEquals(1, backupService.getServer().getRemotingService().getConnections().size());
ClientSession session1 = sf1.createSession(false, true, true);
// One connection
assertEquals(1, liveService.getServer().getRemotingService().getConnections().size());
- // One replicating connection per session
+ // One replicating connection
assertEquals(1, backupService.getServer().getRemotingService().getConnections().size());
session1.close();
+
+ Thread.sleep(2000);
+
+ assertEquals(0, liveService.getServer().getRemotingService().getConnections().size());
+ assertEquals(1, backupService.getServer().getRemotingService().getConnections().size());
+
log.info("recreating");
session1 = sf1.createSession(false, true, 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-03-23 19:56:44 UTC (rev 6145)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/SimpleAutomaticFailoverTest.java 2009-03-24 10:20:42 UTC (rev 6146)
@@ -518,7 +518,7 @@
assertEquals(0, sf.numSessions());
assertEquals(0, sf.numConnections());
-
+
log.info("** got to end");
}
@@ -595,17 +595,17 @@
final double retryMultiplier = 1d;
- final int maxRetriesBeforeFailover = 0;
+ final int initialConnectAttempts = -1;
- final int maxRetriesAfterFailover = 0;
+ final int reconnectAttempts = 0;
ClientSessionFactoryInternal sf = new ClientSessionFactoryImpl(new TransportConfiguration("org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory"),
new TransportConfiguration("org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory",
backupParams),
retryInterval,
retryMultiplier,
- maxRetriesBeforeFailover,
- maxRetriesAfterFailover);
+ initialConnectAttempts,
+ reconnectAttempts);
sf.setSendWindowSize(32 * 1024);
@@ -696,14 +696,18 @@
public void testFailoverOnCreateSession() throws Exception
{
stopServers();
-
+
for (int j = 0; j < 10; j++)
{
startServers();
ClientSessionFactoryInternal sf = new ClientSessionFactoryImpl(new TransportConfiguration("org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory"),
new TransportConfiguration("org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory",
- backupParams));
+ backupParams),
+ 100,
+ 1,
+ -1,
+ -1);
sf.setSendWindowSize(32 * 1024);
@@ -771,6 +775,57 @@
}
}
+ public void testFailoverWithNotifications() throws Exception
+ {
+ ClientSessionFactoryInternal sf = new ClientSessionFactoryImpl(new TransportConfiguration("org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory"),
+ new TransportConfiguration("org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory",
+ backupParams));
+
+ sf.setSendWindowSize(32 * 1024);
+
+ ClientSession sess = sf.createSession(false, true, true);
+
+ sess.createQueue("jbm.admin.notification", "notifqueue", false);
+
+ ClientConsumer cons = sess.createConsumer("notifqueue");
+
+ sess.start();
+
+ sess.createQueue("blah", "blah", false);
+ sess.createQueue("blah", "blah2", false);
+
+ ClientMessage msg = cons.receive(1000);
+ assertNotNull(msg);
+ msg.acknowledge();
+
+ msg = cons.receive(1000);
+ assertNotNull(msg);
+ msg.acknowledge();
+
+ sess.stop();
+
+ sess.createQueue("blah", "blah3", false);
+ sess.createQueue("blah", "blah4", false);
+
+ RemotingConnection conn = ((ClientSessionImpl)sess).getConnection();
+
+ // Simulate failure on connection
+ conn.fail(new MessagingException(MessagingException.NOT_CONNECTED));
+
+ sess.start();
+
+ msg = cons.receive(1000);
+ assertNotNull(msg);
+ msg.acknowledge();
+
+ msg = cons.receive(1000);
+ assertNotNull(msg);
+ msg.acknowledge();
+
+ sess.close();
+
+ }
+
// Package protected ---------------------------------------------
// Protected -----------------------------------------------------
@@ -821,7 +876,7 @@
protected void setUp() throws Exception
{
super.setUp();
-
+
startServers();
}
@@ -829,7 +884,7 @@
protected void tearDown() throws Exception
{
stopServers();
-
+
super.tearDown();
}
Modified: trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/XAMultiThreadRandomFailoverTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/XAMultiThreadRandomFailoverTest.java 2009-03-23 19:56:44 UTC (rev 6145)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/XAMultiThreadRandomFailoverTest.java 2009-03-24 10:20:42 UTC (rev 6146)
@@ -12,6 +12,9 @@
package org.jboss.messaging.tests.integration.cluster.failover;
+import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_INITIAL_CONNECT_ATTEMPTS;
+import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_RECONNECT_ATTEMPTS;
+
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
@@ -643,8 +646,8 @@
backupParams),
0,
1,
- ClientSessionFactoryImpl.DEFAULT_MAX_RETRIES_BEFORE_FAILOVER,
- ClientSessionFactoryImpl.DEFAULT_MAX_RETRIES_AFTER_FAILOVER);
+ DEFAULT_INITIAL_CONNECT_ATTEMPTS,
+ DEFAULT_RECONNECT_ATTEMPTS);
sf.setSendWindowSize(32 * 1024);
return sf;
Modified: trunk/tests/src/org/jboss/messaging/tests/integration/cluster/management/ReplicationAwareQueueControlWrapperTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/cluster/management/ReplicationAwareQueueControlWrapperTest.java 2009-03-23 19:56:44 UTC (rev 6145)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/cluster/management/ReplicationAwareQueueControlWrapperTest.java 2009-03-24 10:20:42 UTC (rev 6146)
@@ -30,13 +30,13 @@
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_CONNECTION_TTL;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_CONSUMER_MAX_RATE;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_CONSUMER_WINDOW_SIZE;
+import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_INITIAL_CONNECT_ATTEMPTS;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_MAX_CONNECTIONS;
-import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_MAX_RETRIES_AFTER_FAILOVER;
-import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_MAX_RETRIES_BEFORE_FAILOVER;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_MIN_LARGE_MESSAGE_SIZE;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_PING_PERIOD;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_PRE_ACKNOWLEDGE;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_PRODUCER_MAX_RATE;
+import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_RECONNECT_ATTEMPTS;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_RETRY_INTERVAL;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_RETRY_INTERVAL_MULTIPLIER;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_SEND_WINDOW_SIZE;
@@ -492,8 +492,8 @@
DEFAULT_ACK_BATCH_SIZE,
DEFAULT_RETRY_INTERVAL,
DEFAULT_RETRY_INTERVAL_MULTIPLIER,
- DEFAULT_MAX_RETRIES_BEFORE_FAILOVER,
- DEFAULT_MAX_RETRIES_AFTER_FAILOVER);
+ DEFAULT_INITIAL_CONNECT_ATTEMPTS,
+ DEFAULT_RECONNECT_ATTEMPTS);
session = sf.createSession(false, true, true);
Modified: trunk/tests/src/org/jboss/messaging/tests/integration/http/NettyHttpTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/http/NettyHttpTest.java 2009-03-23 19:56:44 UTC (rev 6145)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/http/NettyHttpTest.java 2009-03-24 10:20:42 UTC (rev 6146)
@@ -45,9 +45,9 @@
private NettyAcceptor acceptor;
private NettyConnector connector;
-
+
public void testFoo()
- {
+ {
}
public void testSendAndReceiveAtSameTime() throws Exception
@@ -92,7 +92,7 @@
assertTrue(i == j);
i++;
}
- i = 0;
+ i = 0;
for (Integer j : connectorHandler.messages)
{
assertTrue(i == j);
@@ -100,9 +100,24 @@
}
}
+ public void testFail() throws Exception
+ {
+ tearDown();
+
+ for (int k = 0; k < 1000; k++)
+ {
+ setUp();
+ testSendAndReceiveAtSameTime();
+ tearDown();
+
+ setUp();
+ testSendThenReceive();
+ tearDown();
+ }
+ }
+
public void testSendThenReceive() throws Exception
{
-
int numPackets = 1000;
CountDownLatch connCreatedLatch = new CountDownLatch(1);
CountDownLatch acceptorLatch = new CountDownLatch(numPackets);
@@ -145,7 +160,7 @@
assertTrue(i == j);
i++;
}
- i = 0;
+ i = 0;
for (Integer j : connectorHandler.messages)
{
assertTrue(i == j);
@@ -199,7 +214,7 @@
assertTrue(i == j);
i++;
}
- i = 0;
+ i = 0;
for (Integer j : connectorHandler.messages)
{
assertTrue(i == j);
@@ -235,7 +250,6 @@
acceptorListener.connection.write(buff);
}
-
MessagingBuffer buff = conn.createBuffer(8);
buff.writeInt(4);
buff.writeInt(0);
@@ -252,7 +266,7 @@
assertTrue(i == j);
i++;
}
- i = 0;
+ i = 0;
for (Integer j : connectorHandler.messages)
{
assertTrue(i == j);
@@ -300,7 +314,7 @@
assertTrue(i == j);
i++;
}
- i = 0;
+ i = 0;
for (Integer j : connectorHandler.messages)
{
assertTrue(i == j);
@@ -353,17 +367,17 @@
@Override
protected void tearDown() throws Exception
{
- if(connector != null)
+ if (connector != null)
{
connector.close();
connector = null;
}
- if(acceptor != null)
+ if (acceptor != null)
{
acceptor.stop();
acceptor = null;
}
-
+
super.tearDown();
}
@@ -372,6 +386,7 @@
int messagesReceieved = 0;
ArrayList<Integer> messages = new ArrayList<Integer>();
+
private CountDownLatch latch;
public SimpleBufferHandler(CountDownLatch latch)
@@ -379,7 +394,6 @@
this.latch = latch;
}
-
public void bufferReceived(Object connectionID, MessagingBuffer buffer)
{
int i = buffer.readInt();
@@ -394,6 +408,7 @@
int messagesReceieved = 0;
ArrayList<Integer> messages = new ArrayList<Integer>();
+
private CountDownLatch latch;
public BogusResponseHandler(CountDownLatch latch)
@@ -428,7 +443,7 @@
public void connectionCreated(Connection connection)
{
- this.connection = connection;
+ this.connection = connection;
if (latch != null)
{
latch.countDown();
Modified: trunk/tests/src/org/jboss/messaging/tests/integration/jms/bridge/BridgeTestBase.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/jms/bridge/BridgeTestBase.java 2009-03-23 19:56:44 UTC (rev 6145)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/jms/bridge/BridgeTestBase.java 2009-03-24 10:20:42 UTC (rev 6146)
@@ -23,17 +23,18 @@
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_ACK_BATCH_SIZE;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_AUTO_GROUP;
-import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_ACKNOWLEDGE;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_CALL_TIMEOUT;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_CONNECTION_LOAD_BALANCING_POLICY_CLASS_NAME;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_CONNECTION_TTL;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_CONSUMER_MAX_RATE;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_CONSUMER_WINDOW_SIZE;
+import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_INITIAL_CONNECT_ATTEMPTS;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_MAX_CONNECTIONS;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_MIN_LARGE_MESSAGE_SIZE;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_PING_PERIOD;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_PRE_ACKNOWLEDGE;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_PRODUCER_MAX_RATE;
+import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_RECONNECT_ATTEMPTS;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_RETRY_INTERVAL;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_RETRY_INTERVAL_MULTIPLIER;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_SEND_WINDOW_SIZE;
@@ -90,17 +91,18 @@
public abstract class BridgeTestBase extends UnitTestCase
{
private static final Logger log = Logger.getLogger(BridgeTestBase.class);
-
+
protected static ConnectionFactoryFactory cff0, cff1;
-
+
protected static ConnectionFactory cf0, cf1;
-
- protected static DestinationFactory sourceQueueFactory, targetQueueFactory, localTargetQueueFactory, sourceTopicFactory;
-
+
+ protected static DestinationFactory sourceQueueFactory, targetQueueFactory, localTargetQueueFactory,
+ sourceTopicFactory;
+
protected static Queue sourceQueue, targetQueue, localTargetQueue;
-
+
protected static Topic sourceTopic;
-
+
protected static boolean firstTime = true;
protected MessagingServiceImpl server0;
@@ -117,22 +119,21 @@
private HashMap<String, Object> params1;
-
protected void setUp() throws Exception
{
super.setUp();
- //Start the servers
+ // Start the servers
Configuration conf0 = new ConfigurationImpl();
conf0.setSecurityEnabled(false);
conf0.getAcceptorConfigurations()
- .add(new TransportConfiguration("org.jboss.messaging.core.remoting.impl.invm.InVMAcceptorFactory"));
+ .add(new TransportConfiguration("org.jboss.messaging.core.remoting.impl.invm.InVMAcceptorFactory"));
server0 = Messaging.newNullStorageMessagingService(conf0);
server0.start();
context0 = new InVMContext();
jmsServer0 = JMSServerManagerImpl.newJMSServerManagerImpl(server0.getServer());
- jmsServer0.start();
+ jmsServer0.start();
jmsServer0.setContext(context0);
Configuration conf1 = new ConfigurationImpl();
@@ -140,9 +141,8 @@
params1 = new HashMap<String, Object>();
params1.put(TransportConstants.SERVER_ID_PROP_NAME, 1);
conf1.getAcceptorConfigurations()
- .add(new TransportConfiguration("org.jboss.messaging.core.remoting.impl.invm.InVMAcceptorFactory",
- params1));
- conf1.setBackup(true);
+ .add(new TransportConfiguration("org.jboss.messaging.core.remoting.impl.invm.InVMAcceptorFactory", params1));
+
server1 = Messaging.newNullStorageMessagingService(conf1);
server1.start();
@@ -161,9 +161,9 @@
setUpAdministeredObjects();
- //We need a local transaction and recovery manager
- //We must start this after the remote servers have been created or it won't
- //have deleted the database and the recovery manager may attempt to recover transactions
+ // We need a local transaction and recovery manager
+ // We must start this after the remote servers have been created or it won't
+ // have deleted the database and the recovery manager may attempt to recover transactions
firstTime = false;
@@ -176,67 +176,68 @@
{
server = jmsServer1;
}
- server.createQueue(queueName, "/queue/" + queueName);
+ server.createQueue(queueName, "/queue/" + queueName);
}
-
protected void tearDown() throws Exception
- {
+ {
checkEmpty(sourceQueue, 0);
checkEmpty(localTargetQueue, 0);
checkEmpty(targetQueue, 1);
-
+
// Check no subscriptions left lying around
-
+
checkNoSubscriptions(sourceTopic, 0);
-
+
server1.stop();
server0.stop();
-
- super.tearDown();
+
+ super.tearDown();
}
-
+
protected void setUpAdministeredObjects() throws Exception
{
cff0 = new ConnectionFactoryFactory()
{
public ConnectionFactory createConnectionFactory() throws Exception
{
+ //Note! We disable automatic reconnection on the session factory. The bridge needs to do the reconnection
return new JBossConnectionFactory(new TransportConfiguration(InVMConnectorFactory.class.getName()),
- null,
- DEFAULT_CONNECTION_LOAD_BALANCING_POLICY_CLASS_NAME,
- DEFAULT_PING_PERIOD,
- DEFAULT_CONNECTION_TTL,
- DEFAULT_CALL_TIMEOUT,
- null,
- DEFAULT_ACK_BATCH_SIZE,
- DEFAULT_ACK_BATCH_SIZE,
- DEFAULT_CONSUMER_WINDOW_SIZE,
- DEFAULT_CONSUMER_MAX_RATE,
- DEFAULT_SEND_WINDOW_SIZE,
- DEFAULT_PRODUCER_MAX_RATE,
- DEFAULT_MIN_LARGE_MESSAGE_SIZE,
- true,
- true,
- true,
- DEFAULT_AUTO_GROUP,
- DEFAULT_MAX_CONNECTIONS,
- DEFAULT_PRE_ACKNOWLEDGE,
- DEFAULT_RETRY_INTERVAL,
- DEFAULT_RETRY_INTERVAL_MULTIPLIER,
- 0,
- 0);
+ null,
+ DEFAULT_CONNECTION_LOAD_BALANCING_POLICY_CLASS_NAME,
+ DEFAULT_PING_PERIOD,
+ DEFAULT_CONNECTION_TTL,
+ DEFAULT_CALL_TIMEOUT,
+ null,
+ DEFAULT_ACK_BATCH_SIZE,
+ DEFAULT_ACK_BATCH_SIZE,
+ DEFAULT_CONSUMER_WINDOW_SIZE,
+ DEFAULT_CONSUMER_MAX_RATE,
+ DEFAULT_SEND_WINDOW_SIZE,
+ DEFAULT_PRODUCER_MAX_RATE,
+ DEFAULT_MIN_LARGE_MESSAGE_SIZE,
+ true,
+ true,
+ true,
+ DEFAULT_AUTO_GROUP,
+ DEFAULT_MAX_CONNECTIONS,
+ DEFAULT_PRE_ACKNOWLEDGE,
+ DEFAULT_RETRY_INTERVAL,
+ DEFAULT_RETRY_INTERVAL_MULTIPLIER,
+ 1,
+ 0);
}
-
+
};
-
+
cf0 = cff0.createConnectionFactory();
-
+
cff1 = new ConnectionFactoryFactory()
{
public ConnectionFactory createConnectionFactory() throws Exception
{
+ //Note! We disable automatic reconnection on the session factory. The bridge needs to do the reconnection
return new JBossConnectionFactory(new TransportConfiguration(InVMConnectorFactory.class.getName(), params1),
null,
DEFAULT_CONNECTION_LOAD_BALANCING_POLICY_CLASS_NAME,
@@ -256,22 +257,22 @@
true,
DEFAULT_AUTO_GROUP,
DEFAULT_MAX_CONNECTIONS,
- DEFAULT_PRE_ACKNOWLEDGE,
+ DEFAULT_PRE_ACKNOWLEDGE,
DEFAULT_RETRY_INTERVAL,
DEFAULT_RETRY_INTERVAL_MULTIPLIER,
- 0,
+ 1,
0);
- }
+ }
};
-
+
cf1 = cff1.createConnectionFactory();
-
+
sourceQueueFactory = new DestinationFactory()
{
public Destination createDestination() throws Exception
{
return (Destination)context0.lookup("/queue/sourceQueue");
- }
+ }
};
sourceQueue = (Queue)sourceQueueFactory.createDestination();
@@ -281,7 +282,7 @@
public Destination createDestination() throws Exception
{
return (Destination)context1.lookup("/queue/targetQueue");
- }
+ }
};
targetQueue = (Queue)targetQueueFactory.createDestination();
@@ -291,7 +292,7 @@
public Destination createDestination() throws Exception
{
return (Destination)context0.lookup("/topic/sourceTopic");
- }
+ }
};
sourceTopic = (Topic)sourceTopicFactory.createDestination();
@@ -301,31 +302,30 @@
public Destination createDestination() throws Exception
{
return (Destination)context0.lookup("/queue/localTargetQueue");
- }
+ }
};
localTargetQueue = (Queue)localTargetQueueFactory.createDestination();
}
-
- protected void sendMessages(ConnectionFactory cf, Destination dest, int start, int numMessages, boolean persistent)
- throws Exception
+
+ protected void sendMessages(ConnectionFactory cf, Destination dest, int start, int numMessages, boolean persistent) throws Exception
{
Connection conn = null;
-
+
try
{
conn = cf.createConnection();
-
+
Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
+
MessageProducer prod = sess.createProducer(dest);
-
+
prod.setDeliveryMode(persistent ? DeliveryMode.PERSISTENT : DeliveryMode.NON_PERSISTENT);
-
+
for (int i = start; i < start + numMessages; i++)
{
TextMessage tm = sess.createTextMessage("message" + i);
-
+
prod.send(tm);
}
}
@@ -337,71 +337,73 @@
}
}
}
-
- protected void checkMessagesReceived(ConnectionFactory cf, Destination dest, QualityOfServiceMode qosMode,
- int numMessages, boolean longWaitForFirst) throws Exception
+ protected void checkMessagesReceived(ConnectionFactory cf,
+ Destination dest,
+ QualityOfServiceMode qosMode,
+ int numMessages,
+ boolean longWaitForFirst) throws Exception
{
Connection conn = null;
-
+
try
{
conn = cf.createConnection();
-
+
conn.start();
-
+
Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
+
MessageConsumer cons = sess.createConsumer(dest);
-
+
// Consume the messages
-
+
Set msgs = new HashSet();
-
+
int count = 0;
-
- //We always wait longer for the first one - it may take some time to arrive especially if we are
- //waiting for recovery to kick in
+
+ // We always wait longer for the first one - it may take some time to arrive especially if we are
+ // waiting for recovery to kick in
while (true)
{
TextMessage tm = (TextMessage)cons.receive(count == 0 ? (longWaitForFirst ? 60000 : 10000) : 5000);
-
+
if (tm == null)
{
break;
}
-
- //log.info("Got message " + tm.getText());
-
+
+ // log.info("Got message " + tm.getText());
+
msgs.add(tm.getText());
count++;
-
+
}
-
+
if (qosMode == QualityOfServiceMode.ONCE_AND_ONLY_ONCE || qosMode == QualityOfServiceMode.DUPLICATES_OK)
- {
- //All the messages should be received
-
+ {
+ // All the messages should be received
+
for (int i = 0; i < numMessages; i++)
{
assertTrue("" + i, msgs.contains("message" + i));
}
-
- //Should be no more
+
+ // Should be no more
if (qosMode == QualityOfServiceMode.ONCE_AND_ONLY_ONCE)
{
assertEquals(numMessages, msgs.size());
- }
+ }
}
else if (qosMode == QualityOfServiceMode.AT_MOST_ONCE)
{
- //No *guarantee* that any messages will be received
- //but you still might get some depending on how/where the crash occurred
- }
+ // No *guarantee* that any messages will be received
+ // but you still might get some depending on how/where the crash occurred
+ }
log.trace("Check complete");
-
+
}
finally
{
@@ -409,35 +411,34 @@
{
conn.close();
}
- }
+ }
}
-
-
+
protected void checkAllMessageReceivedInOrder(ConnectionFactory cf, Destination dest, int start, int numMessages) throws Exception
{
- Connection conn = null;
+ Connection conn = null;
try
{
conn = cf.createConnection();
-
+
conn.start();
-
+
Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
+
MessageConsumer cons = sess.createConsumer(dest);
-
+
// Consume the messages
-
+
for (int i = 0; i < numMessages; i++)
- {
+ {
TextMessage tm = (TextMessage)cons.receive(30000);
-
+
assertNotNull(tm);
-
- //log.info("Got message " + tm.getText());
-
+
+ // log.info("Got message " + tm.getText());
+
assertEquals("message" + (i + start), tm.getText());
- }
+ }
}
finally
{
@@ -445,7 +446,7 @@
{
conn.close();
}
- }
+ }
}
public boolean checkEmpty(Queue queue, int index) throws Exception
@@ -459,14 +460,14 @@
JMSQueueControlMBean queueControl = (JMSQueueControlMBean)managementService.getResource(objectName);
Integer messageCount = queueControl.getMessageCount();
-
+
if (messageCount > 0)
{
queueControl.removeAllMessages();
}
return true;
}
-
+
protected void checkNoSubscriptions(Topic topic, int index) throws Exception
{
ManagementService managementService = server0.getServer().getManagementService();
@@ -496,8 +497,7 @@
{
return new TransactionManagerImple();
}
-
+
// Inner classes -------------------------------------------------------------------
-
+
}
-
Modified: trunk/tests/src/org/jboss/messaging/tests/integration/jms/cluster/JMSFailoverTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/jms/cluster/JMSFailoverTest.java 2009-03-23 19:56:44 UTC (rev 6145)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/jms/cluster/JMSFailoverTest.java 2009-03-24 10:20:42 UTC (rev 6146)
@@ -31,13 +31,13 @@
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_CONNECTION_TTL;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_CONSUMER_MAX_RATE;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_CONSUMER_WINDOW_SIZE;
+import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_INITIAL_CONNECT_ATTEMPTS;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_MAX_CONNECTIONS;
-import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_MAX_RETRIES_AFTER_FAILOVER;
-import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_MAX_RETRIES_BEFORE_FAILOVER;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_MIN_LARGE_MESSAGE_SIZE;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_PING_PERIOD;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_PRE_ACKNOWLEDGE;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_PRODUCER_MAX_RATE;
+import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_RECONNECT_ATTEMPTS;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_RETRY_INTERVAL;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_RETRY_INTERVAL_MULTIPLIER;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_SEND_WINDOW_SIZE;
@@ -55,6 +55,7 @@
import javax.jms.TextMessage;
import org.jboss.messaging.core.client.ClientSession;
+import org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl;
import org.jboss.messaging.core.client.impl.ClientSessionImpl;
import org.jboss.messaging.core.config.Configuration;
import org.jboss.messaging.core.config.TransportConfiguration;
@@ -130,8 +131,8 @@
DEFAULT_PRE_ACKNOWLEDGE,
DEFAULT_RETRY_INTERVAL,
DEFAULT_RETRY_INTERVAL_MULTIPLIER,
- DEFAULT_MAX_RETRIES_BEFORE_FAILOVER,
- DEFAULT_MAX_RETRIES_AFTER_FAILOVER);
+ DEFAULT_INITIAL_CONNECT_ATTEMPTS,
+ DEFAULT_RECONNECT_ATTEMPTS);
Connection conn = jbcf.createConnection();
@@ -212,8 +213,8 @@
DEFAULT_PRE_ACKNOWLEDGE,
DEFAULT_RETRY_INTERVAL,
DEFAULT_RETRY_INTERVAL_MULTIPLIER,
- 0,
- 0);
+ DEFAULT_INITIAL_CONNECT_ATTEMPTS,
+ DEFAULT_RECONNECT_ATTEMPTS);
JBossConnectionFactory jbcfBackup = new JBossConnectionFactory(new TransportConfiguration("org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory",
backupParams),
@@ -238,8 +239,8 @@
DEFAULT_PRE_ACKNOWLEDGE,
DEFAULT_RETRY_INTERVAL,
DEFAULT_RETRY_INTERVAL_MULTIPLIER,
- 0,
- 0);
+ DEFAULT_INITIAL_CONNECT_ATTEMPTS,
+ DEFAULT_RECONNECT_ATTEMPTS);
Connection connLive = jbcfLive.createConnection();
Modified: trunk/tests/src/org/jboss/messaging/tests/integration/jms/consumer/ConsumerTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/jms/consumer/ConsumerTest.java 2009-03-23 19:56:44 UTC (rev 6145)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/jms/consumer/ConsumerTest.java 2009-03-24 10:20:42 UTC (rev 6146)
@@ -30,12 +30,12 @@
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_CONNECTION_TTL;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_CONSUMER_MAX_RATE;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_CONSUMER_WINDOW_SIZE;
+import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_INITIAL_CONNECT_ATTEMPTS;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_MAX_CONNECTIONS;
-import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_MAX_RETRIES_AFTER_FAILOVER;
-import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_MAX_RETRIES_BEFORE_FAILOVER;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_MIN_LARGE_MESSAGE_SIZE;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_PING_PERIOD;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_PRODUCER_MAX_RATE;
+import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_RECONNECT_ATTEMPTS;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_RETRY_INTERVAL;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_RETRY_INTERVAL_MULTIPLIER;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_SEND_WINDOW_SIZE;
@@ -113,8 +113,8 @@
true,
DEFAULT_RETRY_INTERVAL,
DEFAULT_RETRY_INTERVAL_MULTIPLIER,
- DEFAULT_MAX_RETRIES_BEFORE_FAILOVER,
- DEFAULT_MAX_RETRIES_AFTER_FAILOVER);
+ DEFAULT_INITIAL_CONNECT_ATTEMPTS,
+ DEFAULT_RECONNECT_ATTEMPTS);
}
@Override
Modified: trunk/tests/src/org/jboss/messaging/tests/integration/jms/management/JMSQueueControlTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/jms/management/JMSQueueControlTest.java 2009-03-23 19:56:44 UTC (rev 6145)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/jms/management/JMSQueueControlTest.java 2009-03-24 10:20:42 UTC (rev 6146)
@@ -31,13 +31,13 @@
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_CONNECTION_TTL;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_CONSUMER_MAX_RATE;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_CONSUMER_WINDOW_SIZE;
+import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_INITIAL_CONNECT_ATTEMPTS;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_MAX_CONNECTIONS;
-import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_MAX_RETRIES_AFTER_FAILOVER;
-import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_MAX_RETRIES_BEFORE_FAILOVER;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_MIN_LARGE_MESSAGE_SIZE;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_PING_PERIOD;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_PRE_ACKNOWLEDGE;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_PRODUCER_MAX_RATE;
+import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_RECONNECT_ATTEMPTS;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_RETRY_INTERVAL;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_RETRY_INTERVAL_MULTIPLIER;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_SEND_WINDOW_SIZE;
@@ -56,6 +56,7 @@
import javax.management.openmbean.TabularData;
import javax.naming.Context;
+import org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl;
import org.jboss.messaging.core.config.Configuration;
import org.jboss.messaging.core.config.TransportConfiguration;
import org.jboss.messaging.core.config.impl.ConfigurationImpl;
@@ -203,6 +204,7 @@
assertEquals(0, queueControl.getMessageCount());
Connection conn = createConnection();
+
Session s = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
MessageProducer producer = s.createProducer(queue);
@@ -717,8 +719,8 @@
DEFAULT_PRE_ACKNOWLEDGE,
DEFAULT_RETRY_INTERVAL,
DEFAULT_RETRY_INTERVAL_MULTIPLIER,
- DEFAULT_MAX_RETRIES_BEFORE_FAILOVER,
- DEFAULT_MAX_RETRIES_AFTER_FAILOVER);
+ DEFAULT_INITIAL_CONNECT_ATTEMPTS,
+ DEFAULT_RECONNECT_ATTEMPTS);
return cf.createConnection();
}
Modified: trunk/tests/src/org/jboss/messaging/tests/integration/jms/management/JMSServerControl2Test.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/jms/management/JMSServerControl2Test.java 2009-03-23 19:56:44 UTC (rev 6145)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/jms/management/JMSServerControl2Test.java 2009-03-24 10:20:42 UTC (rev 6146)
@@ -151,8 +151,8 @@
ClientSessionFactoryImpl.DEFAULT_PRE_ACKNOWLEDGE,
ClientSessionFactoryImpl.DEFAULT_RETRY_INTERVAL,
ClientSessionFactoryImpl.DEFAULT_RETRY_INTERVAL_MULTIPLIER,
- ClientSessionFactoryImpl.DEFAULT_MAX_RETRIES_BEFORE_FAILOVER,
- ClientSessionFactoryImpl.DEFAULT_MAX_RETRIES_AFTER_FAILOVER,
+ ClientSessionFactoryImpl.DEFAULT_INITIAL_CONNECT_ATTEMPTS,
+ ClientSessionFactoryImpl.DEFAULT_RECONNECT_ATTEMPTS,
cfJNDIBinding);
Object o = checkBinding(context, cfJNDIBinding);
@@ -438,7 +438,7 @@
}
}
}
-
+
// Inner classes -------------------------------------------------
}
\ No newline at end of file
Modified: trunk/tests/src/org/jboss/messaging/tests/integration/jms/management/JMSServerControlTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/jms/management/JMSServerControlTest.java 2009-03-23 19:56:44 UTC (rev 6145)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/jms/management/JMSServerControlTest.java 2009-03-24 10:20:42 UTC (rev 6146)
@@ -121,7 +121,6 @@
checkNoBinding(context, queueJNDIBinding);
checkNoResource(ObjectNames.getJMSQueueObjectName(queueName));
-
}
public void testCreateTopic() throws Exception
@@ -236,8 +235,8 @@
int maxConnections = randomPositiveInt();
long retryInterval = randomPositiveLong();
double retryIntervalMultiplier = randomDouble();
- int maxRetriesBeforeFailover = randomPositiveInt();
- int maxRetriesAfterFailover = randomPositiveInt();
+ int initialConnectAttempts = randomPositiveInt();
+ int reconnectAttempts = randomPositiveInt();
boolean preAcknowledge = randomBoolean();
boolean blockOnAcknowledge = randomBoolean();
boolean blockOnNonPersistentSend = randomBoolean();
@@ -270,8 +269,8 @@
preAcknowledge,
retryInterval,
retryIntervalMultiplier,
- maxRetriesBeforeFailover,
- maxRetriesAfterFailover,
+ initialConnectAttempts,
+ reconnectAttempts,
cfJNDIBinding);
Object o = checkBinding(context, cfJNDIBinding);
@@ -299,8 +298,8 @@
assertEquals(maxConnections, cfControl.getMaxConnections());
assertEquals(retryInterval, cfControl.getRetryInterval());
assertEquals(retryIntervalMultiplier, cfControl.getRetryIntervalMultiplier());
- assertEquals(maxRetriesBeforeFailover, cfControl.getMaxRetriesBeforeFailover());
- assertEquals(maxRetriesAfterFailover, cfControl.getMaxRetriesAfterFailover());
+ assertEquals(initialConnectAttempts, cfControl.getInitialConnectAttempts());
+ assertEquals(reconnectAttempts, cfControl.getReconnectAttempts());
assertEquals(preAcknowledge, cfControl.isPreAcknowledge());
assertEquals(blockOnAcknowledge, cfControl.isBlockOnAcknowledge());
assertEquals(blockOnNonPersistentSend, cfControl.isBlockOnNonPersistentSend());
Modified: trunk/tests/src/org/jboss/messaging/tests/integration/jms/management/JMSUtil.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/jms/management/JMSUtil.java 2009-03-23 19:56:44 UTC (rev 6145)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/jms/management/JMSUtil.java 2009-03-24 10:20:42 UTC (rev 6146)
@@ -31,13 +31,13 @@
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_CONNECTION_TTL;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_CONSUMER_MAX_RATE;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_CONSUMER_WINDOW_SIZE;
+import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_INITIAL_CONNECT_ATTEMPTS;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_MAX_CONNECTIONS;
-import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_MAX_RETRIES_AFTER_FAILOVER;
-import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_MAX_RETRIES_BEFORE_FAILOVER;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_MIN_LARGE_MESSAGE_SIZE;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_PING_PERIOD;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_PRE_ACKNOWLEDGE;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_PRODUCER_MAX_RATE;
+import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_RECONNECT_ATTEMPTS;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_RETRY_INTERVAL;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_RETRY_INTERVAL_MULTIPLIER;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_SEND_WINDOW_SIZE;
@@ -102,8 +102,8 @@
DEFAULT_PRE_ACKNOWLEDGE,
DEFAULT_RETRY_INTERVAL,
DEFAULT_RETRY_INTERVAL_MULTIPLIER,
- DEFAULT_MAX_RETRIES_BEFORE_FAILOVER,
- DEFAULT_MAX_RETRIES_AFTER_FAILOVER);
+ DEFAULT_INITIAL_CONNECT_ATTEMPTS,
+ DEFAULT_RECONNECT_ATTEMPTS);
return cf.createConnection();
}
@@ -132,8 +132,8 @@
DEFAULT_PRE_ACKNOWLEDGE,
DEFAULT_RETRY_INTERVAL,
DEFAULT_RETRY_INTERVAL_MULTIPLIER,
- DEFAULT_MAX_RETRIES_BEFORE_FAILOVER,
- DEFAULT_MAX_RETRIES_AFTER_FAILOVER);
+ DEFAULT_INITIAL_CONNECT_ATTEMPTS,
+ DEFAULT_RECONNECT_ATTEMPTS);
Connection conn = cf.createConnection();
@@ -178,8 +178,8 @@
DEFAULT_PRE_ACKNOWLEDGE,
DEFAULT_RETRY_INTERVAL,
DEFAULT_RETRY_INTERVAL_MULTIPLIER,
- DEFAULT_MAX_RETRIES_BEFORE_FAILOVER,
- DEFAULT_MAX_RETRIES_AFTER_FAILOVER);
+ DEFAULT_INITIAL_CONNECT_ATTEMPTS,
+ DEFAULT_RECONNECT_ATTEMPTS);
Connection conn = cf.createConnection();
Modified: trunk/tests/src/org/jboss/messaging/tests/integration/management/BridgeControlTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/management/BridgeControlTest.java 2009-03-23 19:56:44 UTC (rev 6145)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/management/BridgeControlTest.java 2009-03-24 10:20:42 UTC (rev 6146)
@@ -87,8 +87,8 @@
assertEquals(bridgeConfig.getFilterString(), bridgeControl.getFilterString());
assertEquals(bridgeConfig.getRetryInterval(), bridgeControl.getRetryInterval());
assertEquals(bridgeConfig.getRetryIntervalMultiplier(), bridgeControl.getRetryIntervalMultiplier());
- assertEquals(bridgeConfig.getMaxRetriesBeforeFailover(), bridgeControl.getMaxRetriesBeforeFailover());
- assertEquals(bridgeConfig.getMaxRetriesAfterFailover(), bridgeControl.getMaxRetriesAfterFailover());
+ assertEquals(bridgeConfig.getInitialConnectAttempts(), bridgeControl.getInitialConnectAttempts());
+ assertEquals(bridgeConfig.getReconnectAttempts(), bridgeControl.getReconnectAttempts());
assertEquals(bridgeConfig.isUseDuplicateDetection(), bridgeControl.isUseDuplicateDetection());
CompositeData connectorPairData = bridgeControl.getConnectorPair();
Modified: trunk/tests/src/org/jboss/messaging/tests/integration/management/ClusterConnectionControlTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/management/ClusterConnectionControlTest.java 2009-03-23 19:56:44 UTC (rev 6145)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/management/ClusterConnectionControlTest.java 2009-03-24 10:20:42 UTC (rev 6146)
@@ -89,10 +89,10 @@
assertEquals(clusterConnectionConfig.getRetryInterval(), clusterConnectionControl.getRetryInterval());
assertEquals(clusterConnectionConfig.getRetryIntervalMultiplier(),
clusterConnectionControl.getRetryIntervalMultiplier());
- assertEquals(clusterConnectionConfig.getMaxRetriesBeforeFailover(),
- clusterConnectionControl.getMaxRetriesBeforeFailover());
- assertEquals(clusterConnectionConfig.getMaxRetriesAfterFailover(),
- clusterConnectionControl.getMaxRetriesAfterFailover());
+ assertEquals(clusterConnectionConfig.getInitialConnectAttempts(),
+ clusterConnectionControl.getInitialConnectAttempts());
+ assertEquals(clusterConnectionConfig.getReconnectAttempts(),
+ clusterConnectionControl.getReconnectAttempts());
assertEquals(clusterConnectionConfig.isDuplicateDetection(), clusterConnectionControl.isDuplicateDetection());
assertEquals(clusterConnectionConfig.isForwardWhenNoConsumers(),
clusterConnectionControl.isForwardWhenNoConsumers());
Modified: trunk/tests/src/org/jboss/messaging/tests/integration/remoting/PingTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/remoting/PingTest.java 2009-03-23 19:56:44 UTC (rev 6145)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/remoting/PingTest.java 2009-03-24 10:20:42 UTC (rev 6146)
@@ -32,12 +32,12 @@
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_CONNECTION_TTL;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_CONSUMER_MAX_RATE;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_CONSUMER_WINDOW_SIZE;
+import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_INITIAL_CONNECT_ATTEMPTS;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_MAX_CONNECTIONS;
-import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_MAX_RETRIES_AFTER_FAILOVER;
-import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_MAX_RETRIES_BEFORE_FAILOVER;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_MIN_LARGE_MESSAGE_SIZE;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_PRE_ACKNOWLEDGE;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_PRODUCER_MAX_RATE;
+import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_RECONNECT_ATTEMPTS;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_RETRY_INTERVAL;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_RETRY_INTERVAL_MULTIPLIER;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_SEND_WINDOW_SIZE;
@@ -147,8 +147,8 @@
DEFAULT_ACK_BATCH_SIZE,
DEFAULT_RETRY_INTERVAL,
DEFAULT_RETRY_INTERVAL_MULTIPLIER,
- DEFAULT_MAX_RETRIES_BEFORE_FAILOVER,
- DEFAULT_MAX_RETRIES_AFTER_FAILOVER);
+ DEFAULT_INITIAL_CONNECT_ATTEMPTS,
+ DEFAULT_RECONNECT_ATTEMPTS);
ClientSession session = csf.createSession(false, true, true);
@@ -222,8 +222,8 @@
DEFAULT_ACK_BATCH_SIZE,
DEFAULT_RETRY_INTERVAL,
DEFAULT_RETRY_INTERVAL_MULTIPLIER,
- DEFAULT_MAX_RETRIES_BEFORE_FAILOVER,
- DEFAULT_MAX_RETRIES_AFTER_FAILOVER);
+ DEFAULT_INITIAL_CONNECT_ATTEMPTS,
+ DEFAULT_RECONNECT_ATTEMPTS);
ClientSession session = csf.createSession(false, true, true);
@@ -297,8 +297,8 @@
DEFAULT_ACK_BATCH_SIZE,
DEFAULT_RETRY_INTERVAL,
DEFAULT_RETRY_INTERVAL_MULTIPLIER,
- DEFAULT_MAX_RETRIES_BEFORE_FAILOVER,
- DEFAULT_MAX_RETRIES_AFTER_FAILOVER);
+ DEFAULT_INITIAL_CONNECT_ATTEMPTS,
+ DEFAULT_RECONNECT_ATTEMPTS);
Listener clientListener = new Listener();
@@ -403,8 +403,8 @@
DEFAULT_ACK_BATCH_SIZE,
DEFAULT_RETRY_INTERVAL,
DEFAULT_RETRY_INTERVAL_MULTIPLIER,
- 0,
- 0);
+ DEFAULT_INITIAL_CONNECT_ATTEMPTS,
+ DEFAULT_RECONNECT_ATTEMPTS);
ClientSession session = csf.createSession(false, true, true);
Modified: trunk/tests/src/org/jboss/messaging/tests/integration/xa/BasicXaRecoveryTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/xa/BasicXaRecoveryTest.java 2009-03-23 19:56:44 UTC (rev 6145)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/xa/BasicXaRecoveryTest.java 2009-03-24 10:20:42 UTC (rev 6146)
@@ -306,8 +306,6 @@
{
ClientMessage m = pageConsumer.receive(10000);
- log.info("got message " + i);
-
assertNotNull(m);
m.acknowledge();
clientSession.commit();
Modified: trunk/tests/src/org/jboss/messaging/tests/integration/xa/BasicXaTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/xa/BasicXaTest.java 2009-03-23 19:56:44 UTC (rev 6145)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/xa/BasicXaTest.java 2009-03-24 10:20:42 UTC (rev 6146)
@@ -365,10 +365,20 @@
session.end(xid, XAResource.TMSUCCESS);
session.prepare(xid);
session.rollback(xid);
-
session.close();
+ messagingService.start();
+
+ sessionFactory = createInVMFactory();
+
+ xid = newXID();
+ session = sessionFactory.createSession(true, false, false);
+ session.start(xid, XAResource.TMNOFLAGS);
+ session.end(xid, XAResource.TMSUCCESS);
+ session.rollback(xid);
+
+
messagingService.stop();
messagingService.start();
Modified: trunk/tests/src/org/jboss/messaging/tests/stress/remote/PingStressTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/stress/remote/PingStressTest.java 2009-03-23 19:56:44 UTC (rev 6145)
+++ trunk/tests/src/org/jboss/messaging/tests/stress/remote/PingStressTest.java 2009-03-24 10:20:42 UTC (rev 6146)
@@ -30,12 +30,12 @@
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_CONNECTION_LOAD_BALANCING_POLICY_CLASS_NAME;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_CONSUMER_MAX_RATE;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_CONSUMER_WINDOW_SIZE;
+import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_INITIAL_CONNECT_ATTEMPTS;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_MAX_CONNECTIONS;
-import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_MAX_RETRIES_AFTER_FAILOVER;
-import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_MAX_RETRIES_BEFORE_FAILOVER;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_MIN_LARGE_MESSAGE_SIZE;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_PRE_ACKNOWLEDGE;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_PRODUCER_MAX_RATE;
+import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_RECONNECT_ATTEMPTS;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_RETRY_INTERVAL;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_RETRY_INTERVAL_MULTIPLIER;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_SEND_WINDOW_SIZE;
@@ -168,8 +168,8 @@
DEFAULT_ACK_BATCH_SIZE,
DEFAULT_RETRY_INTERVAL,
DEFAULT_RETRY_INTERVAL_MULTIPLIER,
- DEFAULT_MAX_RETRIES_BEFORE_FAILOVER,
- DEFAULT_MAX_RETRIES_AFTER_FAILOVER);
+ DEFAULT_INITIAL_CONNECT_ATTEMPTS,
+ DEFAULT_RECONNECT_ATTEMPTS);
final int numberOfSessions = 1;
final int numberOfThreads = 30;
@@ -217,8 +217,8 @@
DEFAULT_ACK_BATCH_SIZE,
DEFAULT_RETRY_INTERVAL,
DEFAULT_RETRY_INTERVAL_MULTIPLIER,
- DEFAULT_MAX_RETRIES_BEFORE_FAILOVER,
- DEFAULT_MAX_RETRIES_AFTER_FAILOVER);
+ DEFAULT_INITIAL_CONNECT_ATTEMPTS,
+ DEFAULT_RECONNECT_ATTEMPTS);
// Start all at once to make concurrency worst
flagAligned.countDown();
Modified: trunk/tests/src/org/jboss/messaging/tests/unit/core/persistence/impl/journal/JournalStorageManagerTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/core/persistence/impl/journal/JournalStorageManagerTest.java 2009-03-23 19:56:44 UTC (rev 6145)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/core/persistence/impl/journal/JournalStorageManagerTest.java 2009-03-24 10:20:42 UTC (rev 6146)
@@ -673,60 +673,60 @@
// assertEquals(sdest3, destinations.get(2));
// }
- public void testStartStop() throws Exception
- {
- Journal messageJournal = EasyMock.createStrictMock(Journal.class);
- Journal bindingsJournal = EasyMock.createStrictMock(Journal.class);
+// public void testStartStop() throws Exception
+// {
+// Journal messageJournal = EasyMock.createStrictMock(Journal.class);
+// Journal bindingsJournal = EasyMock.createStrictMock(Journal.class);
+//
+// JournalStorageManager jsm = new JournalStorageManager(messageJournal, bindingsJournal, null);
+//
+// assertFalse(jsm.isStarted());
+// bindingsJournal.start();
+// messageJournal.start();
+//
+// EasyMock.replay(messageJournal, bindingsJournal);
+//
+// jsm.start();
+//
+// assertTrue(jsm.isStarted());
+//
+// EasyMock.verify(messageJournal, bindingsJournal);
+//
+// EasyMock.reset(messageJournal, bindingsJournal);
+//
+// EasyMock.replay(messageJournal, bindingsJournal);
+//
+// jsm.start();
+//
+// EasyMock.verify(messageJournal, bindingsJournal);
+//
+// assertTrue(jsm.isStarted());
+//
+// EasyMock.reset(messageJournal, bindingsJournal);
+//
+// bindingsJournal.stop();
+//
+// messageJournal.stop();
+//
+// EasyMock.replay(messageJournal, bindingsJournal);
+//
+// jsm.stop();
+//
+// EasyMock.verify(messageJournal, bindingsJournal);
+//
+// assertFalse(jsm.isStarted());
+//
+// EasyMock.reset(messageJournal, bindingsJournal);
+//
+// EasyMock.replay(messageJournal, bindingsJournal);
+//
+// jsm.stop();
+//
+// EasyMock.verify(messageJournal, bindingsJournal);
+//
+// assertFalse(jsm.isStarted());
+// }
- JournalStorageManager jsm = new JournalStorageManager(messageJournal, bindingsJournal, null);
-
- assertFalse(jsm.isStarted());
- bindingsJournal.start();
- messageJournal.start();
-
- EasyMock.replay(messageJournal, bindingsJournal);
-
- jsm.start();
-
- assertTrue(jsm.isStarted());
-
- EasyMock.verify(messageJournal, bindingsJournal);
-
- EasyMock.reset(messageJournal, bindingsJournal);
-
- EasyMock.replay(messageJournal, bindingsJournal);
-
- jsm.start();
-
- EasyMock.verify(messageJournal, bindingsJournal);
-
- assertTrue(jsm.isStarted());
-
- EasyMock.reset(messageJournal, bindingsJournal);
-
- bindingsJournal.stop();
-
- messageJournal.stop();
-
- EasyMock.replay(messageJournal, bindingsJournal);
-
- jsm.stop();
-
- EasyMock.verify(messageJournal, bindingsJournal);
-
- assertFalse(jsm.isStarted());
-
- EasyMock.reset(messageJournal, bindingsJournal);
-
- EasyMock.replay(messageJournal, bindingsJournal);
-
- jsm.stop();
-
- EasyMock.verify(messageJournal, bindingsJournal);
-
- assertFalse(jsm.isStarted());
- }
-
public void testGenerateMessageID()
{
Journal messageJournal = EasyMock.createStrictMock(Journal.class);
Modified: trunk/tests/src/org/jboss/messaging/tests/util/ServiceTestBase.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/util/ServiceTestBase.java 2009-03-23 19:56:44 UTC (rev 6145)
+++ trunk/tests/src/org/jboss/messaging/tests/util/ServiceTestBase.java 2009-03-24 10:20:42 UTC (rev 6146)
@@ -305,7 +305,7 @@
* @return
* @throws Exception
*/
- protected int getMessageCounter(final PostOffice postOffice, final String address) throws Exception
+ protected int getMessageCount(final PostOffice postOffice, final String address) throws Exception
{
int messageCount;
messageCount = 0;
More information about the jboss-cvs-commits
mailing list