[jboss-cvs] JBoss Messaging SVN: r1583 - in branches/Branch_Client_Failover_Experiment: src/main/org/jboss/jms/client src/main/org/jboss/jms/client/ha src/main/org/jboss/jms/server/connectionfactory src/main/org/jboss/jms/server/ha src/main/org/jboss/messaging/core/plugin/contract src/main/org/jboss/messaging/core/plugin/postoffice/cluster tests/src/org/jboss/test/messaging/core/ha
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Nov 17 18:42:31 EST 2006
Author: clebert.suconic at jboss.com
Date: 2006-11-17 18:42:24 -0500 (Fri, 17 Nov 2006)
New Revision: 1583
Added:
branches/Branch_Client_Failover_Experiment/src/main/org/jboss/jms/client/ha/ClusteredConnectionFactoryDelegate.java
branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/core/ha/ClusterecConnectionTest.java
Removed:
branches/Branch_Client_Failover_Experiment/src/main/org/jboss/jms/client/ha/ClusteredClientConnectionFactoryDelegateServer.java
branches/Branch_Client_Failover_Experiment/src/main/org/jboss/jms/client/ha/ClusteredConnectionFactoryClient.java
Modified:
branches/Branch_Client_Failover_Experiment/src/main/org/jboss/jms/client/JBossConnectionFactory.java
branches/Branch_Client_Failover_Experiment/src/main/org/jboss/jms/server/connectionfactory/ConnectionFactoryJNDIMapper.java
branches/Branch_Client_Failover_Experiment/src/main/org/jboss/jms/server/ha/ClusteredConnectionFactory.java
branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/contract/ClusteredPostOffice.java
branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/DefaultClusteredPostOffice.java
branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/NodeAddressInfo.java
branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/core/ha/HATestBase.java
Log:
Fixing ClusteredConnectionFactory (integration with ClusteredPostOffices)
Modified: branches/Branch_Client_Failover_Experiment/src/main/org/jboss/jms/client/JBossConnectionFactory.java
===================================================================
--- branches/Branch_Client_Failover_Experiment/src/main/org/jboss/jms/client/JBossConnectionFactory.java 2006-11-17 23:32:05 UTC (rev 1582)
+++ branches/Branch_Client_Failover_Experiment/src/main/org/jboss/jms/client/JBossConnectionFactory.java 2006-11-17 23:42:24 UTC (rev 1583)
@@ -28,7 +28,7 @@
import org.jboss.aop.Advised;
import org.jboss.jms.client.container.JmsClientAspectXMLLoader;
import org.jboss.jms.client.delegate.ClientConnectionFactoryDelegate;
-import org.jboss.jms.client.ha.ClusteredConnectionFactoryClient;
+import org.jboss.jms.client.ha.ClusteredConnectionFactoryDelegate;
import org.jboss.jms.delegate.ConnectionDelegate;
import org.jboss.jms.delegate.ConnectionFactoryDelegate;
import org.jboss.jms.referenceable.SerializableObjectRefAddr;
@@ -164,6 +164,11 @@
{
return delegate;
}
+
+ public void setDelegate(ConnectionFactoryDelegate delegate)
+ {
+ this.delegate = delegate;
+ }
// Package protected ---------------------------------------------
@@ -206,7 +211,8 @@
}
else
{
- ((ClusteredConnectionFactoryClient)delegate).init();
+ System.out.println("Initializing clustered factory");
+ ((ClusteredConnectionFactoryDelegate)delegate).init();
}
initialised = true;
}
@@ -222,14 +228,16 @@
if (!configLoaded)
{
ClientConnectionFactoryDelegate currentDelegate = null;
- if (delegate instanceof ClusteredConnectionFactoryClient)
+ if (delegate instanceof ClusteredConnectionFactoryDelegate)
{
- currentDelegate = ((ClusteredConnectionFactoryClient)delegate).getRoundRobbinFactoryDelegate();
+ currentDelegate = ((ClusteredConnectionFactoryDelegate)delegate).getRoundRobbinFactoryDelegate();
}
else
{
currentDelegate = (ClientConnectionFactoryDelegate)delegate;
}
+
+ currentDelegate.init();
// Load the client side aspect stack configuration from the server and apply it
byte[] clientAOPConfig = currentDelegate.getClientAOPConfig();
Deleted: branches/Branch_Client_Failover_Experiment/src/main/org/jboss/jms/client/ha/ClusteredClientConnectionFactoryDelegateServer.java
===================================================================
--- branches/Branch_Client_Failover_Experiment/src/main/org/jboss/jms/client/ha/ClusteredClientConnectionFactoryDelegateServer.java 2006-11-17 23:32:05 UTC (rev 1582)
+++ branches/Branch_Client_Failover_Experiment/src/main/org/jboss/jms/client/ha/ClusteredClientConnectionFactoryDelegateServer.java 2006-11-17 23:42:24 UTC (rev 1583)
@@ -1,100 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.jms.client.ha;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import javax.jms.JMSException;
-import org.jboss.jms.client.delegate.ClientConnectionFactoryDelegate;
-import org.jboss.jms.delegate.ConnectionDelegate;
-import org.jboss.jms.delegate.ConnectionFactoryDelegate;
-import org.jboss.messaging.core.plugin.IdBlock;
-import org.jboss.messaging.core.plugin.contract.ClusteredPostOffice;
-import org.jboss.messaging.core.plugin.postoffice.cluster.NodeAddressInfo;
-
-/**
- * This connection factory looks up for Active Servers in one PostOffice and sends them to the client, by
- * doing a writeResolve what means it would send an updated list of servers.
- *
- * @author <a href="mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
- * @version <tt>$Revision:$</tt>
- * <p/>
- * $Id:$
- */
-public class ClusteredClientConnectionFactoryDelegateServer implements ConnectionFactoryDelegate, Serializable
-{
-
- ClusteredPostOffice postOffice;
-
- transient ClusteredConnectionFactoryClient currentDelegate = null;
-
- public ClusteredClientConnectionFactoryDelegateServer(ClusteredPostOffice clusteredPostOffice)
- {
- this.postOffice = clusteredPostOffice;
- }
-
-
- private ClusteredConnectionFactoryClient createClient()
- {
- NodeAddressInfo[] addresses = postOffice.getClusterNodes();
-
- ArrayList delegatesList = new ArrayList();
-
- for (int i = 0; i < addresses.length; i++)
- {
- ConnectionFactoryDelegate delegateArray[] = addresses[i].getConnectionFactoryDelegates();
-
- for (int j = 0; j < delegateArray.length; j++)
- {
- delegatesList.add(delegateArray[j]);
- }
- }
- ClientConnectionFactoryDelegate[] delegateFinal = (ClientConnectionFactoryDelegate[]) delegatesList.toArray(new ClientConnectionFactoryDelegate[delegatesList.size()]);
-
- return new ClusteredConnectionFactoryClient(delegateFinal);
- }
-
- public ConnectionDelegate createConnectionDelegate(String username, String password) throws JMSException
- {
- if (currentDelegate == null)
- {
- currentDelegate = createClient();
- }
- return currentDelegate.createConnectionDelegate(username, password);
- }
-
- public byte[] getClientAOPConfig() throws JMSException
- {
- throw new RuntimeException("It shouldn't be called here");
- }
-
- public IdBlock getIdBlock(int size) throws JMSException
- {
- throw new RuntimeException("It shouldn't be called here");
- }
-
- private Object writeReplace()
- {
- return createClient();
- }
-}
Deleted: branches/Branch_Client_Failover_Experiment/src/main/org/jboss/jms/client/ha/ClusteredConnectionFactoryClient.java
===================================================================
--- branches/Branch_Client_Failover_Experiment/src/main/org/jboss/jms/client/ha/ClusteredConnectionFactoryClient.java 2006-11-17 23:32:05 UTC (rev 1582)
+++ branches/Branch_Client_Failover_Experiment/src/main/org/jboss/jms/client/ha/ClusteredConnectionFactoryClient.java 2006-11-17 23:42:24 UTC (rev 1583)
@@ -1,60 +0,0 @@
-package org.jboss.jms.client.ha;
-
-import java.io.Serializable;
-import javax.jms.JMSException;
-import org.jboss.jms.client.delegate.ClientConnectionFactoryDelegate;
-import org.jboss.jms.delegate.ConnectionDelegate;
-import org.jboss.jms.delegate.ConnectionFactoryDelegate;
-import org.jboss.messaging.core.plugin.IdBlock;
-
-/**
- * @author <a href="mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
- * @version <tt>$Revision:$</tt>
- * <p/>
- * $Id:$
- */
-public class ClusteredConnectionFactoryClient implements ConnectionFactoryDelegate, Serializable
-{
-
- private int current;
- ClientConnectionFactoryDelegate[] delegates;
-
- public ClusteredConnectionFactoryClient(ClientConnectionFactoryDelegate[] delegates)
- {
- this.delegates = delegates;
- }
-
- public ConnectionDelegate createConnectionDelegate(String username, String password) throws JMSException
- {
- return getRoundRobbinFactoryDelegate().createConnectionDelegate(username, password);
- }
-
-
- public synchronized ClientConnectionFactoryDelegate getRoundRobbinFactoryDelegate()
- {
- ClientConnectionFactoryDelegate currentDelegate = delegates[current++];
- if (current >= delegates.length)
- {
- current = 0;
- }
- return currentDelegate;
- }
-
- public byte[] getClientAOPConfig() throws JMSException
- {
- throw new RuntimeException("Shouldn't be called here");
- }
-
- public IdBlock getIdBlock(int size) throws JMSException
- {
- throw new RuntimeException("Shouldn't be called here");
- }
-
- public synchronized void init()
- {
- for (int i=0;i<delegates.length;i++)
- {
- delegates[i].init();
- }
- }
-}
Copied: branches/Branch_Client_Failover_Experiment/src/main/org/jboss/jms/client/ha/ClusteredConnectionFactoryDelegate.java (from rev 1567, branches/Branch_Client_Failover_Experiment/src/main/org/jboss/jms/client/ha/ClusteredConnectionFactoryClient.java)
===================================================================
--- branches/Branch_Client_Failover_Experiment/src/main/org/jboss/jms/client/ha/ClusteredConnectionFactoryClient.java 2006-11-16 23:02:13 UTC (rev 1567)
+++ branches/Branch_Client_Failover_Experiment/src/main/org/jboss/jms/client/ha/ClusteredConnectionFactoryDelegate.java 2006-11-17 23:42:24 UTC (rev 1583)
@@ -0,0 +1,66 @@
+package org.jboss.jms.client.ha;
+
+import java.io.Serializable;
+import javax.jms.JMSException;
+import org.jboss.jms.client.delegate.ClientConnectionFactoryDelegate;
+import org.jboss.jms.delegate.ConnectionDelegate;
+import org.jboss.jms.delegate.ConnectionFactoryDelegate;
+import org.jboss.messaging.core.plugin.IdBlock;
+
+/**
+ * @author <a href="mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
+ * @version <tt>$Revision:$</tt>
+ * <p/>
+ * $Id:$
+ */
+public class ClusteredConnectionFactoryDelegate implements ConnectionFactoryDelegate, Serializable
+{
+
+ private int current;
+ ClientConnectionFactoryDelegate[] delegates;
+
+ public ClusteredConnectionFactoryDelegate(ClientConnectionFactoryDelegate[] delegates)
+ {
+ this.delegates = delegates;
+ }
+
+ public ConnectionDelegate createConnectionDelegate(String username, String password) throws JMSException
+ {
+ return getRoundRobbinFactoryDelegate().createConnectionDelegate(username, password);
+ }
+
+
+ public synchronized ClientConnectionFactoryDelegate getRoundRobbinFactoryDelegate()
+ {
+ ClientConnectionFactoryDelegate currentDelegate = delegates[current++];
+ if (current >= delegates.length)
+ {
+ current = 0;
+ }
+ return currentDelegate;
+ }
+
+ public byte[] getClientAOPConfig() throws JMSException
+ {
+ throw new RuntimeException("Shouldn't be called here");
+ }
+
+ public IdBlock getIdBlock(int size) throws JMSException
+ {
+ throw new RuntimeException("Shouldn't be called here");
+ }
+
+ /** This method was meant for testcases only */
+ public ClientConnectionFactoryDelegate[] getDelegates()
+ {
+ return delegates;
+ }
+
+ public synchronized void init()
+ {
+ for (int i=0;i<delegates.length;i++)
+ {
+ delegates[i].init();
+ }
+ }
+}
Modified: branches/Branch_Client_Failover_Experiment/src/main/org/jboss/jms/server/connectionfactory/ConnectionFactoryJNDIMapper.java
===================================================================
--- branches/Branch_Client_Failover_Experiment/src/main/org/jboss/jms/server/connectionfactory/ConnectionFactoryJNDIMapper.java 2006-11-17 23:32:05 UTC (rev 1582)
+++ branches/Branch_Client_Failover_Experiment/src/main/org/jboss/jms/server/connectionfactory/ConnectionFactoryJNDIMapper.java 2006-11-17 23:42:24 UTC (rev 1583)
@@ -24,9 +24,11 @@
import java.util.*;
import javax.naming.Context;
import javax.naming.InitialContext;
+import javax.naming.NameNotFoundException;
import org.jboss.jms.client.JBossConnectionFactory;
import org.jboss.jms.client.delegate.ClientConnectionFactoryDelegate;
-import org.jboss.jms.client.ha.ClusteredClientConnectionFactoryDelegateServer;
+import org.jboss.jms.client.ha.ClusteredConnectionFactoryDelegate;
+import org.jboss.jms.delegate.ConnectionFactoryDelegate;
import org.jboss.jms.server.ConnectionFactoryManager;
import org.jboss.jms.server.ServerPeer;
import org.jboss.jms.server.endpoint.ServerConnectionFactoryEndpoint;
@@ -35,6 +37,7 @@
import org.jboss.jms.util.JNDIUtil;
import org.jboss.logging.Logger;
import org.jboss.messaging.core.plugin.contract.ClusteredPostOffice;
+import org.jboss.messaging.core.plugin.postoffice.cluster.NodeAddressInfo;
/**
* @author <a href="mailto:ovidiu at jboss.org">Ovidiu Feodorov</a>
@@ -73,18 +76,35 @@
JNDIBindings jndiBindings) throws Exception
{
- ClusteredClientConnectionFactoryDelegateServer factory
- = new ClusteredClientConnectionFactoryDelegateServer(postOffice);
- JBossConnectionFactory cf = new JBossConnectionFactory(factory);
+ ClusteredConnectionFactoryDelegate factoryDelegate = createClusteredConnectionFactoryDelegate(postOffice);
+ JBossConnectionFactory cf = new JBossConnectionFactory(factoryDelegate);
if (jndiBindings != null)
{
List jndiNames = jndiBindings.getNames();
- for(Iterator i = jndiNames.iterator(); i.hasNext(); )
+ for (Iterator i = jndiNames.iterator(); i.hasNext();)
{
- String jndiName = (String)i.next();
- JNDIUtil.rebind(initialContext, jndiName, cf);
+ String jndiName = (String) i.next();
+ boolean isBound = false;
+
+ try
+ {
+ isBound = initialContext.lookup(jndiName) != null;
+ }
+ catch (NameNotFoundException ignored)
+ {
+ }
+
+
+ if (isBound)
+ {
+ initialContext.rebind(jndiName,cf);
+ }
+ else
+ {
+ JNDIUtil.rebind(initialContext, jndiName, cf);
+ }
}
}
}
@@ -190,6 +210,26 @@
// Protected -----------------------------------------------------
// Private -------------------------------------------------------
-
+
+ private ClusteredConnectionFactoryDelegate createClusteredConnectionFactoryDelegate(ClusteredPostOffice postOffice)
+ {
+ NodeAddressInfo[] addresses = postOffice.getClusterNodes();
+
+ ArrayList delegatesList = new ArrayList();
+
+ for (int i = 0; i < addresses.length; i++)
+ {
+ ConnectionFactoryDelegate delegateArray[] = addresses[i].getConnectionFactoryDelegates();
+
+ for (int j = 0; j < delegateArray.length; j++)
+ {
+ delegatesList.add(delegateArray[j]);
+ }
+ }
+ ClientConnectionFactoryDelegate[] delegateFinal = (ClientConnectionFactoryDelegate[]) delegatesList.toArray(new ClientConnectionFactoryDelegate[delegatesList.size()]);
+
+ return new ClusteredConnectionFactoryDelegate(delegateFinal);
+ }
+
// Inner classes -------------------------------------------------
}
Modified: branches/Branch_Client_Failover_Experiment/src/main/org/jboss/jms/server/ha/ClusteredConnectionFactory.java
===================================================================
--- branches/Branch_Client_Failover_Experiment/src/main/org/jboss/jms/server/ha/ClusteredConnectionFactory.java 2006-11-17 23:32:05 UTC (rev 1582)
+++ branches/Branch_Client_Failover_Experiment/src/main/org/jboss/jms/server/ha/ClusteredConnectionFactory.java 2006-11-17 23:42:24 UTC (rev 1583)
@@ -119,6 +119,8 @@
serverPeer.getConnectionFactoryManager().registerClusteredConnectionFactory(postOffice, this.jndiBindings);
+ postOffice.setClusteredConnectionInformation(serverPeer.getConnectionFactoryManager(), this.jndiBindings);
+
started = true;
}
catch (Throwable t)
Modified: branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/contract/ClusteredPostOffice.java
===================================================================
--- branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/contract/ClusteredPostOffice.java 2006-11-17 23:32:05 UTC (rev 1582)
+++ branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/contract/ClusteredPostOffice.java 2006-11-17 23:42:24 UTC (rev 1583)
@@ -22,6 +22,8 @@
package org.jboss.messaging.core.plugin.contract;
import java.util.Collection;
+import org.jboss.jms.server.ConnectionFactoryManager;
+import org.jboss.jms.server.connectionfactory.JNDIBindings;
import org.jboss.messaging.core.plugin.postoffice.Binding;
import org.jboss.messaging.core.plugin.postoffice.cluster.LocalClusteredQueue;
import org.jboss.messaging.core.plugin.postoffice.cluster.NodeAddressInfo;
@@ -31,6 +33,7 @@
* A ClusteredPostOffice
*
* @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * @author <a href="mailto:clebert.suconic at jboss.com">Clebert Suconic</a>
* @version <tt>$Revision: 1.1 $</tt>
*
* $Id$
@@ -38,7 +41,16 @@
*/
public interface ClusteredPostOffice extends PostOffice
{
+
/**
+ * Sets this ClusteredPostOffice as responsible for rebind the ClusteredConnectionFactories when the
+ * membership changes.
+ * @param jndiMapper
+ * @param clusteredConnectionJndiBindings
+ */
+ public void setClusteredConnectionInformation(ConnectionFactoryManager jndiMapper,
+ JNDIBindings clusteredConnectionJndiBindings);
+ /**
* Bind a queue to the post office under a specific condition
* such that it is available across the cluster
* @param condition The condition to be used when routing references
Modified: branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/DefaultClusteredPostOffice.java
===================================================================
--- branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/DefaultClusteredPostOffice.java 2006-11-17 23:32:05 UTC (rev 1582)
+++ branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/DefaultClusteredPostOffice.java 2006-11-17 23:42:24 UTC (rev 1583)
@@ -27,7 +27,9 @@
import javax.sql.DataSource;
import javax.transaction.TransactionManager;
import org.jboss.jms.delegate.ConnectionFactoryDelegate;
+import org.jboss.jms.server.ConnectionFactoryManager;
import org.jboss.jms.server.QueuedExecutorPool;
+import org.jboss.jms.server.connectionfactory.JNDIBindings;
import org.jboss.logging.Logger;
import org.jboss.messaging.core.*;
import org.jboss.messaging.core.Queue;
@@ -69,7 +71,7 @@
private boolean failHandleResult;
private boolean trace = log.isTraceEnabled();
-
+
private Channel syncChannel;
private Channel asyncChannel;
@@ -112,7 +114,11 @@
private MessagePullPolicy messagePullPolicy;
private ClusterRouterFactory routerFactory;
-
+
+ private ConnectionFactoryManager jndiMapper;
+
+ private JNDIBindings clusteredConnectionJndiBindings;
+
private Map routerMap;
/** List of failed over bindings.
@@ -313,6 +319,13 @@
// PostOffice implementation ---------------------------------------
+ public void setClusteredConnectionInformation(ConnectionFactoryManager jndiMapper,
+ JNDIBindings clusteredConnectionJndiBindings)
+ {
+ this.jndiMapper = jndiMapper;
+ this.clusteredConnectionJndiBindings=clusteredConnectionJndiBindings;
+ }
+
public Binding bindClusteredQueue(String condition, LocalClusteredQueue queue) throws Exception
{
if (trace)
@@ -643,6 +656,18 @@
try
{
nodeIdAddressesMap.put(new Integer(nodeId), info);
+
+ try
+ {
+ registerDatasources();
+ }
+ catch (Throwable e)
+ {
+ log.error("Caught Exception in MembershipListener", e);
+ IllegalStateException e2 = new IllegalStateException(e.getMessage());
+ e2.initCause(e);
+ throw e2;
+ }
}
finally
{
@@ -1293,6 +1318,17 @@
out.println("</table>");
+ out.println("Clustered Information");
+
+ NodeAddressInfo info[] = getClusterNodes();
+
+ out.println("<table><tr><td>Node</td><td>AsyncChannel</td><td>SyncChannel</td></tr>");
+ for (int i = 0; i < info.length; i++)
+ {
+ out.println("<tr><td>" + info[i].getNodeId() + "</td><td>" + info[i].getAsyncChannelAddress() + "</td><td>" + info[i].getSyncChannelAddress() + "</td>");
+ }
+ out.println("</table>");
+
return buffer.toString();
}
@@ -1839,8 +1875,19 @@
return null;
}
}
+
+
+ private void registerDatasources() throws Exception
+ {
+ if (jndiMapper!=null)
+ {
+ jndiMapper.registerClusteredConnectionFactory(this,clusteredConnectionJndiBindings);
+ }
+ }
+
+
+
-
/*
* This class is used to listen for messages on the async channel
*/
Modified: branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/NodeAddressInfo.java
===================================================================
--- branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/NodeAddressInfo.java 2006-11-17 23:32:05 UTC (rev 1582)
+++ branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/NodeAddressInfo.java 2006-11-17 23:42:24 UTC (rev 1583)
@@ -61,7 +61,13 @@
this.connectionFactoryDelegates = connectionFactoryDelegates;
}
-
+
+
+ public int getNodeId()
+ {
+ return nodeId;
+ }
+
Address getSyncChannelAddress()
{
return syncChannelAddress;
Added: branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/core/ha/ClusterecConnectionTest.java
===================================================================
--- branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/core/ha/ClusterecConnectionTest.java 2006-11-17 23:32:05 UTC (rev 1582)
+++ branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/core/ha/ClusterecConnectionTest.java 2006-11-17 23:42:24 UTC (rev 1583)
@@ -0,0 +1,39 @@
+package org.jboss.test.messaging.core.ha;
+
+import org.jboss.jms.client.JBossConnection;
+import org.jboss.jms.client.JBossConnectionFactory;
+import org.jboss.jms.client.delegate.ClientConnectionDelegate;
+import org.jboss.jms.client.ha.ClusteredConnectionFactoryDelegate;
+import org.jboss.jms.client.state.ConnectionState;
+
+/**
+ * Start two JBoss instances (clustered) to run these tests.
+ */
+public class ClusterecConnectionTest extends HATestBase
+{
+
+
+ public void setup() throws Exception
+ {
+ super.setUp("/HAConnectionFactory");
+ }
+
+ public void testSimpleConnection() throws Exception
+ {
+ JBossConnectionFactory factory = (JBossConnectionFactory)this.ctx1.lookup("/HAConnectionFactory");
+ JBossConnection conn = (JBossConnection) factory.createConnection();
+
+ ClusteredConnectionFactoryDelegate delegate = (ClusteredConnectionFactoryDelegate)factory.getDelegate();
+
+ assertEquals(2,delegate.getDelegates().length);
+
+
+ for (int i=0;i<100;i++)
+ {
+ JBossConnection conn2 = (JBossConnection)factory.createConnection();
+ ConnectionState state = (ConnectionState) ((ClientConnectionDelegate)conn2.getDelegate()).getState();
+ log.info("state.serverId=" + state.getServerID());
+ conn2.close();
+ }
+ }
+}
Modified: branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/core/ha/HATestBase.java
===================================================================
--- branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/core/ha/HATestBase.java 2006-11-17 23:32:05 UTC (rev 1582)
+++ branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/core/ha/HATestBase.java 2006-11-17 23:42:24 UTC (rev 1583)
@@ -22,13 +22,11 @@
package org.jboss.test.messaging.core.ha;
-import junit.framework.TestCase;
-
+import java.util.Properties;
import javax.jms.ConnectionFactory;
+import javax.naming.Context;
import javax.naming.InitialContext;
-import javax.naming.Context;
-import java.util.Properties;
-
+import junit.framework.TestCase;
import org.jboss.logging.Logger;
/**
@@ -53,21 +51,27 @@
protected String NODE1 =System.getProperty("NODE1","localhost:1199");
protected String NODE2 =System.getProperty("NODE2","localhost:1299");
- public void setUp() throws Exception
- {
- super.setUp();
- System.out.println("Server1=" + NODE1);
- System.out.println("Server2=" + NODE2);
+ public void setUp(String jndiFactory) throws Exception
+ {
+ super.setUp();
- ctx1 = getContext(NODE1);
- ctx2 = getContext(NODE2);
+ System.out.println("Server1=" + NODE1);
+ System.out.println("Server2=" + NODE2);
- factoryServer1 = (ConnectionFactory)ctx1.lookup("/ConnectionFactory");
- factoryServer2 = (ConnectionFactory)ctx2.lookup("/ConnectionFactory");
- }
+ ctx1 = getContext(NODE1);
+ ctx2 = getContext(NODE2);
- protected Context getContext(String host) throws Exception
+ factoryServer1 = (ConnectionFactory) ctx1.lookup(jndiFactory);
+ factoryServer2 = (ConnectionFactory) ctx2.lookup(jndiFactory);
+ }
+
+ public void setUp() throws Exception
+ {
+ this.setUp("/ConnectionFactory");
+ }
+
+ protected Context getContext(String host) throws Exception
{
// don't worry about this yet, we will put this in more generic way.
// This is for test purposes only.
More information about the jboss-cvs-commits
mailing list