[jboss-cvs] JBoss Messaging SVN: r7672 - in branches/Branch_MultiThreaded_Replication: src/main/org/jboss/messaging/core/server/impl and 1 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Aug 6 05:27:50 EDT 2009


Author: timfox
Date: 2009-08-06 05:27:50 -0400 (Thu, 06 Aug 2009)
New Revision: 7672

Added:
   branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/remoting/impl/wireformat/replication/ReplicateNotificationMessage.java
   branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/remoting/impl/wireformat/replication/ReplicateUpdateConnectorsMessage.java
   branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/server/impl/BridgePacketHandler.java
   branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/server/impl/ClusterConnectionPacketHandler.java
   branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/server/impl/MessageFlowRecordPacketHandler.java
   branches/Branch_MultiThreaded_Replication/tests/src/org/jboss/messaging/tests/integration/cluster/distribution/SmallClusterWithBackupTest.java
Log:
last files before MT replication park

Added: branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/remoting/impl/wireformat/replication/ReplicateNotificationMessage.java
===================================================================
--- branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/remoting/impl/wireformat/replication/ReplicateNotificationMessage.java	                        (rev 0)
+++ branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/remoting/impl/wireformat/replication/ReplicateNotificationMessage.java	2009-08-06 09:27:50 UTC (rev 7672)
@@ -0,0 +1,87 @@
+/*
+ * JBoss, Home of Professional Open Source Copyright 2005-2008, Red Hat Middleware LLC, and individual contributors 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.messaging.core.remoting.impl.wireformat.replication;
+
+import org.jboss.messaging.core.client.ClientMessage;
+import org.jboss.messaging.core.client.impl.ClientMessageImpl;
+import org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl;
+import org.jboss.messaging.core.remoting.spi.MessagingBuffer;
+
+/**
+ * 
+ * A ReplicateRemoteBindingAddedMessage
+ *
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * 
+ * Created 4 Mar 2009 18:36:30
+ *
+ *
+ */
+public class ReplicateNotificationMessage extends PacketImpl
+{
+   // Constants -----------------------------------------------------
+
+   // Attributes ----------------------------------------------------
+
+   private ClientMessage clientMessage;
+
+   // Static --------------------------------------------------------
+
+   // Constructors --------------------------------------------------
+
+   public ReplicateNotificationMessage(final ClientMessage message)
+   {
+      super(REPLICATE_NOTIFICATION);
+      
+      this.clientMessage = message;
+   }
+
+   // Public --------------------------------------------------------
+
+   public ReplicateNotificationMessage()
+   {
+      super(REPLICATE_NOTIFICATION);
+   }
+
+   public int getRequiredBufferSize()
+   {
+      return BASIC_PACKET_SIZE + clientMessage.getEncodeSize();
+   }
+
+   @Override
+   public void encodeBody(final MessagingBuffer buffer)
+   {
+      clientMessage.encode(buffer);
+   }
+
+   @Override
+   public void decodeBody(final MessagingBuffer buffer)
+   {
+      clientMessage = new ClientMessageImpl();
+      
+      clientMessage.decode(buffer);
+   }
+
+   public ClientMessage getMessage()
+   {
+      return clientMessage;
+   }
+
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private -------------------------------------------------------
+
+   // Inner classes -------------------------------------------------
+}

Added: branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/remoting/impl/wireformat/replication/ReplicateUpdateConnectorsMessage.java
===================================================================
--- branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/remoting/impl/wireformat/replication/ReplicateUpdateConnectorsMessage.java	                        (rev 0)
+++ branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/remoting/impl/wireformat/replication/ReplicateUpdateConnectorsMessage.java	2009-08-06 09:27:50 UTC (rev 7672)
@@ -0,0 +1,123 @@
+/*
+ * JBoss, Home of Professional Open Source Copyright 2005-2008, Red Hat Middleware LLC, and individual contributors 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.messaging.core.remoting.impl.wireformat.replication;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jboss.messaging.core.buffers.ChannelBuffers;
+import org.jboss.messaging.core.config.TransportConfiguration;
+import org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl;
+import org.jboss.messaging.core.remoting.spi.MessagingBuffer;
+import org.jboss.messaging.utils.Pair;
+
+/**
+ * 
+ * A ReplicateRemoteBindingAddedMessage
+ *
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * 
+ * Created 4 Mar 2009 18:36:30
+ *
+ *
+ */
+public class ReplicateUpdateConnectorsMessage extends PacketImpl
+{
+   // Constants -----------------------------------------------------
+
+   // Attributes ----------------------------------------------------
+
+   private Map<String, Pair<TransportConfiguration, TransportConfiguration>> map;
+
+   private MessagingBuffer pairBuffer;
+
+   // Static --------------------------------------------------------
+
+   // Constructors --------------------------------------------------
+
+   public ReplicateUpdateConnectorsMessage(final Map<String, Pair<TransportConfiguration, TransportConfiguration>> map)
+   {
+      super(REPLICATE_UPDATE_CONNECTORS);
+      
+      pairBuffer = ChannelBuffers.dynamicBuffer(4096);
+      
+      this.pairBuffer.writeInt(map.size());
+      for (Map.Entry<String, Pair<TransportConfiguration, TransportConfiguration>> entry: map.entrySet())
+      {
+         this.pairBuffer.writeString(entry.getKey());
+         entry.getValue().a.encode(pairBuffer);
+         if (entry.getValue().b != null)
+         {
+            this.pairBuffer.writeBoolean(true);
+            entry.getValue().b.encode(this.pairBuffer);
+         }
+         else
+         {
+            this.pairBuffer.writeBoolean(false);
+         }
+      }
+   }
+
+   // Public --------------------------------------------------------
+
+   public ReplicateUpdateConnectorsMessage()
+   {
+      super(REPLICATE_UPDATE_CONNECTORS);
+   }
+
+   public int getRequiredBufferSize()
+   {
+      return BASIC_PACKET_SIZE + pairBuffer.writerIndex();
+   }
+
+   @Override
+   public void encodeBody(final MessagingBuffer buffer)
+   {
+      buffer.writeBytes(pairBuffer, 0, pairBuffer.writerIndex());
+   }
+
+   @Override
+   public void decodeBody(final MessagingBuffer buffer)
+   {
+      int size = buffer.readInt();
+      this.map = new HashMap<String, Pair<TransportConfiguration, TransportConfiguration>>();
+      for (int i = 0; i < size; i++)
+      {      
+         String nodeID = buffer.readString();
+         TransportConfiguration tcLive = new TransportConfiguration();
+         tcLive.decode(buffer);
+         boolean hasBackup = buffer.readBoolean();
+         TransportConfiguration tcBackup = null;
+         if (hasBackup)
+         {
+            tcBackup = new TransportConfiguration();
+            tcBackup.decode(buffer);
+         }
+         Pair<TransportConfiguration, TransportConfiguration> connectorPair = new Pair<TransportConfiguration, TransportConfiguration>(tcLive, tcBackup);
+         this.map.put(nodeID, connectorPair);
+      }
+   }
+
+   public Map<String, Pair<TransportConfiguration, TransportConfiguration>> getMap()
+   {
+      return map;
+   }
+
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private -------------------------------------------------------
+
+   // Inner classes -------------------------------------------------
+}

Added: branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/server/impl/BridgePacketHandler.java
===================================================================
--- branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/server/impl/BridgePacketHandler.java	                        (rev 0)
+++ branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/server/impl/BridgePacketHandler.java	2009-08-06 09:27:50 UTC (rev 7672)
@@ -0,0 +1,112 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005-2009, Red Hat Middleware LLC, and individual contributors
+ * 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.messaging.core.server.impl;
+
+import static org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl.REPLICATE_LOCK_SEQUENCES;
+
+import java.util.List;
+
+import org.jboss.messaging.core.logging.Logger;
+import org.jboss.messaging.core.remoting.Channel;
+import org.jboss.messaging.core.remoting.ChannelHandler;
+import org.jboss.messaging.core.remoting.Packet;
+import org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl;
+import org.jboss.messaging.core.remoting.impl.wireformat.replication.ReplicateLockSequenceMessage;
+import org.jboss.messaging.core.remoting.impl.wireformat.replication.ReplicationResponseMessage;
+import org.jboss.messaging.core.server.cluster.Bridge;
+import org.jboss.messaging.core.server.replication.impl.JBMThread;
+import org.jboss.messaging.utils.Triple;
+
+/**
+ * 
+ * A BridgePacketHandler
+ *
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ *
+ *
+ */
+public class BridgePacketHandler implements ChannelHandler
+{
+   private static final Logger log = Logger.getLogger(BridgePacketHandler.class);
+
+   private final Bridge bridge;
+
+   private volatile List<Triple<Long, Long, Integer>> sequences;
+
+   private final Channel channel;
+
+   public BridgePacketHandler(final Bridge bridge, final Channel channel)
+   {
+      this.bridge = bridge;
+
+      this.channel = channel;
+   }
+
+   public void handlePacket(final Packet packet)
+   {
+      switch (packet.getType())
+      {
+         case REPLICATE_LOCK_SEQUENCES:
+         {
+            ReplicateLockSequenceMessage msg = (ReplicateLockSequenceMessage)packet;
+
+            sequences = msg.getSequences();
+
+            // log.info("got sequences on queue " + msg.getID());
+            // dumpSequences(sequences);
+
+            break;
+         }
+         case PacketImpl.REPLICATE_BRIDGE_ACKNOWLEDGE:
+         {
+            JBMThread thread = JBMThread.currentThread();
+
+            thread.setReplay(sequences);
+
+            bridge.acknowledge();
+
+            channel.send(new ReplicationResponseMessage());
+
+            thread.setNoReplayOrRecord(12);
+
+            break;
+         }
+
+         default:
+         {
+            throw new IllegalArgumentException("Invalid packet " + packet);
+         }
+      }
+   }
+
+   private void dumpSequences(List<Triple<Long, Long, Integer>> sequences)
+   {
+      log.info(Thread.currentThread() + " Got on cluster connection replication ph Sequences size is " +
+               sequences.size());
+
+      for (Triple<Long, Long, Integer> sequence : sequences)
+      {
+         log.info(sequence.a + ": " + sequence.b);
+      }
+   }
+}

Added: branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/server/impl/ClusterConnectionPacketHandler.java
===================================================================
--- branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/server/impl/ClusterConnectionPacketHandler.java	                        (rev 0)
+++ branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/server/impl/ClusterConnectionPacketHandler.java	2009-08-06 09:27:50 UTC (rev 7672)
@@ -0,0 +1,115 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005-2009, Red Hat Middleware LLC, and individual contributors
+ * 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.messaging.core.server.impl;
+
+import static org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl.REPLICATE_LOCK_SEQUENCES;
+import static org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl.REPLICATE_UPDATE_CONNECTORS;
+
+import java.util.List;
+
+import org.jboss.messaging.core.logging.Logger;
+import org.jboss.messaging.core.remoting.Channel;
+import org.jboss.messaging.core.remoting.ChannelHandler;
+import org.jboss.messaging.core.remoting.Packet;
+import org.jboss.messaging.core.remoting.impl.wireformat.replication.ReplicateLockSequenceMessage;
+import org.jboss.messaging.core.remoting.impl.wireformat.replication.ReplicateUpdateConnectorsMessage;
+import org.jboss.messaging.core.remoting.impl.wireformat.replication.ReplicationResponseMessage;
+import org.jboss.messaging.core.server.cluster.ClusterConnection;
+import org.jboss.messaging.core.server.replication.impl.JBMThread;
+import org.jboss.messaging.utils.Triple;
+
+/**
+ * 
+ * A ClusterConnectionPacketHandler
+ *
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ *
+ *
+ */
+public class ClusterConnectionPacketHandler implements ChannelHandler
+{
+   private static final Logger log = Logger.getLogger(ClusterConnectionPacketHandler.class);
+
+   private final ClusterConnection clusterConnection;
+
+   private volatile List<Triple<Long, Long, Integer>> sequences;
+
+   private final Channel channel;
+
+   public ClusterConnectionPacketHandler(final ClusterConnection clusterConnection, final Channel channel)
+   {
+      this.clusterConnection = clusterConnection;
+
+      this.channel = channel;
+   }
+
+   public void handlePacket(final Packet packet)
+   {
+      switch (packet.getType())
+      {
+         case REPLICATE_LOCK_SEQUENCES:
+         {
+            ReplicateLockSequenceMessage msg = (ReplicateLockSequenceMessage)packet;
+
+            sequences = msg.getSequences();
+
+            // log.info("got sequences on queue " + msg.getID());
+            // dumpSequences(sequences);
+
+            break;
+         }
+         case REPLICATE_UPDATE_CONNECTORS:
+         {
+            JBMThread thread = JBMThread.currentThread();
+
+            thread.setReplay(sequences);
+
+            ReplicateUpdateConnectorsMessage msg = (ReplicateUpdateConnectorsMessage)packet;
+
+            clusterConnection.updateConnectors(msg.getMap());
+
+            channel.send(new ReplicationResponseMessage());
+
+            thread.setNoReplayOrRecord(12);
+
+            break;
+         }
+
+         default:
+         {
+            throw new IllegalArgumentException("Invalid packet " + packet);
+         }
+      }
+   }
+
+   private void dumpSequences(List<Triple<Long, Long, Integer>> sequences)
+   {
+      log.info(Thread.currentThread() + " Got on cluster connection replication ph Sequences size is " +
+               sequences.size());
+
+      for (Triple<Long, Long, Integer> sequence : sequences)
+      {
+         log.info(sequence.a + ": " + sequence.b);
+      }
+   }
+}

Added: branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/server/impl/MessageFlowRecordPacketHandler.java
===================================================================
--- branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/server/impl/MessageFlowRecordPacketHandler.java	                        (rev 0)
+++ branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/server/impl/MessageFlowRecordPacketHandler.java	2009-08-06 09:27:50 UTC (rev 7672)
@@ -0,0 +1,116 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005-2009, Red Hat Middleware LLC, and individual contributors
+ * 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.messaging.core.server.impl;
+
+import static org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl.REPLICATE_LOCK_SEQUENCES;
+import static org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl.REPLICATE_NOTIFICATION;
+
+import java.util.List;
+
+import org.jboss.messaging.core.logging.Logger;
+import org.jboss.messaging.core.remoting.Channel;
+import org.jboss.messaging.core.remoting.ChannelHandler;
+import org.jboss.messaging.core.remoting.Packet;
+import org.jboss.messaging.core.remoting.impl.wireformat.replication.ReplicateLockSequenceMessage;
+import org.jboss.messaging.core.remoting.impl.wireformat.replication.ReplicateNotificationMessage;
+import org.jboss.messaging.core.remoting.impl.wireformat.replication.ReplicationResponseMessage;
+import org.jboss.messaging.core.server.cluster.MessageFlowRecord;
+import org.jboss.messaging.core.server.replication.impl.JBMThread;
+import org.jboss.messaging.utils.Triple;
+
+/**
+ * 
+ * A MessageFlowRecordPacketHandler
+ *
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ *
+ *
+ */
+public class MessageFlowRecordPacketHandler implements ChannelHandler
+{
+   private static final Logger log = Logger.getLogger(MessageFlowRecordPacketHandler.class);
+
+   private final MessageFlowRecord record;
+   
+   private volatile List<Triple<Long, Long, Integer>> sequences;
+
+   private final Channel channel;
+
+   public MessageFlowRecordPacketHandler(final MessageFlowRecord record ,                                        
+                                         final Channel channel)
+   {
+      this.record = record;
+      
+      this.channel = channel;
+   }
+
+   public void handlePacket(final Packet packet)
+   {
+      switch (packet.getType())
+      {
+         case REPLICATE_LOCK_SEQUENCES:
+         {
+            ReplicateLockSequenceMessage msg = (ReplicateLockSequenceMessage)packet;
+
+            sequences = msg.getSequences();
+
+            // log.info("got sequences on queue " + msg.getID());
+             dumpSequences(sequences);
+
+            break;
+         }
+         case REPLICATE_NOTIFICATION:
+         {
+            JBMThread thread = JBMThread.currentThread();
+
+            thread.setReplay(sequences);
+            
+            ReplicateNotificationMessage msg = (ReplicateNotificationMessage)packet; 
+
+            record.onMessage(msg.getMessage());
+
+            channel.send(new ReplicationResponseMessage());
+
+            thread.setNoReplayOrRecord(12);
+
+            break;
+         }
+         
+         default:
+         {
+            throw new IllegalArgumentException("Invalid packet " + packet);
+         }
+      }
+   }
+
+   private void dumpSequences(List<Triple<Long, Long, Integer>> sequences)
+   {
+      log.info(Thread.currentThread() + " Got on flow record replication ph Sequences size is " +
+               sequences.size());
+
+      for (Triple<Long, Long, Integer> sequence : sequences)
+      {
+         log.info(sequence.a + ": " + sequence.b);
+      }
+   }
+}

Added: branches/Branch_MultiThreaded_Replication/tests/src/org/jboss/messaging/tests/integration/cluster/distribution/SmallClusterWithBackupTest.java
===================================================================
--- branches/Branch_MultiThreaded_Replication/tests/src/org/jboss/messaging/tests/integration/cluster/distribution/SmallClusterWithBackupTest.java	                        (rev 0)
+++ branches/Branch_MultiThreaded_Replication/tests/src/org/jboss/messaging/tests/integration/cluster/distribution/SmallClusterWithBackupTest.java	2009-08-06 09:27:50 UTC (rev 7672)
@@ -0,0 +1,131 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005-2009, Red Hat Middleware LLC, and individual contributors
+ * 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.messaging.tests.integration.cluster.distribution;
+
+import org.jboss.messaging.core.logging.Logger;
+
+/**
+ * 
+ * A SmallClusterWithBackupTest
+ *
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ *
+ *
+ */
+public class SmallClusterWithBackupTest extends ClusterTestBase
+{
+   private static final Logger log = Logger.getLogger(SmallClusterWithBackupTest.class);
+
+   @Override
+   protected void setUp() throws Exception
+   {
+      super.setUp();
+
+      setupServers();
+   }
+
+   @Override
+   protected void tearDown() throws Exception
+   {
+      stopServers();
+
+      super.tearDown();
+   }
+
+   protected boolean isNetty()
+   {
+      return false;
+   }
+
+   protected boolean isFileStorage()
+   {
+      return false;
+   }
+   
+   public void testBasicRoundRobin() throws Exception
+   {
+      setupCluster();
+
+      startServers(0, 1, 2, 3);
+      
+      setupSessionFactory(2, isNetty());
+      setupSessionFactory(3, isNetty());
+      
+      createQueue(2, "queues.testaddress", "queue0", null, false);
+      createQueue(3, "queues.testaddress", "queue0", null, false);
+      
+      addConsumer(0, 2, "queue0", null);
+      addConsumer(1, 3, "queue0", null);
+      
+      waitForBindings(2, "queues.testaddress", 1, 1, true);
+      waitForBindings(3, "queues.testaddress", 1, 1, true);
+
+      waitForBindings(2, "queues.testaddress", 1, 1, false);
+      waitForBindings(3, "queues.testaddress", 1, 1, false);
+
+      send(2, "queues.testaddress", 100, false, null);
+
+      verifyReceiveRoundRobinInSomeOrder(100, 0, 1);
+
+      verifyNotReceive(0, 1);
+   }
+   
+   protected void setupCluster() throws Exception
+   {
+      setupCluster(false);
+   }
+
+   protected void setupCluster(final boolean forwardWhenNoConsumers) throws Exception
+   {
+      setupClusterConnection("cluster0", "queues", forwardWhenNoConsumers, 1, isNetty(), 2, 3);
+
+      setupClusterConnection("cluster1", "queues", forwardWhenNoConsumers, 1, isNetty(), 3, 2);
+
+            
+      setupClusterConnection("cluster0", "queues", forwardWhenNoConsumers, 1, isNetty(), 0, 1);
+
+      setupClusterConnection("cluster1", "queues", forwardWhenNoConsumers, 1, isNetty(), 1, 0);
+   }
+
+   protected void setupServers() throws Exception
+   {
+      //The backups
+      setupServer(0, isFileStorage(), isNetty(), true);
+      setupServer(1, isFileStorage(), isNetty(), true);
+      
+      //The lives
+      setupServer(2, isFileStorage(), isNetty(), 0);
+      setupServer(3, isFileStorage(), isNetty(), 1);    
+      
+   }
+
+   protected void stopServers() throws Exception
+   {
+      closeAllConsumers();
+
+      closeAllSessionFactories();
+
+      stopServers(0, 1, 2, 3);
+   }
+
+}




More information about the jboss-cvs-commits mailing list