[jboss-cvs] JBoss Messaging SVN: r2400 - in trunk: tests/src/org/jboss/test/messaging/core/plugin/base and 1 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Feb 23 06:57:03 EST 2007
Author: timfox
Date: 2007-02-23 06:57:03 -0500 (Fri, 23 Feb 2007)
New Revision: 2400
Modified:
trunk/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/DefaultRouter.java
trunk/tests/src/org/jboss/test/messaging/core/plugin/base/PostOfficeTestBase.java
trunk/tests/src/org/jboss/test/messaging/core/plugin/postoffice/cluster/DefaultRouterTest.java
Log:
http://jira.jboss.org/jira/browse/JBMESSAGING-888
Modified: trunk/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/DefaultRouter.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/DefaultRouter.java 2007-02-23 01:21:29 UTC (rev 2399)
+++ trunk/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/DefaultRouter.java 2007-02-23 11:57:03 UTC (rev 2400)
@@ -34,10 +34,15 @@
import org.jboss.messaging.core.tx.Transaction;
/**
- * This router always favours the local queue.
*
+ * This router first favours the failed over queue (if there is one) TODO revisit this
+ *
+ * Then it favours the local queue.
+ *
* If there is no local queue, then it will round robin between the non local queues.
*
+ * FIXME - none of the new failed over functionality has been tested!!
+ *
* @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
* @author <a href="mailto:ovidiu at jboss.org">Ovidiu Feodorov</a>
* @version <tt>$Revision$</tt>
@@ -72,6 +77,7 @@
public DefaultRouter()
{
nonLocalQueues = new ArrayList();
+
failedOverQueues = new ArrayList();
}
@@ -83,6 +89,7 @@
// Favour the local queue or the failedOver queue in round robin
+ //TODO - revisit all of this - it doesn't look right to me - Tim
if (!failedOverQueues.isEmpty())
{
// If the message arrived over a failed-over connection, try to send the message to its
@@ -105,29 +112,9 @@
return del;
}
- else
- {
- LocalClusteredQueue queueToUse = null;
-
- if (target == -1)
- {
- queueToUse = (LocalClusteredQueue)localQueue;
- }
- else
- {
- queueToUse = (LocalClusteredQueue)failedOverQueues.get(target);
- }
-
- incTargetFailedOver();
-
- Delivery del = queueToUse.handle(observer, ref, tx);
-
- if (trace) { log.trace(this + " routed message to failed queue, using failed-over round robbing, returned " + del); }
-
- return del;
- }
}
- else if (localQueue != null)
+
+ if (localQueue != null)
{
// The only time the local queue won't accept is if the selector doesn't match, in which
// case it won't match at any other nodes too so no point in trying them
@@ -168,11 +155,14 @@
public boolean contains(Receiver queue)
{
+ //FIXME - what about failed over queues??
return localQueue == queue || nonLocalQueues.contains(queue);
}
public Iterator iterator()
{
+ //FIXME - this is broken - where are the failed over queuues?
+
List queues = new ArrayList();
if (localQueue != null)
@@ -195,6 +185,7 @@
if (localQueue == queue)
{
localQueue = null;
+
return true;
}
else
@@ -209,7 +200,15 @@
}
else
{
- return false;
+ //Maybe it's a failed over queue
+ if (this.failedOverQueues.remove(queue))
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
}
}
}
@@ -217,12 +216,17 @@
public void clear()
{
nonLocalQueues.clear();
+
+ failedOverQueues.clear();
+
localQueue = null;
+
target = 0;
}
public int getNumberOfReceivers()
{
+ //FIXME - what about failed over queues????
return nonLocalQueues.size() + (localQueue != null ? 1 : 0);
}
@@ -297,17 +301,6 @@
// Private --------------------------------------------------------------------------------------
- private void incTargetFailedOver()
- {
- target++;
-
- if (target == failedOverQueues.size())
- {
- target = -1; // use the local queue
- }
- }
-
-
private void incTarget()
{
target++;
@@ -322,6 +315,9 @@
{
// TODO - this is a VERY slow sequential pass; I am sure we can come with a smarter way to
// locate the queue
+
+ // This is rubbish - should be using a Map for the failed over queues
+ // or better still rethink the whole way this failed over queue routing works - it is a mess!
for(int i = 0; i < failedOverQueues.size(); i++)
{
if (((FailedOverQueue)failedOverQueues.get(i)).getFailedNodeID() == failedNodeID)
Modified: trunk/tests/src/org/jboss/test/messaging/core/plugin/base/PostOfficeTestBase.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/core/plugin/base/PostOfficeTestBase.java 2007-02-23 01:21:29 UTC (rev 2399)
+++ trunk/tests/src/org/jboss/test/messaging/core/plugin/base/PostOfficeTestBase.java 2007-02-23 11:57:03 UTC (rev 2400)
@@ -45,6 +45,7 @@
import org.jboss.messaging.core.plugin.postoffice.cluster.DefaultRouterFactory;
import org.jboss.messaging.core.plugin.postoffice.cluster.MessagePullPolicy;
import org.jboss.messaging.core.plugin.postoffice.cluster.NullMessagePullPolicy;
+import org.jboss.messaging.core.plugin.postoffice.cluster.RoundRobinRouterFactory;
import org.jboss.messaging.core.plugin.postoffice.cluster.jchannelfactory.JChannelFactory;
import org.jboss.messaging.core.tx.Transaction;
import org.jboss.messaging.core.tx.TransactionRepository;
@@ -83,10 +84,36 @@
throws Exception
{
return createClusteredPostOffice(nodeID, groupName, 5000, 5000, new NullMessagePullPolicy(),
- sc, ms, pm, tr);
+ sc, ms, pm, tr, new DefaultRouterFactory());
}
+
+ protected static ClusteredPostOffice createClusteredPostOfficeWithRRR(int nodeID,
+ String groupName,
+ ServiceContainer sc,
+ MessageStore ms,
+ PersistenceManager pm,
+ TransactionRepository tr)
+ throws Exception
+ {
+ return createClusteredPostOffice(nodeID, groupName, 5000, 5000, new NullMessagePullPolicy(),
+ sc, ms, pm, tr, new RoundRobinRouterFactory());
+ }
+
+ protected static ClusteredPostOffice createClusteredPostOffice(int nodeID,
+ String groupName,
+ long stateTimeout,
+ long castTimeout,
+ MessagePullPolicy pullPolicy,
+ ServiceContainer sc,
+ MessageStore ms,
+ PersistenceManager pm,
+ TransactionRepository tr) throws Exception
+ {
+ return createClusteredPostOffice(nodeID, groupName, stateTimeout, castTimeout, pullPolicy, sc, ms, pm, tr,
+ new DefaultRouterFactory());
+ }
+
-
protected static ClusteredPostOffice createClusteredPostOffice(int nodeID,
String groupName,
long stateTimeout,
@@ -95,11 +122,11 @@
ServiceContainer sc,
MessageStore ms,
PersistenceManager pm,
- TransactionRepository tr)
+ TransactionRepository tr,
+ ClusterRouterFactory rf)
throws Exception
{
FilterFactory ff = new SimpleFilterFactory();
- ClusterRouterFactory rf = new DefaultRouterFactory();
FailoverMapper mapper = new DefaultFailoverMapper();
ConditionFactory cf = new SimpleConditionFactory();
Modified: trunk/tests/src/org/jboss/test/messaging/core/plugin/postoffice/cluster/DefaultRouterTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/core/plugin/postoffice/cluster/DefaultRouterTest.java 2007-02-23 01:21:29 UTC (rev 2399)
+++ trunk/tests/src/org/jboss/test/messaging/core/plugin/postoffice/cluster/DefaultRouterTest.java 2007-02-23 11:57:03 UTC (rev 2400)
@@ -44,6 +44,8 @@
/**
* @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
* @version <tt>$Revision$</tt>
+ *
+ * TODO Need to add tests for failed over queues to this
*
* $Id$
*
@@ -304,32 +306,6 @@
receiver.clear();
}
-// private void sendAndCheck(ClusterRouter router, Queue queue) throws Throwable
-// {
-// Message msg = CoreMessageFactory.createCoreMessage(nextId++, false, null);
-//
-// MessageReference ref = ms.reference(msg);
-//
-// Delivery del = router.handle(null, ref, null);
-//
-// assertNotNull(del);
-//
-// assertTrue(del.isSelectorAccepted());
-//
-// Thread.sleep(250);
-//
-// List msgs = queue.browse();
-//
-// assertNotNull(msgs);
-//
-// assertEquals(1, msgs.size());
-//
-// Message msgRec = (Message)msgs.get(0);
-//
-// assertTrue(msg == msgRec);
-//
-// queue.removeAllReferences();
-// }
// Private -------------------------------------------------------
More information about the jboss-cvs-commits
mailing list