[jboss-cvs] JBoss Messaging SVN: r1990 - in trunk: src/main/org/jboss/jms/client/container and 8 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Jan 19 00:00:41 EST 2007
Author: ovidiu.feodorov at jboss.com
Date: 2007-01-19 00:00:41 -0500 (Fri, 19 Jan 2007)
New Revision: 1990
Added:
trunk/tests/src/org/jboss/test/messaging/jms/clustering/ClusterViewUpdateTest.java
Removed:
trunk/tests/src/org/jboss/test/messaging/jms/clustering/ConnectionFactoryUpdateTest.java
Modified:
trunk/src/etc/xmdesc/ConnectionFactory-xmbean.xml
trunk/src/main/org/jboss/jms/client/container/ClusteringAspect.java
trunk/src/main/org/jboss/jms/client/delegate/ClientClusteredConnectionFactoryDelegate.java
trunk/src/main/org/jboss/jms/client/delegate/ClientConnectionFactoryDelegate.java
trunk/src/main/org/jboss/jms/client/remoting/CallbackHandler.java
trunk/src/main/org/jboss/jms/client/remoting/CallbackManager.java
trunk/src/main/org/jboss/jms/client/remoting/ConnectionFactoryCallbackHandler.java
trunk/src/main/org/jboss/jms/server/ConnectionManager.java
trunk/src/main/org/jboss/jms/server/connectionfactory/ConnectionFactory.java
trunk/src/main/org/jboss/jms/server/connectionmanager/SimpleConnectionManager.java
trunk/src/main/org/jboss/jms/server/endpoint/ConnectionFactoryUpdateMessage.java
trunk/src/main/org/jboss/jms/server/endpoint/ServerConnectionFactoryEndpoint.java
trunk/tests/src/org/jboss/test/messaging/jms/clustering/ClusteringAspectInternalTest.java
trunk/tests/src/org/jboss/test/messaging/tools/jndi/RemoteInitialContextFactory.java
Log:
More minor refactoring, comment aligning, method name changing, logging touch ups and other things of this kind"
Modified: trunk/src/etc/xmdesc/ConnectionFactory-xmbean.xml
===================================================================
--- trunk/src/etc/xmdesc/ConnectionFactory-xmbean.xml 2007-01-19 03:24:03 UTC (rev 1989)
+++ trunk/src/etc/xmdesc/ConnectionFactory-xmbean.xml 2007-01-19 05:00:41 UTC (rev 1990)
@@ -45,7 +45,7 @@
<attribute access="read-write" getMethod="getPrefetchSize" setMethod="setPrefetchSize">
<description>The maximum number of messages that will be prefetched by the client side consumer</description>
<name>PrefetchSize</name>
- <type>int</type>
+ <type>int</type>
</attribute>
<attribute access="read-write" getMethod="getDefaultTempQueueFullSize" setMethod="setDefaultTempQueueFullSize">
Modified: trunk/src/main/org/jboss/jms/client/container/ClusteringAspect.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/container/ClusteringAspect.java 2007-01-19 03:24:03 UTC (rev 1989)
+++ trunk/src/main/org/jboss/jms/client/container/ClusteringAspect.java 2007-01-19 05:00:41 UTC (rev 1990)
@@ -208,10 +208,9 @@
Map failoverMap = clusteredDelegate.getFailoverMap();
Integer failoverNodeID = (Integer)failoverMap.get(nodeID);
- // FailoverNodeID is not on the map, that means the ConnectionFactory was updated
- // by another connection in another server.. So we will have to guess the failoverID
- // by numeric order. Case we guessed the new server wrongly we will have to rely on
- // redirect from failover
+ // FailoverNodeID is not on the map, that means the ConnectionFactory was updated by another
+ // connection in another server. So we will have to guess the failoverID by numeric order.
+ // In case we guessed the new server wrongly we will have to rely on redirect from failover.
if (failoverNodeID == null)
{
failoverNodeID = guessFailoverID(failoverMap, nodeID);
@@ -228,21 +227,22 @@
return null;
}
- /** FailoverNodeID is not on the map, that means the ConnectionFactory was updated
- * by another connection in another server.. So we will have to guess the failoverID
- * by numeric order. Case we guessed the new server wrongly we will have to rely on
- * redirect from failover.
- * (NOTE:
- * There is a testcase that uses reflection to validate this method at
- * org.jboss.test.messaging.jms.clustering.ClusteringAspectInternalTest
- * Modify that testcase case you decide to refactor this method)
- */
+ /**
+ * FailoverNodeID is not on the map, that means the ConnectionFactory was updated by another
+ * connection in another server. So we will have to guess the failoverID by numeric order. In
+ * case we guessed the new server wrongly we will have to rely on redirect from failover.
+ * (NOTE: There is a testcase that uses reflection to validate this method in
+ * org.jboss.test.messaging.jms.clustering.ClusteringAspectInternalTest. Modify that testcase
+ * in case you decide to refactor this method).
+ */
private static Integer guessFailoverID(Map failoverMap, Integer nodeID)
{
Integer failoverNodeID = null;
Integer[] nodes = (Integer[]) failoverMap.keySet().toArray(new Integer[failoverMap.size()]);
+
// We need to sort the array first
Arrays.sort(nodes);
+
for (int i = 0; i < nodes.length; i++)
{
if (nodeID.intValue() < nodes[i].intValue())
@@ -251,6 +251,7 @@
break;
}
}
+
// if still null use the first node...
if (failoverNodeID == null)
{
Modified: trunk/src/main/org/jboss/jms/client/delegate/ClientClusteredConnectionFactoryDelegate.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/delegate/ClientClusteredConnectionFactoryDelegate.java 2007-01-19 03:24:03 UTC (rev 1989)
+++ trunk/src/main/org/jboss/jms/client/delegate/ClientClusteredConnectionFactoryDelegate.java 2007-01-19 05:00:41 UTC (rev 1990)
@@ -132,7 +132,7 @@
public void setDelegates(ClientConnectionFactoryDelegate[] dels)
{
this.delegates = dels;
- getLoadBalancingPolicy().updateView(dels);
+ loadBalancingPolicy.updateView(dels);
}
public Map getFailoverMap()
@@ -154,16 +154,14 @@
public synchronized void updateFailoverInfo(ClientConnectionFactoryDelegate[] delegates,
Map failoverMap)
{
- for (int i = 0; i < delegates.length; i++)
- {
- delegates[i].init();
- }
this.delegates = delegates;
this.failoverMap = failoverMap;
- getLoadBalancingPolicy().updateView(delegates);
- }
+ init();
+ loadBalancingPolicy.updateView(delegates);
+ }
+
public String toString()
{
StringBuffer sb = new StringBuffer("ClusteredConnectionFactoryDelegate[");
Modified: trunk/src/main/org/jboss/jms/client/delegate/ClientConnectionFactoryDelegate.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/delegate/ClientConnectionFactoryDelegate.java 2007-01-19 03:24:03 UTC (rev 1989)
+++ trunk/src/main/org/jboss/jms/client/delegate/ClientConnectionFactoryDelegate.java 2007-01-19 05:00:41 UTC (rev 1990)
@@ -174,9 +174,9 @@
SimpleMetaData md = mi.getMetaData();
md.addMetaData(Dispatcher.DISPATCHER,
- Dispatcher.OID,
- new Integer(id),
- PayloadKey.AS_IS);
+ Dispatcher.OID,
+ new Integer(id),
+ PayloadKey.AS_IS);
// If the method being invoked is createConnectionDelegate() then we must invoke it on the
// same remoting client subsequently used by the connection. This is because we need to pass
Modified: trunk/src/main/org/jboss/jms/client/remoting/CallbackHandler.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/remoting/CallbackHandler.java 2007-01-19 03:24:03 UTC (rev 1989)
+++ trunk/src/main/org/jboss/jms/client/remoting/CallbackHandler.java 2007-01-19 05:00:41 UTC (rev 1990)
@@ -32,5 +32,5 @@
{
void handleMessage(Object message);
-
+
}
Modified: trunk/src/main/org/jboss/jms/client/remoting/CallbackManager.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/remoting/CallbackManager.java 2007-01-19 03:24:03 UTC (rev 1989)
+++ trunk/src/main/org/jboss/jms/client/remoting/CallbackManager.java 2007-01-19 05:00:41 UTC (rev 1990)
@@ -25,6 +25,7 @@
import org.jboss.jms.message.MessageProxy;
import org.jboss.jms.server.endpoint.ClientDelivery;
+import org.jboss.jms.server.endpoint.ConnectionFactoryUpdateMessage;
import org.jboss.jms.server.remoting.MessagingMarshallable;
import org.jboss.jms.client.delegate.ClientConnectionDelegate;
import org.jboss.logging.Logger;
@@ -54,21 +55,15 @@
{
// Constants ------------------------------------------------------------------------------------
- protected static final Logger log;
+ private static final Logger log = Logger.getLogger(CallbackManager.class);
public static final String JMS_CALLBACK_SUBSYSTEM = "CALLBACK";
// Static ---------------------------------------------------------------------------------------
+ private static boolean trace = log.isTraceEnabled();
+
protected static CallbackManager theManager;
-
- private static boolean trace;
-
- static
- {
- log = Logger.getLogger(CallbackManager.class);
- trace = log.isTraceEnabled();
- }
// Attributes -----------------------------------------------------------------------------------
@@ -87,9 +82,11 @@
public void handleCallback(Callback callback) throws HandleCallbackException
{
- if (callback.getParameter() instanceof MessagingMarshallable)
+ Object parameter = callback.getParameter();
+
+ if (parameter instanceof MessagingMarshallable)
{
- MessagingMarshallable mm = (MessagingMarshallable)callback.getParameter();
+ MessagingMarshallable mm = (MessagingMarshallable)parameter;
ClientDelivery dr = (ClientDelivery)mm.getLoad();
MessageProxy msg = dr.getMessage();
@@ -98,22 +95,31 @@
if (handler == null)
{
- //This is OK and can happen if the callback handler is deregistered on consumer close,
- //but there are messages still in transit which arrive later.
- //In this case it is just safe to ignore the message
+ // This is OK and can happen if the callback handler is deregistered on consumer close,
+ // but there are messages still in transit which arrive later. In this case it is just
+ // safe to ignore the message.
+
if (trace) { log.trace(this + " callback handler not found, message arrived after consumer is closed"); }
return;
}
handler.handleMessage(msg);
- } else
+ }
+ else if (parameter instanceof ConnectionFactoryUpdateMessage)
{
- log.trace("Receiving connectionFactoryUpdateMessage - " + callback.getParameter());
+ ConnectionFactoryUpdateMessage viewChange = (ConnectionFactoryUpdateMessage)parameter;
+
+ if (trace) { log.trace(this + " receiving cluster view change " + viewChange); }
+
if (connectionfactoryCallbackHandler != null)
{
- connectionfactoryCallbackHandler.handleMessage(callback.getParameter());
+ connectionfactoryCallbackHandler.handleMessage(viewChange);
}
}
+ else
+ {
+ throw new HandleCallbackException("Unknow callback type: " + callback);
+ }
}
// Public ---------------------------------------------------------------------------------------
@@ -134,6 +140,11 @@
return (MessageCallbackHandler)callbackHandlers.remove(new Integer(consumerID));
}
+ public String toString()
+ {
+ return "CallbackManager[" + Integer.toHexString(hashCode()) + "]";
+ }
+
// Package protected ----------------------------------------------------------------------------
// Protected ------------------------------------------------------------------------------------
Modified: trunk/src/main/org/jboss/jms/client/remoting/ConnectionFactoryCallbackHandler.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/remoting/ConnectionFactoryCallbackHandler.java 2007-01-19 03:24:03 UTC (rev 1989)
+++ trunk/src/main/org/jboss/jms/client/remoting/ConnectionFactoryCallbackHandler.java 2007-01-19 05:00:41 UTC (rev 1990)
@@ -32,22 +32,22 @@
* This class will manage ConnectionFactory messages updates
* @author <a href="mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
* @version <tt>$Revision$</tt>
- * <p/>
- * $Id$
+ *
+ * $Id$
*/
public class ConnectionFactoryCallbackHandler implements CallbackHandler
{
-
// Constants ------------------------------------------------------------------------------------
+ private static final Logger log = Logger.getLogger(ConnectionFactoryCallbackHandler.class);
+
// Attributes -----------------------------------------------------------------------------------
- ClientConnectionDelegate connectionDelegate;
- ConnectionState state;
+ private ClientConnectionDelegate connectionDelegate;
+ private ConnectionState state;
// Static ---------------------------------------------------------------------------------------
- protected static final Logger log = Logger.getLogger(ConnectionFactoryCallbackHandler.class);
private static boolean trace = log.isTraceEnabled();
// Constructors ---------------------------------------------------------------------------------
@@ -58,41 +58,37 @@
this.state = (ConnectionState)connectionDelegate.getState();
}
+ // CallbackHandler implementation ---------------------------------------------------------------
- // Implementation of CallbackHandler ------------------------------------------------------------
public void handleMessage(Object message)
{
- ConnectionFactoryUpdateMessage updateMessage = (ConnectionFactoryUpdateMessage) message;
+ if (trace) { log.trace(this + " handling " + message); }
+ ConnectionFactoryUpdateMessage viewChange = (ConnectionFactoryUpdateMessage)message;
- if (getState().getClusteredConnectionFactoryDelegate() != null &&
- getState().getClusteredConnectionFactoryDelegate()
- instanceof ClientClusteredConnectionFactoryDelegate)
+ Object d = state.getClusteredConnectionFactoryDelegate();
+
+ if (d instanceof ClientClusteredConnectionFactoryDelegate)
{
- ClientClusteredConnectionFactoryDelegate delegate =
- (ClientClusteredConnectionFactoryDelegate) getState().
- getClusteredConnectionFactoryDelegate();
+ ClientClusteredConnectionFactoryDelegate clusteredDelegate =
+ (ClientClusteredConnectionFactoryDelegate)d;
- delegate.updateFailoverInfo(updateMessage.getDelegates(), updateMessage.getFailoverMap());
+ clusteredDelegate.updateFailoverInfo(viewChange.getDelegates(),
+ viewChange.getFailoverMap());
}
-
}
// Public ---------------------------------------------------------------------------------------
+ public String toString()
+ {
+ return "ConnectionFactoryCallbackHandler[" + connectionDelegate + "]";
+ }
+
// Package protected ----------------------------------------------------------------------------
// Protected ------------------------------------------------------------------------------------
- protected ConnectionState getState()
- {
- if (state==null)
- {
- this.state = (ConnectionState)connectionDelegate.getState();
- }
- return this.state;
- }
-
// Private --------------------------------------------------------------------------------------
// Inner classes --------------------------------------------------------------------------------
Modified: trunk/src/main/org/jboss/jms/server/ConnectionManager.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/ConnectionManager.java 2007-01-19 03:24:03 UTC (rev 1989)
+++ trunk/src/main/org/jboss/jms/server/ConnectionManager.java 2007-01-19 05:00:41 UTC (rev 1990)
@@ -49,8 +49,9 @@
boolean containsSession(String remotingClientSessionID);
/**
- * Returns a list of active connections on this Manager.
+ * Returns a list of active connections currently maintained by an instance of this manager.
* The implementation should make a copy of the list to avoid ConcurrentModificationException.
+ * The list could be empty, but never null.
*/
- List getActiveConnectionsList();
+ List getActiveConnections();
}
Modified: trunk/src/main/org/jboss/jms/server/connectionfactory/ConnectionFactory.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/connectionfactory/ConnectionFactory.java 2007-01-19 03:24:03 UTC (rev 1989)
+++ trunk/src/main/org/jboss/jms/server/connectionfactory/ConnectionFactory.java 2007-01-19 05:00:41 UTC (rev 1990)
@@ -28,11 +28,11 @@
*/
public class ConnectionFactory extends ServiceMBeanSupport
{
- // Constants -----------------------------------------------------
+ // Constants ------------------------------------------------------------------------------------
- // Static --------------------------------------------------------
+ // Static ---------------------------------------------------------------------------------------
- // Attributes ----------------------------------------------------
+ // Attributes -----------------------------------------------------------------------------------
protected String clientID;
protected JNDIBindings jndiBindings;
@@ -54,7 +54,7 @@
protected boolean started;
- // Constructors --------------------------------------------------
+ // Constructors ---------------------------------------------------------------------------------
public ConnectionFactory()
{
@@ -69,7 +69,7 @@
this.loadBalancingFactory = LoadBalancingFactory.getDefaultFactory();
}
- // ServiceMBeanSupport overrides ---------------------------------
+ // ServiceMBeanSupport overrides ----------------------------------------------------------------
public synchronized void startService() throws Exception
{
@@ -165,7 +165,7 @@
}
}
- // JMX managed attributes ----------------------------------------
+ // JMX managed attributes -----------------------------------------------------------------------
public int getDefaultTempQueueFullSize()
{
@@ -290,20 +290,20 @@
this.loadBalancingFactory = loadBalancingFactory;
}
- // JMX managed operations ----------------------------------------
+ // JMX managed operations -----------------------------------------------------------------------
- // Public --------------------------------------------------------
+ // Public ---------------------------------------------------------------------------------------
public String toString()
{
return "[" + jndiBindings.toString() + "]";
}
- // Package protected ---------------------------------------------
+ // Package protected ----------------------------------------------------------------------------
- // Protected -----------------------------------------------------
+ // Protected ------------------------------------------------------------------------------------
- // Private -------------------------------------------------------
+ // Private --------------------------------------------------------------------------------------
- // Inner classes -------------------------------------------------
+ // Inner classes --------------------------------------------------------------------------------
}
Modified: trunk/src/main/org/jboss/jms/server/connectionmanager/SimpleConnectionManager.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/connectionmanager/SimpleConnectionManager.java 2007-01-19 03:24:03 UTC (rev 1989)
+++ trunk/src/main/org/jboss/jms/server/connectionmanager/SimpleConnectionManager.java 2007-01-19 05:00:41 UTC (rev 1990)
@@ -191,7 +191,7 @@
return sessions.containsKey(remotingClientSessionID);
}
- public synchronized List getActiveConnectionsList()
+ public synchronized List getActiveConnections()
{
// I will make a copy to avoid ConcurrentModification
ArrayList list = new ArrayList();
Modified: trunk/src/main/org/jboss/jms/server/endpoint/ConnectionFactoryUpdateMessage.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/endpoint/ConnectionFactoryUpdateMessage.java 2007-01-19 03:24:03 UTC (rev 1989)
+++ trunk/src/main/org/jboss/jms/server/endpoint/ConnectionFactoryUpdateMessage.java 2007-01-19 05:00:41 UTC (rev 1990)
@@ -27,15 +27,16 @@
import java.io.Serializable;
/**
- * This class holds the updated information about the server to ConnectionFactories
+ * This class holds the update cluster view sent by the server to client-side clustered connection
+ * factories.
+ *
* @author <a href="mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
* @version <tt>$Revision$</tt>
*
- * $Id$
+ * $Id$
*/
public class ConnectionFactoryUpdateMessage implements Serializable
{
-
// Constants ------------------------------------------------------------------------------------
@@ -79,6 +80,24 @@
this.failoverMap = failoverMap;
}
+ public String toString()
+ {
+ StringBuffer sb = new StringBuffer("ConnectionFactoryUpdateMessage[");
+
+ for(int i = 0; i < delegates.length; i++)
+ {
+ sb.append(delegates[i]);
+ if (i < delegates.length - 1)
+ {
+ sb.append(',');
+ }
+ }
+
+ sb.append("]");
+
+ return sb.toString();
+ }
+
// Package protected ----------------------------------------------------------------------------
// Protected ------------------------------------------------------------------------------------
Modified: trunk/src/main/org/jboss/jms/server/endpoint/ServerConnectionFactoryEndpoint.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/endpoint/ServerConnectionFactoryEndpoint.java 2007-01-19 03:24:03 UTC (rev 1989)
+++ trunk/src/main/org/jboss/jms/server/endpoint/ServerConnectionFactoryEndpoint.java 2007-01-19 05:00:41 UTC (rev 1990)
@@ -226,30 +226,33 @@
return jndiBindings;
}
-
- /** Sends an update message on ClusteredConnectionFactories.
- * Observation: I have placed here, because if we decide to lock the ServerEndpoint
- * while we send updates, we would need the method here to perform WriteLocks on objects */
+ /**
+ * Sends a cluster view update message to its associated ClusteredConnectionFactories.
+ *
+ * Observation: It is placed here, because if we decide to lock the ServerEndpoint while we send
+ * updates, we would need the method here to perform WriteLocks on objects.
+ */
public void updateClusteredClients(ClientConnectionFactoryDelegate[] delegates, Map failoverMap)
throws Exception
{
+ // TODO Should we lock the CFEndpoint now allowing new connections to come while doing this?
- // Should we lock the CFEndpoint now allowing new connections to come while doing this?
+ List activeConnections = serverPeer.getConnectionManager().getActiveConnections();
- List connectionList = serverPeer.getConnectionManager().getActiveConnectionsList();
+ log.info(this + " sending updated cluster view to " +
+ activeConnections.size() + " active connections.");
+ ConnectionFactoryUpdateMessage message =
+ new ConnectionFactoryUpdateMessage(delegates, failoverMap);
- log.info("Sending update list to active connections. It got " +
- connectionList.size() + " elements");
-
- ConnectionFactoryUpdateMessage message = new ConnectionFactoryUpdateMessage(delegates,
- failoverMap);
Callback callback = new Callback(message);
- for (Iterator iter = connectionList.iterator(); iter.hasNext();)
+ for (Iterator i = activeConnections.iterator(); i.hasNext();)
{
- ServerConnectionEndpoint connEndpoint = (ServerConnectionEndpoint) iter.next();
- log.trace("Updating connection " + connEndpoint);
+ ServerConnectionEndpoint connEndpoint = (ServerConnectionEndpoint)i.next();
+
+ log.debug(this + " sending cluster view update to " + connEndpoint);
+
try
{
connEndpoint.getCallbackHandler().handleCallback(callback);
@@ -259,7 +262,6 @@
log.error("Callback failed on connection " + connEndpoint, e);
}
}
-
}
public String toString()
Copied: trunk/tests/src/org/jboss/test/messaging/jms/clustering/ClusterViewUpdateTest.java (from rev 1988, trunk/tests/src/org/jboss/test/messaging/jms/clustering/ConnectionFactoryUpdateTest.java)
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/clustering/ClusterViewUpdateTest.java (rev 0)
+++ trunk/tests/src/org/jboss/test/messaging/jms/clustering/ClusterViewUpdateTest.java 2007-01-19 05:00:41 UTC (rev 1990)
@@ -0,0 +1,158 @@
+/*
+ * 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.test.messaging.jms.clustering;
+
+import org.jboss.test.messaging.jms.clustering.base.ClusteringTestBase;
+import org.jboss.test.messaging.tools.ServerManagement;
+import org.jboss.jms.client.JBossConnectionFactory;
+import org.jboss.jms.client.state.ConnectionState;
+import org.jboss.jms.client.delegate.ClientClusteredConnectionFactoryDelegate;
+import javax.jms.Connection;
+import javax.jms.Session;
+
+/**
+ * @author <a href="mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
+ * @version <tt>$Revision$</tt>
+ *
+ * $Id$
+ */
+public class ClusterViewUpdateTest extends ClusteringTestBase
+{
+
+ // Constants ------------------------------------------------------------------------------------
+
+ // Attributes -----------------------------------------------------------------------------------
+
+ // Static ---------------------------------------------------------------------------------------
+
+ // Constructors ---------------------------------------------------------------------------------
+
+ public ClusterViewUpdateTest(String name)
+ {
+ super(name);
+ }
+
+ // Public ---------------------------------------------------------------------------------------
+
+ public void testUpdateConnectionFactory() throws Exception
+ {
+ Connection conn = cf.createConnection();
+
+ JBossConnectionFactory jbcf = (JBossConnectionFactory)cf;
+
+ ClientClusteredConnectionFactoryDelegate cfDelegate =
+ (ClientClusteredConnectionFactoryDelegate)jbcf.getDelegate();
+
+ assertEquals(3, cfDelegate.getDelegates().length);
+
+ Connection conn1 = cf.createConnection();
+
+ assertEquals(1, getServerId(conn1));
+
+ ServerManagement.killAndWait(1);
+
+ log.info("sleeping 5 secs ...");
+ Thread.sleep(5000);
+
+ // first part of the test, verifies if the CF was updated
+ assertEquals(2, cfDelegate.getDelegates().length);
+ conn.close();
+
+ log.info("sleeping 25 secs ...");
+ Thread.sleep(25000);
+
+ // Second part, verifies a possible racing condition on failoverMap and handleFilover
+
+ log.info("ServerId=" + getServerId(conn1));
+ assertTrue(1 != getServerId(conn1));
+
+ //Session sess = conn1.createSession(true, Session.SESSION_TRANSACTED);
+ conn1.close();
+
+ }
+
+ /**
+ * Test if an update on failoverMap on the connectionFactory would
+ * cause any problems during failover
+ */
+ public void testUpdateConnectionFactoryRaceCondition() throws Exception
+ {
+ // This connection needs to be opened, as we need the callback to update CF from this conn
+ Connection conn = cf.createConnection();
+ JBossConnectionFactory jbcf = (JBossConnectionFactory) cf;
+ ClientClusteredConnectionFactoryDelegate cfDelegate =
+ (ClientClusteredConnectionFactoryDelegate) jbcf.getDelegate();
+ assertEquals(3, cfDelegate.getDelegates().length);
+
+ Connection conn1 = cf.createConnection();
+
+ Connection conn2 = cf.createConnection();
+
+ assertEquals(2, getServerId(conn2));
+
+ assertEquals(1, getServerId(conn1));
+
+ ConnectionState state = this.getConnectionState(conn1);
+
+ // Disable Leasing for Failover
+ state.getRemotingConnection().removeConnectionListener();
+
+ ServerManagement.killAndWait(1);
+
+ Thread.sleep(15000);
+
+ // This will force Failover from Valve to kick in
+ conn1.createSession(true, Session.SESSION_TRANSACTED);
+
+ // first part of the test, verifies if the CF was updated
+ assertEquals(2, cfDelegate.getDelegates().length);
+
+ log.info("ServerId=" + getServerId(conn1));
+ assertTrue(1 != getServerId(conn1));
+
+ conn.close();
+ conn1.close();
+ conn2.close();
+
+ }
+
+ // Package protected ----------------------------------------------------------------------------
+
+ // Protected ------------------------------------------------------------------------------------
+
+ protected void setUp() throws Exception
+ {
+ nodeCount = 3;
+ super.setUp();
+ }
+
+ protected void tearDown() throws Exception
+ {
+ super.tearDown();
+ }
+
+ // Private --------------------------------------------------------------------------------------
+
+ // Inner classes --------------------------------------------------------------------------------
+
+}
Property changes on: trunk/tests/src/org/jboss/test/messaging/jms/clustering/ClusterViewUpdateTest.java
___________________________________________________________________
Name: svn:keywords
+ Id LastChangedDate Author Revision
Modified: trunk/tests/src/org/jboss/test/messaging/jms/clustering/ClusteringAspectInternalTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/clustering/ClusteringAspectInternalTest.java 2007-01-19 03:24:03 UTC (rev 1989)
+++ trunk/tests/src/org/jboss/test/messaging/jms/clustering/ClusteringAspectInternalTest.java 2007-01-19 05:00:41 UTC (rev 1990)
@@ -28,12 +28,12 @@
import java.lang.reflect.Method;
/**
- * This class tests internal methods of ClusteringAspect
+ * This class tests internal methods of ClusteringAspect.
*
* @author <a href="mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
* @version <tt>$Revision$</tt>
*
- * $Id$
+ * $Id$
*/
public class ClusteringAspectInternalTest extends MessagingTestCase
{
@@ -67,20 +67,18 @@
}
-
-
// Package protected ----------------------------------------------------------------------------
// Protected ------------------------------------------------------------------------------------
protected void setUp() throws Exception
{
- super.setUp(); //To change body of overridden methods use File | Settings | File Templates.
+ super.setUp();
}
protected void tearDown() throws Exception
{
- super.tearDown(); //To change body of overridden methods use File | Settings | File Templates.
+ super.tearDown();
}
// Private --------------------------------------------------------------------------------------
@@ -100,6 +98,7 @@
return (Integer) method.invoke(null, new Object[]{map, value});
}
+
// Inner classes --------------------------------------------------------------------------------
}
Deleted: trunk/tests/src/org/jboss/test/messaging/jms/clustering/ConnectionFactoryUpdateTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/clustering/ConnectionFactoryUpdateTest.java 2007-01-19 03:24:03 UTC (rev 1989)
+++ trunk/tests/src/org/jboss/test/messaging/jms/clustering/ConnectionFactoryUpdateTest.java 2007-01-19 05:00:41 UTC (rev 1990)
@@ -1,156 +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.test.messaging.jms.clustering;
-
-import org.jboss.test.messaging.jms.clustering.base.ClusteringTestBase;
-import org.jboss.test.messaging.tools.ServerManagement;
-import org.jboss.jms.client.JBossConnectionFactory;
-import org.jboss.jms.client.state.ConnectionState;
-import org.jboss.jms.client.delegate.ClientClusteredConnectionFactoryDelegate;
-import javax.jms.Connection;
-import javax.jms.Session;
-
-/**
- * @author <a href="mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
- * @version <tt>$Revision$</tt>
- *
- * $Id$
- */
-public class ConnectionFactoryUpdateTest extends ClusteringTestBase
-{
-
- // Constants ------------------------------------------------------------------------------------
-
- // Attributes -----------------------------------------------------------------------------------
-
- // Static ---------------------------------------------------------------------------------------
-
- // Constructors ---------------------------------------------------------------------------------
-
- public ConnectionFactoryUpdateTest(String name)
- {
- super(name);
- }
-
- // Public ---------------------------------------------------------------------------------------
- /**
- */
- public void testUpdateConnectionFactory() throws Exception
- {
- Connection conn = cf.createConnection();
- JBossConnectionFactory jbcf = (JBossConnectionFactory) cf;
- ClientClusteredConnectionFactoryDelegate cfDelegate =
- (ClientClusteredConnectionFactoryDelegate) jbcf.getDelegate();
- assertEquals(3, cfDelegate.getDelegates().length);
-
-
- Connection conn1 = cf.createConnection();
-
- assertEquals(1, getServerId(conn1));
-
- ServerManagement.killAndWait(1);
-
- Thread.sleep(5000);
-
- // first part of the test, verifies if the CF was updated
- assertEquals(2, cfDelegate.getDelegates().length);
- conn.close();
-
- Thread.sleep(25000);
-
- // Second part, verifies a possible racing condition on failoverMap and handleFilover
-
- log.info("ServerId=" + getServerId(conn1));
- assertTrue(1 != getServerId(conn1));
-
- //Session sess = conn1.createSession(true, Session.SESSION_TRANSACTED);
- conn1.close();
-
- }
-
- /**
- * Test if an update on failoverMap on the connectionFactory would
- * cause any problems during failover
- */
- public void testUpdateConnectionFactoryRaceCondition() throws Exception
- {
- // This connection needs to be opened, as we need the callback to update CF from this conn
- Connection conn = cf.createConnection();
- JBossConnectionFactory jbcf = (JBossConnectionFactory) cf;
- ClientClusteredConnectionFactoryDelegate cfDelegate =
- (ClientClusteredConnectionFactoryDelegate) jbcf.getDelegate();
- assertEquals(3, cfDelegate.getDelegates().length);
-
- Connection conn1 = cf.createConnection();
-
- Connection conn2 = cf.createConnection();
-
- assertEquals(2, getServerId(conn2));
-
- assertEquals(1, getServerId(conn1));
-
- ConnectionState state = this.getConnectionState(conn1);
-
- // Disable Leasing for Failover
- state.getRemotingConnection().removeConnectionListener();
-
- ServerManagement.killAndWait(1);
-
- Thread.sleep(15000);
-
- // This will force Failover from Valve to kick in
- Session sess = conn1.createSession(true, Session.SESSION_TRANSACTED);
-
- // first part of the test, verifies if the CF was updated
- assertEquals(2, cfDelegate.getDelegates().length);
-
- log.info("ServerId=" + getServerId(conn1));
- assertTrue(1 != getServerId(conn1));
-
- conn.close();
- conn1.close();
- conn2.close();
-
- }
-
-
- // Package protected ----------------------------------------------------------------------------
-
- // Protected ------------------------------------------------------------------------------------
-
- protected void setUp() throws Exception
- {
- nodeCount = 3;
- super.setUp();
- }
-
- protected void tearDown() throws Exception
- {
- super.tearDown();
- }
-
- // Private --------------------------------------------------------------------------------------
-
- // Inner classes --------------------------------------------------------------------------------
-
-}
Modified: trunk/tests/src/org/jboss/test/messaging/tools/jndi/RemoteInitialContextFactory.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/jndi/RemoteInitialContextFactory.java 2007-01-19 03:24:03 UTC (rev 1989)
+++ trunk/tests/src/org/jboss/test/messaging/tools/jndi/RemoteInitialContextFactory.java 2007-01-19 05:00:41 UTC (rev 1990)
@@ -63,8 +63,6 @@
public Context getInitialContext(Hashtable environment) throws NamingException
{
- log.info(this + " getting intial context for " + environment);
-
String s = (String)environment.get(Constants.SERVER_INDEX_PROPERTY_NAME);
if (s == null)
More information about the jboss-cvs-commits
mailing list