[jboss-cvs] JBoss Messaging SVN: r7670 - in branches/Branch_MultiThreaded_Replication: src/main/org/jboss/messaging/core/cluster and 28 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Aug 6 04:56:54 EDT 2009
Author: timfox
Date: 2009-08-06 04:56:53 -0400 (Thu, 06 Aug 2009)
New Revision: 7670
Removed:
branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/remoting/impl/wireformat/replication/ReplicateAcknowledgeMessage.java
branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/remoting/impl/wireformat/replication/ReplicateRedistributionMessage.java
branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/remoting/impl/wireformat/replication/ReplicateRemoteBindingAddedMessage.java
branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/remoting/impl/wireformat/replication/ReplicateRemoteBindingRemovedMessage.java
branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/remoting/impl/wireformat/replication/ReplicateRemoteConsumerAddedMessage.java
branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/remoting/impl/wireformat/replication/ReplicateRemoteConsumerRemovedMessage.java
Modified:
branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/client/impl/ClientSessionFactoryImpl.java
branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/cluster/DiscoveryGroup.java
branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/cluster/impl/DiscoveryGroupImpl.java
branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/management/impl/ManagementServiceImpl.java
branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/persistence/impl/journal/JournalStorageManager.java
branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/persistence/impl/nullpm/NullStorageManager.java
branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/postoffice/impl/BindingsImpl.java
branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/postoffice/impl/ClusterQueueStateManagerImpl.java
branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/postoffice/impl/PostOfficeImpl.java
branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/remoting/Channel.java
branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/remoting/impl/PacketDecoder.java
branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/remoting/impl/wireformat/PacketImpl.java
branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/remoting/server/RemotingService.java
branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/remoting/server/impl/RemotingServiceImpl.java
branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/server/MessagingServer.java
branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/server/Queue.java
branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/server/cluster/Bridge.java
branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/server/cluster/ClusterConnection.java
branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/server/cluster/impl/BridgeImpl.java
branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/server/cluster/impl/ClusterConnectionImpl.java
branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/server/cluster/impl/ClusterManagerImpl.java
branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/server/cluster/impl/Redistributor.java
branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/server/cluster/impl/RemoteQueueBindingImpl.java
branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/server/impl/MessagingServerImpl.java
branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/server/impl/QueueImpl.java
branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/server/impl/ServerSessionPacketHandler.java
branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/server/replication/impl/ReplicationAwareMutex.java
branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/server/replication/impl/ReplicatorImpl.java
branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/server/replication/impl/SequencedLock.java
branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/utils/JBMThreadFactory.java
branches/Branch_MultiThreaded_Replication/tests/src/org/jboss/messaging/tests/concurrent/server/impl/QueueTest.java
branches/Branch_MultiThreaded_Replication/tests/src/org/jboss/messaging/tests/integration/cluster/distribution/OnewayTwoNodeClusterTest.java
branches/Branch_MultiThreaded_Replication/tests/src/org/jboss/messaging/tests/integration/cluster/distribution/SymmetricClusterTest.java
branches/Branch_MultiThreaded_Replication/tests/src/org/jboss/messaging/tests/integration/cluster/failover/FailBackupServerTest.java
branches/Branch_MultiThreaded_Replication/tests/src/org/jboss/messaging/tests/integration/cluster/failover/SplitBrainTest.java
branches/Branch_MultiThreaded_Replication/tests/src/org/jboss/messaging/tests/integration/discovery/DiscoveryTest.java
branches/Branch_MultiThreaded_Replication/tests/src/org/jboss/messaging/tests/integration/paging/PageCrashTest.java
branches/Branch_MultiThreaded_Replication/tests/src/org/jboss/messaging/tests/timing/core/server/impl/QueueImplTest.java
branches/Branch_MultiThreaded_Replication/tests/src/org/jboss/messaging/tests/unit/core/paging/impl/PagingManagerImplTest.java
branches/Branch_MultiThreaded_Replication/tests/src/org/jboss/messaging/tests/unit/core/paging/impl/PagingStoreImplTest.java
branches/Branch_MultiThreaded_Replication/tests/src/org/jboss/messaging/tests/unit/core/postoffice/impl/BindingImplTest.java
branches/Branch_MultiThreaded_Replication/tests/src/org/jboss/messaging/tests/unit/core/server/impl/QueueImplTest.java
branches/Branch_MultiThreaded_Replication/tests/src/org/jboss/messaging/tests/unit/core/server/impl/fakes/FakePostOffice.java
branches/Branch_MultiThreaded_Replication/tests/src/org/jboss/messaging/tests/unit/core/server/impl/fakes/FakeQueueFactory.java
branches/Branch_MultiThreaded_Replication/tests/src/org/jboss/messaging/tests/unit/core/server/replication/impl/QueuedWriteManagerTest.java
branches/Branch_MultiThreaded_Replication/tests/src/org/jboss/messaging/tests/unit/core/server/replication/impl/SequencedLockTest.java
Log:
Parking MT replication code
Modified: branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/client/impl/ClientSessionFactoryImpl.java
===================================================================
--- branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/client/impl/ClientSessionFactoryImpl.java 2009-08-06 08:44:47 UTC (rev 7669)
+++ branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/client/impl/ClientSessionFactoryImpl.java 2009-08-06 08:56:53 UTC (rev 7670)
@@ -14,6 +14,7 @@
import java.io.Serializable;
import java.net.InetAddress;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashMap;
@@ -839,15 +840,11 @@
{
receivedBroadcast = true;
- Map<String, DiscoveryEntry> newConnectors = discoveryGroup.getDiscoveryEntryMap();
+ Map<String, Pair<TransportConfiguration, TransportConfiguration>> newConnectors = discoveryGroup.getDiscoveryEntryMap();
- Set<Pair<TransportConfiguration, TransportConfiguration>> connectorSet = new HashSet<Pair<TransportConfiguration, TransportConfiguration>>();
+ Collection<Pair<TransportConfiguration, TransportConfiguration>> connectorSet =
+ newConnectors.values();
- for (DiscoveryEntry entry : newConnectors.values())
- {
- connectorSet.add(entry.getConnectorPair());
- }
-
Iterator<Map.Entry<Pair<TransportConfiguration, TransportConfiguration>, ConnectionManager>> iter = connectionManagerMap.entrySet()
.iterator();
while (iter.hasNext())
Modified: branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/cluster/DiscoveryGroup.java
===================================================================
--- branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/cluster/DiscoveryGroup.java 2009-08-06 08:44:47 UTC (rev 7669)
+++ branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/cluster/DiscoveryGroup.java 2009-08-06 08:56:53 UTC (rev 7670)
@@ -25,7 +25,9 @@
import java.util.Map;
+import org.jboss.messaging.core.config.TransportConfiguration;
import org.jboss.messaging.core.server.MessagingComponent;
+import org.jboss.messaging.utils.Pair;
/**
* A DiscoveryGroup
@@ -40,7 +42,7 @@
{
String getName();
- Map<String, DiscoveryEntry> getDiscoveryEntryMap();
+ Map<String, Pair<TransportConfiguration, TransportConfiguration>> getDiscoveryEntryMap();
boolean waitForBroadcast(long timeout);
Modified: branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/cluster/impl/DiscoveryGroupImpl.java
===================================================================
--- branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/cluster/impl/DiscoveryGroupImpl.java 2009-08-06 08:44:47 UTC (rev 7669)
+++ branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/cluster/impl/DiscoveryGroupImpl.java 2009-08-06 08:56:53 UTC (rev 7670)
@@ -157,9 +157,17 @@
return name;
}
- public synchronized Map<String, DiscoveryEntry> getDiscoveryEntryMap()
+ public synchronized Map<String, Pair<TransportConfiguration, TransportConfiguration>> getDiscoveryEntryMap()
{
- return new HashMap<String, DiscoveryEntry>(connectors);
+ Map<String, Pair<TransportConfiguration, TransportConfiguration>> conns =
+ new HashMap<String, Pair<TransportConfiguration, TransportConfiguration>>();
+
+ for (Map.Entry<String, DiscoveryEntry> entry: connectors.entrySet())
+ {
+ conns.put(entry.getKey(), entry.getValue().getConnectorPair());
+ }
+
+ return conns;
}
public boolean waitForBroadcast(final long timeout)
Modified: branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/management/impl/ManagementServiceImpl.java
===================================================================
--- branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/management/impl/ManagementServiceImpl.java 2009-08-06 08:44:47 UTC (rev 7669)
+++ branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/management/impl/ManagementServiceImpl.java 2009-08-06 08:56:53 UTC (rev 7670)
@@ -608,6 +608,8 @@
public void sendNotification(final Notification notification) throws Exception
{
+ log.info("sending notification " + this.messagingServerControl + " " + notificationsEnabled);
+
if (messagingServerControl != null && notificationsEnabled)
{
clusterQueueStateManager.sendNotification(notification, managementNotificationAddress);
Modified: branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/persistence/impl/journal/JournalStorageManager.java
===================================================================
--- branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/persistence/impl/journal/JournalStorageManager.java 2009-08-06 08:44:47 UTC (rev 7669)
+++ branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/persistence/impl/journal/JournalStorageManager.java 2009-08-06 08:56:53 UTC (rev 7670)
@@ -145,14 +145,10 @@
private final int perfBlastPages;
- private boolean backup;
-
public JournalStorageManager(final Configuration config, final Executor executor)
{
this.executor = executor;
- backup = config.isBackup();
-
if (config.getJournalType() != JournalType.NIO && config.getJournalType() != JournalType.ASYNCIO)
{
throw new IllegalArgumentException("Only NIO and AsyncIO are supported journals");
@@ -251,7 +247,7 @@
{
long id = idGenerator.generateID();
- // log.info(System.identityHashCode(this) + " generated " + id, new Exception());
+ //log.info(System.identityHashCode(this) + " generated " + id, new Exception());
return id;
}
Modified: branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/persistence/impl/nullpm/NullStorageManager.java
===================================================================
--- branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/persistence/impl/nullpm/NullStorageManager.java 2009-08-06 08:44:47 UTC (rev 7669)
+++ branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/persistence/impl/nullpm/NullStorageManager.java 2009-08-06 08:56:53 UTC (rev 7670)
@@ -61,12 +61,8 @@
private volatile boolean started;
- private boolean backup;
-
- public NullStorageManager(final boolean backup)
+ public NullStorageManager()
{
- this.backup = backup;
-
idSequence = new ReplicationAwareSharedCounter(0);
}
@@ -195,6 +191,8 @@
{
long id = idSequence.getAndIncrement();
+ //log.info(System.identityHashCode(this) + " generated " + id, new Exception());
+
return id;
}
Modified: branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/postoffice/impl/BindingsImpl.java
===================================================================
--- branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/postoffice/impl/BindingsImpl.java 2009-08-06 08:44:47 UTC (rev 7669)
+++ branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/postoffice/impl/BindingsImpl.java 2009-08-06 08:56:53 UTC (rev 7670)
@@ -142,7 +142,7 @@
while (buff.hasRemaining())
{
- int bindingID = buff.getInt();
+ long bindingID = buff.getLong();
Binding binding = bindingsMap.get(bindingID);
Modified: branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/postoffice/impl/ClusterQueueStateManagerImpl.java
===================================================================
--- branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/postoffice/impl/ClusterQueueStateManagerImpl.java 2009-08-06 08:44:47 UTC (rev 7669)
+++ branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/postoffice/impl/ClusterQueueStateManagerImpl.java 2009-08-06 08:56:53 UTC (rev 7670)
@@ -27,11 +27,10 @@
import java.util.List;
import java.util.Map;
import java.util.concurrent.ExecutorService;
-import java.util.concurrent.locks.Lock;
-import java.util.concurrent.locks.ReadWriteLock;
import org.jboss.messaging.core.buffers.ChannelBuffers;
import org.jboss.messaging.core.client.management.impl.ManagementHelper;
+import org.jboss.messaging.core.logging.Logger;
import org.jboss.messaging.core.management.Notification;
import org.jboss.messaging.core.management.NotificationType;
import org.jboss.messaging.core.persistence.StorageManager;
@@ -47,7 +46,6 @@
import org.jboss.messaging.core.server.replication.impl.ReplicationAwareMutex;
import org.jboss.messaging.core.settings.HierarchicalRepository;
import org.jboss.messaging.core.settings.impl.AddressSettings;
-import org.jboss.messaging.utils.ExecutorFactory;
import org.jboss.messaging.utils.SimpleString;
import org.jboss.messaging.utils.TypedProperties;
import org.jboss.messaging.utils.UUIDGenerator;
@@ -61,6 +59,8 @@
*/
public class ClusterQueueStateManagerImpl implements ClusterQueueStateManager
{
+ private static final Logger log = Logger.getLogger(ClusterQueueStateManagerImpl.class);
+
public static final SimpleString HDR_RESET_QUEUE_DATA = new SimpleString("_JBM_RESET_QUEUE_DATA");
private final Map<SimpleString, QueueInfo> queueInfos = new HashMap<SimpleString, QueueInfo>();
@@ -128,6 +128,8 @@
try
{
handleNotification(notification);
+
+ log.info("Server started " + server.isStarted());
// start sending notification *messages* only when the server if fully started
if (server != null && !server.isStarted())
Modified: branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/postoffice/impl/PostOfficeImpl.java
===================================================================
--- branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/postoffice/impl/PostOfficeImpl.java 2009-08-06 08:44:47 UTC (rev 7669)
+++ branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/postoffice/impl/PostOfficeImpl.java 2009-08-06 08:56:53 UTC (rev 7670)
@@ -258,7 +258,9 @@
String uid = UUIDGenerator.getInstance().generateStringUUID();
+ log.info("sending notification");
managementService.sendNotification(new Notification(uid, NotificationType.BINDING_ADDED, props));
+ log.info("sent notification");
}
public Binding removeBinding(final SimpleString uniqueName) throws Exception
Modified: branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/remoting/Channel.java
===================================================================
--- branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/remoting/Channel.java 2009-08-06 08:44:47 UTC (rev 7669)
+++ branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/remoting/Channel.java 2009-08-06 08:56:53 UTC (rev 7670)
@@ -14,7 +14,6 @@
import java.util.concurrent.locks.Lock;
import org.jboss.messaging.core.exception.MessagingException;
-import org.jboss.messaging.core.server.replication.Replicator;
/**
* A Channel A Channel *does not* support concurrent access by more than one thread!
@@ -31,8 +30,6 @@
Packet sendBlocking(Packet packet) throws MessagingException;
- //void replicatePacket(Packet packet, long replicatedChannelID, Runnable action);
-
void setHandler(ChannelHandler handler);
ChannelHandler getHandler();
@@ -55,8 +52,6 @@
RemotingConnection getConnection();
- //void executeOutstandingDelayedResults();
-
void confirm(Packet packet);
void setCommandConfirmationHandler(CommandConfirmationHandler handler);
@@ -65,16 +60,9 @@
void handlePacket(Packet packet);
- //void waitForAllReplicationResponse();
-
- //void replicationResponseReceived(Replicator replicator, int count);
-
Thread getExecutingThread();
- //void freeze();
-
void setFrozen(boolean frozen);
- void waitForAllExecutions();
-
+ void waitForAllExecutions();
}
Modified: branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/remoting/impl/PacketDecoder.java
===================================================================
--- branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/remoting/impl/PacketDecoder.java 2009-08-06 08:44:47 UTC (rev 7669)
+++ branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/remoting/impl/PacketDecoder.java 2009-08-06 08:56:53 UTC (rev 7670)
@@ -34,16 +34,13 @@
import static org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl.PING;
import static org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl.REATTACH_SESSION;
import static org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl.REATTACH_SESSION_RESP;
-import static org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl.REPLICATE_ACKNOWLEDGE;
-import static org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl.REPLICATE_ADD_REMOTE_CONSUMER;
-import static org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl.REPLICATE_ADD_REMOTE_QUEUE_BINDING;
+import static org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl.REPLICATE_BRIDGE_ACKNOWLEDGE;
import static org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl.REPLICATE_DEPAGE;
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 static org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl.REPLICATE_QUEUE_DELIVERY;
-import static org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl.REPLICATE_REDISTRIBUTION;
-import static org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl.REPLICATE_REMOVE_REMOTE_CONSUMER;
-import static org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl.REPLICATE_REMOVE_REMOTE_QUEUE_BINDING;
import static org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl.REPLICATE_STARTUP_INFO;
+import static org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl.REPLICATE_UPDATE_CONNECTORS;
import static org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl.REPLICATION_RESPONSE;
import static org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl.SESS_ACKNOWLEDGE;
import static org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl.SESS_BINDINGQUERY;
@@ -125,14 +122,10 @@
import org.jboss.messaging.core.remoting.impl.wireformat.SessionXASetTimeoutMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.SessionXASetTimeoutResponseMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.SessionXAStartMessage;
-import org.jboss.messaging.core.remoting.impl.wireformat.replication.ReplicateAcknowledgeMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.replication.ReplicateLockSequenceMessage;
-import org.jboss.messaging.core.remoting.impl.wireformat.replication.ReplicateRedistributionMessage;
-import org.jboss.messaging.core.remoting.impl.wireformat.replication.ReplicateRemoteBindingAddedMessage;
-import org.jboss.messaging.core.remoting.impl.wireformat.replication.ReplicateRemoteBindingRemovedMessage;
-import org.jboss.messaging.core.remoting.impl.wireformat.replication.ReplicateRemoteConsumerAddedMessage;
-import org.jboss.messaging.core.remoting.impl.wireformat.replication.ReplicateRemoteConsumerRemovedMessage;
+import org.jboss.messaging.core.remoting.impl.wireformat.replication.ReplicateNotificationMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.replication.ReplicateStartupInfoMessage;
+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.remoting.spi.MessagingBuffer;
@@ -146,11 +139,11 @@
public class PacketDecoder
{
private static final Logger log = Logger.getLogger(PacketDecoder.class);
-
+
public Packet decode(final MessagingBuffer in)
{
final byte packetType = in.readByte();
-
+
Packet packet;
switch (packetType)
@@ -395,56 +388,66 @@
packet = new SessionSendContinuationMessage();
break;
}
- case REPLICATE_ADD_REMOTE_QUEUE_BINDING:
+// case REPLICATE_REMOVE_REMOTE_QUEUE_BINDING:
+// {
+// packet = new ReplicateRemoteBindingRemovedMessage();
+// break;
+// }
+// case REPLICATE_ADD_REMOTE_CONSUMER:
+// {
+// packet = new ReplicateRemoteConsumerAddedMessage();
+// break;
+// }
+// case REPLICATE_REMOVE_REMOTE_CONSUMER:
+// {
+// packet = new ReplicateRemoteConsumerRemovedMessage();
+// break;
+// }
+ case REPLICATE_STARTUP_INFO:
{
- packet = new ReplicateRemoteBindingAddedMessage();
+ packet = new ReplicateStartupInfoMessage();
break;
}
- case REPLICATE_REMOVE_REMOTE_QUEUE_BINDING:
+// case REPLICATE_ACKNOWLEDGE:
+// {
+// packet = new ReplicateAcknowledgeMessage();
+// break;
+// }
+// case REPLICATE_REDISTRIBUTION:
+// {
+// packet = new ReplicateRedistributionMessage();
+// break;
+// }
+ case REPLICATE_LOCK_SEQUENCES:
{
- packet = new ReplicateRemoteBindingRemovedMessage();
+ packet = new ReplicateLockSequenceMessage();
break;
}
- case REPLICATE_ADD_REMOTE_CONSUMER:
+ case REPLICATE_QUEUE_DELIVERY:
{
- packet = new ReplicateRemoteConsumerAddedMessage();
+ packet = new PacketImpl(REPLICATE_QUEUE_DELIVERY);
break;
}
- case REPLICATE_REMOVE_REMOTE_CONSUMER:
+ case REPLICATE_DEPAGE:
{
- packet = new ReplicateRemoteConsumerRemovedMessage();
+ packet = new PacketImpl(REPLICATE_DEPAGE);
break;
}
- case REPLICATE_STARTUP_INFO:
+ case REPLICATE_UPDATE_CONNECTORS:
{
- packet = new ReplicateStartupInfoMessage();
+ packet = new ReplicateUpdateConnectorsMessage();
break;
}
- case REPLICATE_ACKNOWLEDGE:
+ case REPLICATE_NOTIFICATION:
{
- packet = new ReplicateAcknowledgeMessage();
+ packet = new ReplicateNotificationMessage();
break;
}
- case REPLICATE_REDISTRIBUTION:
+ case REPLICATE_BRIDGE_ACKNOWLEDGE:
{
- packet = new ReplicateRedistributionMessage();
+ packet = new PacketImpl(REPLICATE_BRIDGE_ACKNOWLEDGE);
break;
}
- case REPLICATE_LOCK_SEQUENCES:
- {
- packet = new ReplicateLockSequenceMessage();
- break;
- }
- case REPLICATE_QUEUE_DELIVERY:
- {
- packet = new PacketImpl(REPLICATE_QUEUE_DELIVERY);
- break;
- }
- case REPLICATE_DEPAGE:
- {
- packet = new PacketImpl(REPLICATE_DEPAGE);
- break;
- }
case BACKUP_CONNECTION:
{
packet = new PacketImpl(BACKUP_CONNECTION);
Modified: branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/remoting/impl/wireformat/PacketImpl.java
===================================================================
--- branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/remoting/impl/wireformat/PacketImpl.java 2009-08-06 08:44:47 UTC (rev 7669)
+++ branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/remoting/impl/wireformat/PacketImpl.java 2009-08-06 08:56:53 UTC (rev 7670)
@@ -144,29 +144,33 @@
//Replication
- public static final byte REPLICATE_ADD_REMOTE_QUEUE_BINDING = 91;
+ public static final byte REPLICATE_UPDATE_CONNECTORS = 91;
- public static final byte REPLICATE_REMOVE_REMOTE_QUEUE_BINDING = 92;
+ // public static final byte REPLICATE_ADD_REMOTE_QUEUE_BINDING = 92;
- public static final byte REPLICATE_ADD_REMOTE_CONSUMER = 93;
+ // public static final byte REPLICATE_REMOVE_REMOTE_QUEUE_BINDING = 93;
- public static final byte REPLICATE_REMOVE_REMOTE_CONSUMER = 94;
+ // public static final byte REPLICATE_ADD_REMOTE_CONSUMER = 94;
- public static final byte REPLICATE_ACKNOWLEDGE = 95;
+ // public static final byte REPLICATE_REMOVE_REMOTE_CONSUMER = 95;
- public static final byte REPLICATE_STARTUP_INFO = 96;
+ public static final byte REPLICATE_BRIDGE_ACKNOWLEDGE = 92;
- public static final byte REPLICATE_REDISTRIBUTION = 97;
+ public static final byte REPLICATE_STARTUP_INFO = 93;
- public static final byte REPLICATE_LOCK_SEQUENCES = 98;
+ // public static final byte REPLICATE_REDISTRIBUTION = 98;
- public static final byte REPLICATE_QUEUE_DELIVERY = 99;
+ public static final byte REPLICATE_LOCK_SEQUENCES = 94;
- public static final byte REPLICATE_DEPAGE = 100;
+ public static final byte REPLICATE_QUEUE_DELIVERY = 95;
- public static final byte BACKUP_CONNECTION = 101;
+ public static final byte REPLICATE_DEPAGE = 96;
+ public static final byte REPLICATE_NOTIFICATION = 97;
+ public static final byte BACKUP_CONNECTION = 98;
+
+
// Static --------------------------------------------------------
public PacketImpl(final byte type)
Deleted: branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/remoting/impl/wireformat/replication/ReplicateAcknowledgeMessage.java
===================================================================
--- branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/remoting/impl/wireformat/replication/ReplicateAcknowledgeMessage.java 2009-08-06 08:44:47 UTC (rev 7669)
+++ branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/remoting/impl/wireformat/replication/ReplicateAcknowledgeMessage.java 2009-08-06 08:56:53 UTC (rev 7670)
@@ -1,97 +0,0 @@
-/*
- * 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.remoting.impl.wireformat.PacketImpl;
-import org.jboss.messaging.core.remoting.spi.MessagingBuffer;
-import org.jboss.messaging.utils.DataConstants;
-import org.jboss.messaging.utils.SimpleString;
-
-/**
- *
- * A ReplicateAcknowledgeMessage
- *
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- *
- * Created 4 Mar 2009 18:36:30
- *
- *
- */
-public class ReplicateAcknowledgeMessage extends PacketImpl
-{
- // Constants -----------------------------------------------------
-
- // Attributes ----------------------------------------------------
-
- // TODO - use queue id not name for smaller packet size
- private SimpleString uniqueName;
-
- private long messageID;
-
- // Static --------------------------------------------------------
-
- // Constructors --------------------------------------------------
-
- public ReplicateAcknowledgeMessage(final SimpleString uniqueName, final long messageID)
- {
- super(REPLICATE_ACKNOWLEDGE);
-
- this.uniqueName = uniqueName;
-
- this.messageID = messageID;
- }
-
- // Public --------------------------------------------------------
-
- public ReplicateAcknowledgeMessage()
- {
- super(REPLICATE_ACKNOWLEDGE);
- }
-
- public int getRequiredBufferSize()
- {
- return BASIC_PACKET_SIZE + uniqueName.sizeof() + DataConstants.SIZE_LONG;
- }
-
- @Override
- public void encodeBody(final MessagingBuffer buffer)
- {
- buffer.writeSimpleString(uniqueName);
- buffer.writeLong(messageID);
- }
-
- @Override
- public void decodeBody(final MessagingBuffer buffer)
- {
- uniqueName = buffer.readSimpleString();
- messageID = buffer.readLong();
- }
-
- public SimpleString getUniqueName()
- {
- return uniqueName;
- }
-
- public long getMessageID()
- {
- return messageID;
- }
-
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
-}
Deleted: branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/remoting/impl/wireformat/replication/ReplicateRedistributionMessage.java
===================================================================
--- branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/remoting/impl/wireformat/replication/ReplicateRedistributionMessage.java 2009-08-06 08:44:47 UTC (rev 7669)
+++ branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/remoting/impl/wireformat/replication/ReplicateRedistributionMessage.java 2009-08-06 08:56:53 UTC (rev 7670)
@@ -1,93 +0,0 @@
-/*
- * 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.remoting.impl.wireformat.PacketImpl;
-import org.jboss.messaging.core.remoting.spi.MessagingBuffer;
-import org.jboss.messaging.utils.DataConstants;
-import org.jboss.messaging.utils.SimpleString;
-
-/**
- *
- * A ReplicateRedistributionMessage
- *
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- *
- *
- */
-public class ReplicateRedistributionMessage extends PacketImpl
-{
- // Constants -----------------------------------------------------
-
- // Attributes ----------------------------------------------------
-
- private SimpleString queueName;
-
- private long messageID;
-
- // Static --------------------------------------------------------
-
- // Constructors --------------------------------------------------
-
- public ReplicateRedistributionMessage(final SimpleString queueName, final long messageID)
- {
- super(REPLICATE_REDISTRIBUTION);
-
- this.queueName = queueName;
- this.messageID = messageID;
- }
-
- // Public --------------------------------------------------------
-
- public ReplicateRedistributionMessage()
- {
- super(REPLICATE_REDISTRIBUTION);
- }
-
- public int getRequiredBufferSize()
- {
- return BASIC_PACKET_SIZE + queueName.sizeof() + DataConstants.SIZE_LONG;
- }
-
- @Override
- public void encodeBody(final MessagingBuffer buffer)
- {
- buffer.writeSimpleString(queueName);
- buffer.writeLong(messageID);
- }
-
- @Override
- public void decodeBody(final MessagingBuffer buffer)
- {
- queueName = buffer.readSimpleString();
- messageID = buffer.readLong();
- }
-
- public SimpleString getQueueName()
- {
- return queueName;
- }
-
- public long getMessageID()
- {
- return messageID;
- }
-
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
-}
Deleted: branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/remoting/impl/wireformat/replication/ReplicateRemoteBindingAddedMessage.java
===================================================================
--- branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/remoting/impl/wireformat/replication/ReplicateRemoteBindingAddedMessage.java 2009-08-06 08:44:47 UTC (rev 7669)
+++ branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/remoting/impl/wireformat/replication/ReplicateRemoteBindingAddedMessage.java 2009-08-06 08:56:53 UTC (rev 7670)
@@ -1,170 +0,0 @@
-/*
- * 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.remoting.impl.wireformat.PacketImpl;
-import org.jboss.messaging.core.remoting.spi.MessagingBuffer;
-import org.jboss.messaging.utils.DataConstants;
-import org.jboss.messaging.utils.SimpleString;
-
-/**
- *
- * A ReplicateRemoteBindingAddedMessage
- *
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- *
- * Created 4 Mar 2009 18:36:30
- *
- *
- */
-public class ReplicateRemoteBindingAddedMessage extends PacketImpl
-{
- // Constants -----------------------------------------------------
-
- // Attributes ----------------------------------------------------
-
- private SimpleString clusterConnectionName;
-
- private SimpleString address;
-
- private SimpleString uniqueName;
-
- private SimpleString routingName;
-
- private int remoteQueueID;
-
- private SimpleString filterString;
-
- private SimpleString sfQueueName;
-
- private int distance;
-
- // Static --------------------------------------------------------
-
- // Constructors --------------------------------------------------
-
- public ReplicateRemoteBindingAddedMessage(final SimpleString clusterConnectionName,
- final SimpleString address,
- final SimpleString uniqueName,
- final SimpleString routingName,
- final int remoteQueueID,
- final SimpleString filterString,
- final SimpleString sfQueueName,
- final int distance)
- {
- super(REPLICATE_ADD_REMOTE_QUEUE_BINDING);
-
- this.clusterConnectionName = clusterConnectionName;
- this.address = address;
- this.uniqueName = uniqueName;
- this.routingName = routingName;
- this.remoteQueueID = remoteQueueID;
- this.filterString = filterString;
- this.sfQueueName = sfQueueName;
- this.distance = distance;
- }
-
- // Public --------------------------------------------------------
-
- public ReplicateRemoteBindingAddedMessage()
- {
- super(REPLICATE_ADD_REMOTE_QUEUE_BINDING);
- }
-
- public int getRequiredBufferSize()
- {
- return BASIC_PACKET_SIZE +
- clusterConnectionName.sizeof() + // buffer.writeSimpleString(clusterConnectionName);
- address.sizeof() + // buffer.writeSimpleString(address);
- uniqueName.sizeof() + // buffer.writeSimpleString(uniqueName);
- routingName.sizeof() + // buffer.writeSimpleString(routingName);
- DataConstants.SIZE_INT + // buffer.writeInt(remoteQueueID);
- SimpleString.sizeofNullableString(filterString) + // buffer.writeNullableSimpleString(filterString);
- sfQueueName.sizeof() + // buffer.writeSimpleString(sfQueueName);
- DataConstants.SIZE_INT; // buffer.writeInt(distance);
- }
-
- @Override
- public void encodeBody(final MessagingBuffer buffer)
- {
- buffer.writeSimpleString(clusterConnectionName);
- buffer.writeSimpleString(address);
- buffer.writeSimpleString(uniqueName);
- buffer.writeSimpleString(routingName);
- buffer.writeInt(remoteQueueID);
- buffer.writeNullableSimpleString(filterString);
- buffer.writeSimpleString(sfQueueName);
- buffer.writeInt(distance);
- }
-
- @Override
- public void decodeBody(final MessagingBuffer buffer)
- {
- clusterConnectionName = buffer.readSimpleString();
- address = buffer.readSimpleString();
- uniqueName = buffer.readSimpleString();
- routingName = buffer.readSimpleString();
- remoteQueueID = buffer.readInt();
- filterString = buffer.readNullableSimpleString();
- sfQueueName = buffer.readSimpleString();
- distance = buffer.readInt();
- }
-
- public SimpleString getClusterConnectionName()
- {
- return clusterConnectionName;
- }
-
- public SimpleString getAddress()
- {
- return address;
- }
-
- public SimpleString getUniqueName()
- {
- return uniqueName;
- }
-
- public SimpleString getRoutingName()
- {
- return routingName;
- }
-
- public int getRemoteQueueID()
- {
- return remoteQueueID;
- }
-
- public SimpleString getFilterString()
- {
- return filterString;
- }
-
- public SimpleString getSfQueueName()
- {
- return sfQueueName;
- }
-
- public int getDistance()
- {
- return distance;
- }
-
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
-}
Deleted: branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/remoting/impl/wireformat/replication/ReplicateRemoteBindingRemovedMessage.java
===================================================================
--- branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/remoting/impl/wireformat/replication/ReplicateRemoteBindingRemovedMessage.java 2009-08-06 08:44:47 UTC (rev 7669)
+++ branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/remoting/impl/wireformat/replication/ReplicateRemoteBindingRemovedMessage.java 2009-08-06 08:56:53 UTC (rev 7670)
@@ -1,84 +0,0 @@
-/*
- * 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.remoting.impl.wireformat.PacketImpl;
-import org.jboss.messaging.core.remoting.spi.MessagingBuffer;
-import org.jboss.messaging.utils.SimpleString;
-
-/**
- *
- * A ReplicateRemoteBindingRemovedMessage
- *
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- *
- * Created 4 Mar 2009 18:36:30
- *
- *
- */
-public class ReplicateRemoteBindingRemovedMessage extends PacketImpl
-{
- // Constants -----------------------------------------------------
-
- // Attributes ----------------------------------------------------
-
- private SimpleString uniqueName;
-
- // Static --------------------------------------------------------
-
- // Constructors --------------------------------------------------
-
- public ReplicateRemoteBindingRemovedMessage(final SimpleString uniqueName)
- {
- super(REPLICATE_REMOVE_REMOTE_QUEUE_BINDING);
-
- this.uniqueName = uniqueName;
- }
-
- // Public --------------------------------------------------------
-
- public ReplicateRemoteBindingRemovedMessage()
- {
- super(REPLICATE_REMOVE_REMOTE_QUEUE_BINDING);
- }
-
- public int getRequiredBufferSize()
- {
- return BASIC_PACKET_SIZE + uniqueName.sizeof();
- }
-
- @Override
- public void encodeBody(final MessagingBuffer buffer)
- {
- buffer.writeSimpleString(uniqueName);
- }
-
- @Override
- public void decodeBody(final MessagingBuffer buffer)
- {
- uniqueName = buffer.readSimpleString();
- }
-
- public SimpleString getUniqueName()
- {
- return uniqueName;
- }
-
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
-}
Deleted: branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/remoting/impl/wireformat/replication/ReplicateRemoteConsumerAddedMessage.java
===================================================================
--- branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/remoting/impl/wireformat/replication/ReplicateRemoteConsumerAddedMessage.java 2009-08-06 08:44:47 UTC (rev 7669)
+++ branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/remoting/impl/wireformat/replication/ReplicateRemoteConsumerAddedMessage.java 2009-08-06 08:56:53 UTC (rev 7670)
@@ -1,118 +0,0 @@
-/*
- * 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.remoting.impl.wireformat.PacketImpl;
-import org.jboss.messaging.core.remoting.spi.MessagingBuffer;
-import org.jboss.messaging.utils.SimpleString;
-import org.jboss.messaging.utils.TypedProperties;
-
-/**
- *
- * A ReplicateRemoteConsumerAddedMessage
- *
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- *
- * Created 4 Mar 2009 18:36:30
- *
- *
- */
-public class ReplicateRemoteConsumerAddedMessage extends PacketImpl
-{
- // Constants -----------------------------------------------------
-
- // Attributes ----------------------------------------------------
-
- private SimpleString uniqueBindingName;
-
- private SimpleString filterString;
-
- private TypedProperties properties;
-
- // Static --------------------------------------------------------
-
- // Constructors --------------------------------------------------
-
- public ReplicateRemoteConsumerAddedMessage(final SimpleString uniqueBindingName,
- final SimpleString filterString,
- final TypedProperties properties)
- {
- super(REPLICATE_ADD_REMOTE_CONSUMER);
-
- this.uniqueBindingName = uniqueBindingName;
-
- this.filterString = filterString;
-
- this.properties = properties;
- }
-
- // Public --------------------------------------------------------
-
- public ReplicateRemoteConsumerAddedMessage()
- {
- super(REPLICATE_ADD_REMOTE_CONSUMER);
- }
-
- public int getRequiredBufferSize()
- {
- return BASIC_PACKET_SIZE +
- uniqueBindingName.sizeof() + // buffer.writeSimpleString(uniqueBindingName);
- SimpleString.sizeofNullableString(filterString) + // buffer.writeNullableSimpleString(filterString);
- properties.getEncodeSize(); // properties.encode(buffer);
- }
-
- @Override
- public void encodeBody(final MessagingBuffer buffer)
- {
- buffer.writeSimpleString(uniqueBindingName);
-
- buffer.writeNullableSimpleString(filterString);
-
- properties.encode(buffer);
- }
-
- @Override
- public void decodeBody(final MessagingBuffer buffer)
- {
- uniqueBindingName = buffer.readSimpleString();
-
- filterString = buffer.readNullableSimpleString();
-
- properties = new TypedProperties();
-
- properties.decode(buffer);
- }
-
- public SimpleString getUniqueBindingName()
- {
- return uniqueBindingName;
- }
-
- public SimpleString getFilterString()
- {
- return filterString;
- }
-
- public TypedProperties getProperties()
- {
- return properties;
- }
-
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
-}
Deleted: branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/remoting/impl/wireformat/replication/ReplicateRemoteConsumerRemovedMessage.java
===================================================================
--- branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/remoting/impl/wireformat/replication/ReplicateRemoteConsumerRemovedMessage.java 2009-08-06 08:44:47 UTC (rev 7669)
+++ branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/remoting/impl/wireformat/replication/ReplicateRemoteConsumerRemovedMessage.java 2009-08-06 08:56:53 UTC (rev 7670)
@@ -1,114 +0,0 @@
-/*
- * 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.remoting.impl.wireformat.PacketImpl;
-import org.jboss.messaging.core.remoting.spi.MessagingBuffer;
-import org.jboss.messaging.utils.SimpleString;
-import org.jboss.messaging.utils.TypedProperties;
-
-/**
- *
- * A ReplicateRemoteConsumerRemovedMessage
- *
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- *
- * Created 4 Mar 2009 18:36:30
- *
- *
- */
-public class ReplicateRemoteConsumerRemovedMessage extends PacketImpl
-{
- // Constants -----------------------------------------------------
-
- // Attributes ----------------------------------------------------
-
- private SimpleString uniqueBindingName;
-
- private SimpleString filterString;
-
- private TypedProperties properties;
-
- // Static --------------------------------------------------------
-
- // Constructors --------------------------------------------------
-
- public ReplicateRemoteConsumerRemovedMessage(SimpleString uniqueBindingName, SimpleString filterString, final TypedProperties properties)
- {
- super(REPLICATE_REMOVE_REMOTE_CONSUMER);
-
- this.uniqueBindingName = uniqueBindingName;
-
- this.filterString = filterString;
-
- this.properties = properties;
- }
-
- // Public --------------------------------------------------------
-
- public ReplicateRemoteConsumerRemovedMessage()
- {
- super(REPLICATE_REMOVE_REMOTE_CONSUMER);
- }
-
- public int getRequiredBufferSize()
- {
- return BASIC_PACKET_SIZE +
- uniqueBindingName.sizeof() + // buffer.writeSimpleString(uniqueBindingName);
- SimpleString.sizeofNullableString(filterString) + // buffer.writeNullableSimpleString(filterString);
- properties.getEncodeSize(); // properties.encode(buffer);
- }
-
- public void encodeBody(final MessagingBuffer buffer)
- {
- buffer.writeSimpleString(uniqueBindingName);
-
- buffer.writeNullableSimpleString(filterString);
-
- properties.encode(buffer);
- }
-
- public void decodeBody(final MessagingBuffer buffer)
- {
- uniqueBindingName = buffer.readSimpleString();
-
- filterString = buffer.readNullableSimpleString();
-
- properties = new TypedProperties();
-
- properties.decode(buffer);
- }
-
- public SimpleString getUniqueBindingName()
- {
- return uniqueBindingName;
- }
-
- public SimpleString getFilterString()
- {
- return filterString;
- }
-
- public TypedProperties getProperties()
- {
- return properties;
- }
-
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
-}
Modified: branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/remoting/server/RemotingService.java
===================================================================
--- branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/remoting/server/RemotingService.java 2009-08-06 08:44:47 UTC (rev 7669)
+++ branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/remoting/server/RemotingService.java 2009-08-06 08:56:53 UTC (rev 7670)
@@ -49,6 +49,8 @@
RemotingConnection removeConnection(Object remotingConnectionID);
Set<RemotingConnection> getConnections();
+
+ Set<RemotingConnection> getBackupConnections();
void addInterceptor(Interceptor interceptor);
Modified: branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/remoting/server/impl/RemotingServiceImpl.java
===================================================================
--- branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/remoting/server/impl/RemotingServiceImpl.java 2009-08-06 08:44:47 UTC (rev 7669)
+++ branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/remoting/server/impl/RemotingServiceImpl.java 2009-08-06 08:56:53 UTC (rev 7670)
@@ -21,9 +21,7 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
-import java.util.concurrent.Callable;
import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
import java.util.concurrent.ScheduledExecutorService;
@@ -274,7 +272,22 @@
{
return new HashSet<RemotingConnection>(connections.values());
}
+
+ public synchronized Set<RemotingConnection> getBackupConnections()
+ {
+ Set<RemotingConnection> backupConnections = new HashSet<RemotingConnection>();
+ for (RemotingConnection connection : connections.values())
+ {
+ if (!connection.isActive())
+ {
+ backupConnections.add(connection);
+ }
+ }
+
+ return backupConnections;
+ }
+
public RemotingConnection getServerSideReplicatingConnection()
{
return serverSideReplicatingConnection;
Modified: branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/server/MessagingServer.java
===================================================================
--- branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/server/MessagingServer.java 2009-08-06 08:44:47 UTC (rev 7669)
+++ branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/server/MessagingServer.java 2009-08-06 08:56:53 UTC (rev 7670)
@@ -118,6 +118,8 @@
void returnNonPooledReplicatingConnection(RemotingConnection connection);
RemotingConnection getPooledReplicatingConnection() throws Exception;
+
+ void returnPooledReplicatingConnection(RemotingConnection connection);
void initialiseBackup(UUID nodeID, long currentMessageID) throws Exception;
Modified: branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/server/Queue.java
===================================================================
--- branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/server/Queue.java 2009-08-06 08:44:47 UTC (rev 7669)
+++ branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/server/Queue.java 2009-08-06 08:56:53 UTC (rev 7670)
@@ -82,7 +82,7 @@
void close();
- // void deliverAll();
+ void deliverAll();
HandleStatus deliverOne();
Modified: branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/server/cluster/Bridge.java
===================================================================
--- branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/server/cluster/Bridge.java 2009-08-06 08:44:47 UTC (rev 7669)
+++ branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/server/cluster/Bridge.java 2009-08-06 08:56:53 UTC (rev 7670)
@@ -53,4 +53,6 @@
void activate();
void setQueue(Queue queue);
+
+ void acknowledge();
}
Modified: branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/server/cluster/ClusterConnection.java
===================================================================
--- branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/server/cluster/ClusterConnection.java 2009-08-06 08:44:47 UTC (rev 7669)
+++ branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/server/cluster/ClusterConnection.java 2009-08-06 08:56:53 UTC (rev 7670)
@@ -22,7 +22,11 @@
package org.jboss.messaging.core.server.cluster;
+import java.util.Map;
+
+import org.jboss.messaging.core.config.TransportConfiguration;
import org.jboss.messaging.core.server.MessagingComponent;
+import org.jboss.messaging.utils.Pair;
import org.jboss.messaging.utils.SimpleString;
/**
@@ -37,14 +41,21 @@
public interface ClusterConnection extends MessagingComponent
{
SimpleString getName();
-
- void handleReplicatedAddBinding(SimpleString address,
- SimpleString uniqueName,
- SimpleString routingName,
- int queueID,
- SimpleString filterString,
- SimpleString queueName,
- int distance) throws Exception;
void activate();
+
+// void handleReplicatedAddBinding(SimpleString address,
+// SimpleString uniqueName,
+// SimpleString routingName,
+// long queueID,
+// SimpleString filterString,
+// int distance);
+//
+// void handleRemoveRemoteQueueBinding(SimpleString uniqueName);
+//
+// void handleAddRemoteConsumer(SimpleString uniqueName, SimpleString filterString, TypedProperties properties);
+//
+// void handleRemoveRemoteConsumer(SimpleString uniqueName, SimpleString filterString, TypedProperties properties);
+
+ void updateConnectors(Map<String, Pair<TransportConfiguration, TransportConfiguration>> connectors);
}
Modified: branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/server/cluster/impl/BridgeImpl.java
===================================================================
--- branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/server/cluster/impl/BridgeImpl.java 2009-08-06 08:44:47 UTC (rev 7669)
+++ branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/server/cluster/impl/BridgeImpl.java 2009-08-06 08:56:53 UTC (rev 7670)
@@ -22,6 +22,8 @@
package org.jboss.messaging.core.server.cluster.impl;
+import static org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl.REPLICATE_BRIDGE_ACKNOWLEDGE;
+
import java.nio.ByteBuffer;
import java.util.HashSet;
import java.util.LinkedList;
@@ -50,10 +52,13 @@
import org.jboss.messaging.core.persistence.StorageManager;
import org.jboss.messaging.core.postoffice.BindingType;
import org.jboss.messaging.core.remoting.Channel;
+import org.jboss.messaging.core.remoting.ChannelHandler;
import org.jboss.messaging.core.remoting.FailureListener;
import org.jboss.messaging.core.remoting.Packet;
import org.jboss.messaging.core.remoting.RemotingConnection;
-import org.jboss.messaging.core.remoting.impl.wireformat.replication.ReplicateAcknowledgeMessage;
+import org.jboss.messaging.core.remoting.impl.ChannelImpl;
+import org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl;
+import org.jboss.messaging.core.remoting.impl.wireformat.replication.ReplicateUpdateConnectorsMessage;
import org.jboss.messaging.core.server.HandleStatus;
import org.jboss.messaging.core.server.MessageReference;
import org.jboss.messaging.core.server.MessagingServer;
@@ -62,6 +67,11 @@
import org.jboss.messaging.core.server.cluster.Bridge;
import org.jboss.messaging.core.server.cluster.MessageFlowRecord;
import org.jboss.messaging.core.server.cluster.Transformer;
+import org.jboss.messaging.core.server.impl.BridgePacketHandler;
+import org.jboss.messaging.core.server.impl.ClusterConnectionPacketHandler;
+import org.jboss.messaging.core.server.replication.ReplicableAction;
+import org.jboss.messaging.core.server.replication.Replicator;
+import org.jboss.messaging.core.server.replication.impl.ReplicatorImpl;
import org.jboss.messaging.utils.Future;
import org.jboss.messaging.utils.Pair;
import org.jboss.messaging.utils.SimpleString;
@@ -121,7 +131,7 @@
private final double retryIntervalMultiplier;
private final int reconnectAttempts;
-
+
private final boolean failoverOnServerShutdown;
private final SimpleString idsHeaderName;
@@ -135,9 +145,13 @@
private final String clusterUser;
private final String clusterPassword;
+
+ private final MessagingServer server;
+
+ private Replicator replicator;
+
+ private boolean activated;
- private boolean activated;
-
// Static --------------------------------------------------------
// Constructors --------------------------------------------------
@@ -161,9 +175,10 @@
final SimpleString managementAddress,
final SimpleString managementNotificationAddress,
final String clusterUser,
- final String clusterPassword,
+ final String clusterPassword,
final boolean activated,
- final StorageManager storageManager) throws Exception
+ final StorageManager storageManager,
+ final MessagingServer server) throws Exception
{
this(nodeUUID,
name,
@@ -185,7 +200,8 @@
clusterPassword,
null,
activated,
- storageManager, null);
+ storageManager,
+ server);
}
public BridgeImpl(final UUID nodeUUID,
@@ -209,7 +225,7 @@
final MessageFlowRecord flowRecord,
final boolean activated,
final StorageManager storageManager,
- MessagingServer server) throws Exception
+ final MessagingServer server) throws Exception
{
this.nodeUUID = nodeUUID;
@@ -258,22 +274,65 @@
this.flowRecord = flowRecord;
- this.activated = activated;
+ this.activated = activated;
+
+ this.server = server;
}
+
+ private Replicator setupReplicator() throws Exception
+ {
+ long id = server.getStorageManager().generateUniqueID();
+ if (server.getConfiguration().isBackup())
+ {
+ Channel channel = new ChannelImpl(id, server.getExecutorFactory().getExecutor());
+
+ channel.setHandler(new BridgePacketHandler(this, channel));
+
+ server.getRemotingService().getChannelManager().putChannel(channel);
+ }
+
+ RemotingConnection replicatingConnection = server.getPooledReplicatingConnection();
+
+ if (replicatingConnection != null)
+ {
+ Channel replicatingChannel = new ChannelImpl(id, replicatingConnection);
+
+ replicatingConnection.putChannel(replicatingChannel);
+
+ final Replicator replicator = new ReplicatorImpl("cluster-connection-" + name, replicatingChannel);
+
+ replicatingChannel.setHandler(new ChannelHandler()
+ {
+ public void handlePacket(Packet packet)
+ {
+ replicator.replicationResponseReceived();
+ }
+ });
+
+ return replicator;
+ }
+ else
+ {
+ return null;
+ }
+ }
+
public synchronized void start() throws Exception
{
if (started)
{
return;
}
+
+ started = true;
- started = true;
+ this.replicator = setupReplicator();
if (activated)
{
executor.execute(new CreateObjectsRunnable());
- }
+ }
}
private void cancelRefs() throws Exception
@@ -305,10 +364,21 @@
csf.close();
}
}
+
+ //log.info("stopping bridge "+ name);
executor.execute(new StopRunnable());
-
- waitForRunnablesToComplete();
+
+ waitForRunnablesToComplete();
+
+ if (replicator != null)
+ {
+ server.returnPooledReplicatingConnection(replicator.getReplicatingChannel().getConnection());
+
+ replicator.getReplicatingChannel().close();
+ }
+
+ //log.info("stopped bridge "+ name);
}
public boolean isStarted()
@@ -332,7 +402,7 @@
{
return queue;
}
-
+
public void setQueue(final Queue queue)
{
this.queue = queue;
@@ -370,10 +440,8 @@
return ((ClientSessionImpl)session).getConnection();
}
}
-
- // SendAcknowledgementHandler implementation ---------------------
-
- public void sendAcknowledged(final Message message)
+
+ public void acknowledge()
{
try
{
@@ -381,7 +449,7 @@
if (ref != null)
{
- ref.getQueue().acknowledge(ref);
+ ref.getQueue().acknowledge(ref);
}
}
catch (Exception e)
@@ -390,15 +458,42 @@
}
}
+ // SendAcknowledgementHandler implementation ---------------------
+
+ public void sendAcknowledged(final Message message)
+ {
+ if (replicator == null)
+ {
+ acknowledge();
+ }
+ else
+ {
+ ReplicableAction action = new ReplicableAction()
+ {
+ public void run()
+ {
+ acknowledge();
+ }
+
+ public Packet getPacket()
+ {
+ return new PacketImpl(REPLICATE_BRIDGE_ACKNOWLEDGE);
+ }
+ };
+
+ replicator.execute(action, null);
+ }
+ }
+
// Consumer implementation ---------------------------------------
public HandleStatus handle(final MessageReference ref) throws Exception
- {
+ {
if (filter != null && !filter.match(ref.getMessage()))
{
return HandleStatus.NO_MATCH;
}
-
+
if (!active)
{
return HandleStatus.BUSY;
@@ -477,7 +572,7 @@
// Preserve the original address
dest = message.getDestination();
}
-
+
producer.send(dest, message);
return HandleStatus.HANDLED;
@@ -528,28 +623,21 @@
{
return false;
}
-
+
try
{
queue.addConsumer(BridgeImpl.this);
-
- csf = new ClientSessionFactoryImpl(connectorPair.a,
- connectorPair.b);
-
+
+ csf = new ClientSessionFactoryImpl(connectorPair.a, connectorPair.b);
+
csf.setFailoverOnServerShutdown(failoverOnServerShutdown);
csf.setRetryInterval(retryInterval);
csf.setRetryIntervalMultiplier(retryIntervalMultiplier);
csf.setReconnectAttempts(reconnectAttempts);
- //Session is pre-acknowledge
- session = (ClientSessionInternal)csf.createSession(clusterUser,
- clusterPassword,
- false,
- true,
- true,
- true,
- 1);
-
+ // Session is pre-acknowledge
+ session = (ClientSessionInternal)csf.createSession(clusterUser, clusterPassword, false, true, true, true, 1);
+
if (session == null)
{
// This can happen if the bridge is shutdown
@@ -574,7 +662,7 @@
// Otherwise it may already exist if server is restarted before it has been deleted on backup
String qName = "notif." + nodeUUID.toString() + "." + name.toString();
-
+
SimpleString notifQueueName = new SimpleString(qName);
SimpleString filter = new SimpleString(ManagementHelper.HDR_BINDING_TYPE + "<>" +
@@ -599,10 +687,10 @@
flowRecord.getAddress() +
"%')");
- //The queue can't be temporary, since if the node with the bridge crashes then is restarted quickly
- //it might get deleted on the target when it does connection cleanup
-
- //When the backup activates the queue might already exist, so we catch this and ignore
+ // The queue can't be temporary, since if the node with the bridge crashes then is restarted quickly
+ // it might get deleted on the target when it does connection cleanup
+
+ // When the backup activates the queue might already exist, so we catch this and ignore
try
{
session.createQueue(managementNotificationAddress, notifQueueName, filter, false);
@@ -611,7 +699,7 @@
{
if (me.getCode() == MessagingException.QUEUE_EXISTS)
{
- //Ok
+ // Ok
}
else
{
@@ -641,7 +729,7 @@
active = true;
queue.deliverAsync();
-
+
return true;
}
catch (Exception e)
@@ -668,8 +756,8 @@
}
if (session != null)
- {
- session.close();
+ {
+ session.close();
}
started = false;
@@ -704,7 +792,7 @@
{
try
{
- // flowRecord.reset();
+ // flowRecord.reset();
}
catch (Exception e)
{
Modified: branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/server/cluster/impl/ClusterConnectionImpl.java
===================================================================
--- branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/server/cluster/impl/ClusterConnectionImpl.java 2009-08-06 08:44:47 UTC (rev 7669)
+++ branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/server/cluster/impl/ClusterConnectionImpl.java 2009-08-06 08:56:53 UTC (rev 7670)
@@ -35,7 +35,6 @@
import org.jboss.messaging.core.client.ClientMessage;
import org.jboss.messaging.core.client.management.impl.ManagementHelper;
-import org.jboss.messaging.core.cluster.DiscoveryEntry;
import org.jboss.messaging.core.cluster.DiscoveryGroup;
import org.jboss.messaging.core.cluster.DiscoveryListener;
import org.jboss.messaging.core.config.TransportConfiguration;
@@ -46,16 +45,28 @@
import org.jboss.messaging.core.postoffice.Binding;
import org.jboss.messaging.core.postoffice.Bindings;
import org.jboss.messaging.core.postoffice.PostOffice;
-import org.jboss.messaging.core.postoffice.impl.ClusterQueueStateManagerImpl;
+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.RemotingConnection;
+import org.jboss.messaging.core.remoting.impl.ChannelImpl;
+import org.jboss.messaging.core.remoting.impl.wireformat.replication.ReplicateNotificationMessage;
+import org.jboss.messaging.core.remoting.impl.wireformat.replication.ReplicateUpdateConnectorsMessage;
import org.jboss.messaging.core.server.MessagingServer;
import org.jboss.messaging.core.server.Queue;
import org.jboss.messaging.core.server.cluster.Bridge;
import org.jboss.messaging.core.server.cluster.ClusterConnection;
import org.jboss.messaging.core.server.cluster.MessageFlowRecord;
import org.jboss.messaging.core.server.cluster.RemoteQueueBinding;
+import org.jboss.messaging.core.server.impl.ClusterConnectionPacketHandler;
+import org.jboss.messaging.core.server.impl.MessageFlowRecordPacketHandler;
+import org.jboss.messaging.core.server.replication.ReplicableAction;
+import org.jboss.messaging.core.server.replication.Replicator;
+import org.jboss.messaging.core.server.replication.impl.ReplicatorImpl;
import org.jboss.messaging.utils.ExecutorFactory;
import org.jboss.messaging.utils.Pair;
import org.jboss.messaging.utils.SimpleString;
+import org.jboss.messaging.utils.TypedProperties;
import org.jboss.messaging.utils.UUID;
/**
@@ -102,12 +113,12 @@
private final List<Pair<TransportConfiguration, TransportConfiguration>> staticConnectors;
+ private Replicator replicator;
+
private boolean backup;
private volatile boolean started;
-
- // private int replicationCount;
-
+
/*
* Constructor using static list of connectors
*/
@@ -123,7 +134,7 @@
final ScheduledExecutorService scheduledExecutor,
final List<Pair<TransportConfiguration, TransportConfiguration>> connectors,
final int maxHops,
- final UUID nodeUUID,
+ final UUID nodeUUID,
final boolean backup) throws Exception
{
this.name = name;
@@ -161,10 +172,7 @@
this.staticConnectors = connectors;
- if (!backup)
- {
- this.updateFromStaticConnectors(connectors);
- }
+ this.replicator = setupReplicator();
}
/*
@@ -182,7 +190,7 @@
final ScheduledExecutorService scheduledExecutor,
final DiscoveryGroup discoveryGroup,
final int maxHops,
- final UUID nodeUUID,
+ final UUID nodeUUID,
final boolean backup) throws Exception
{
this.name = name;
@@ -214,8 +222,49 @@
this.backup = backup;
this.staticConnectors = null;
+
+ this.replicator = setupReplicator();
}
+ private Replicator setupReplicator() throws Exception
+ {
+ long id = server.getStorageManager().generateUniqueID();
+
+ if (backup)
+ {
+ Channel channel = new ChannelImpl(id, executorFactory.getExecutor());
+
+ channel.setHandler(new ClusterConnectionPacketHandler(this, channel));
+
+ server.getRemotingService().getChannelManager().putChannel(channel);
+ }
+
+ RemotingConnection replicatingConnection = server.getPooledReplicatingConnection();
+
+ if (replicatingConnection != null)
+ {
+ Channel replicatingChannel = new ChannelImpl(id, replicatingConnection);
+
+ replicatingConnection.putChannel(replicatingChannel);
+
+ final Replicator replicator = new ReplicatorImpl("cluster-connection-" + name, replicatingChannel);
+
+ replicatingChannel.setHandler(new ChannelHandler()
+ {
+ public void handlePacket(Packet packet)
+ {
+ replicator.replicationResponseReceived();
+ }
+ });
+
+ return replicator;
+ }
+ else
+ {
+ return null;
+ }
+ }
+
public synchronized void start() throws Exception
{
if (started)
@@ -223,10 +272,16 @@
return;
}
+ this.replicator = setupReplicator();
+
if (discoveryGroup != null)
{
discoveryGroup.registerListener(this);
}
+ else
+ {
+ updateFromStaticConnectors(staticConnectors);
+ }
started = true;
}
@@ -243,6 +298,13 @@
discoveryGroup.unregisterListener(this);
}
+ if (replicator != null)
+ {
+ server.returnPooledReplicatingConnection(replicator.getReplicatingChannel().getConnection());
+
+ replicator.getReplicatingChannel().close();
+ }
+
for (MessageFlowRecord record : records.values())
{
try
@@ -280,17 +342,6 @@
{
connectorsChanged();
}
- else
- {
- try
- {
- updateFromStaticConnectors(staticConnectors);
- }
- catch (Exception e)
- {
- log.error("Failed to update connectors", e);
- }
- }
}
// DiscoveryListener implementation ------------------------------------------------------------------
@@ -304,7 +355,7 @@
try
{
- Map<String, DiscoveryEntry> connectors = discoveryGroup.getDiscoveryEntryMap();
+ Map<String, Pair<TransportConfiguration, TransportConfiguration>> connectors = discoveryGroup.getDiscoveryEntryMap();
updateConnectors(connectors);
}
@@ -316,106 +367,137 @@
private void updateFromStaticConnectors(final List<Pair<TransportConfiguration, TransportConfiguration>> connectors) throws Exception
{
- Map<String, DiscoveryEntry> map = new HashMap<String, DiscoveryEntry>();
+ Map<String, Pair<TransportConfiguration, TransportConfiguration>> map = new HashMap<String, Pair<TransportConfiguration, TransportConfiguration>>();
// TODO - we fudge the node id - it's never updated anyway
int i = 0;
for (Pair<TransportConfiguration, TransportConfiguration> connectorPair : connectors)
{
- map.put(String.valueOf(i++), new DiscoveryEntry(connectorPair, 0));
+ map.put(String.valueOf(i++), connectorPair);
}
- updateConnectors(map);
+ doUpdateConnectors(map);
}
- private void updateConnectors(final Map<String, DiscoveryEntry> connectors) throws Exception
+ public void updateConnectors(final Map<String, Pair<TransportConfiguration, TransportConfiguration>> connectors)
{
- Iterator<Map.Entry<String, MessageFlowRecord>> iter = records.entrySet().iterator();
-
- while (iter.hasNext())
+ if (replicator == null)
{
- Map.Entry<String, MessageFlowRecord> entry = iter.next();
-
- if (!connectors.containsKey(entry.getKey()))
+ doUpdateConnectors(connectors);
+ }
+ else
+ {
+ ReplicableAction action = new ReplicableAction()
{
- // Connector no longer there - we should remove and close it - we don't delete the queue though - it may
- // have messages - this is up to the administrator to do this
+ public void run()
+ {
+ doUpdateConnectors(connectors);
+ }
- entry.getValue().close();
+ public Packet getPacket()
+ {
+ return new ReplicateUpdateConnectorsMessage(connectors);
+ }
+ };
- iter.remove();
- }
+ replicator.execute(action, null);
}
+ }
- for (final Map.Entry<String, DiscoveryEntry> entry : connectors.entrySet())
+ private void doUpdateConnectors(final Map<String, Pair<TransportConfiguration, TransportConfiguration>> connectors)
+ {
+ try
{
- if (!records.containsKey(entry.getKey()))
+ Iterator<Map.Entry<String, MessageFlowRecord>> iter = records.entrySet().iterator();
+
+ while (iter.hasNext())
{
- Pair<TransportConfiguration, TransportConfiguration> connectorPair = entry.getValue().getConnectorPair();
+ Map.Entry<String, MessageFlowRecord> entry = iter.next();
- final SimpleString queueName = new SimpleString("sf." + name + "." + entry.getKey());
+ if (!connectors.containsKey(entry.getKey()))
+ {
+ // Connector no longer there - we should remove and close it - we don't delete the queue though - it may
+ // have messages - this is up to the administrator to do this
- Binding queueBinding = postOffice.getBinding(queueName);
+ entry.getValue().close();
- Queue queue;
+ iter.remove();
+ }
+ }
- if (queueBinding != null)
+ for (final Map.Entry<String, Pair<TransportConfiguration, TransportConfiguration>> entry : connectors.entrySet())
+ {
+ if (!records.containsKey(entry.getKey()))
{
- queue = (Queue)queueBinding.getBindable();
+ Pair<TransportConfiguration, TransportConfiguration> connectorPair = entry.getValue();
- createNewRecord(entry.getKey(), connectorPair, queueName, queue, true);
+ createMessageFlowRecord(connectorPair, entry.getKey());
}
- else
- {
- // Add binding in storage so the queue will get reloaded on startup and we can find it - it's never
- // actually routed to at that address though
-
- queue = server.createQueue(queueName, queueName, null, true, false);
-
- createNewRecord(entry.getKey(), connectorPair, queueName, queue, true);
- }
}
}
+ catch (Exception e)
+ {
+ log.error("Failed to update connectors", e);
+ }
}
- private void createNewRecord(final String nodeID,
- final Pair<TransportConfiguration, TransportConfiguration> connectorPair,
- final SimpleString queueName,
- final Queue queue,
- final boolean start) throws Exception
+ private void createMessageFlowRecord(final Pair<TransportConfiguration, TransportConfiguration> connectorPair,
+ final String nodeID)
{
- MessageFlowRecordImpl record = new MessageFlowRecordImpl(queue);
+ try
+ {
+ final SimpleString queueName = new SimpleString("sf." + name + "." + nodeID);
- Bridge bridge = new BridgeImpl(nodeUUID,
- queueName,
- queue,
- connectorPair,
- executorFactory.getExecutor(),
- null,
- null,
- scheduledExecutor,
- null,
- retryInterval,
- 1d,
- -1,
- false,
- useDuplicateDetection,
- managementService.getManagementAddress(),
- managementService.getManagementNotificationAddress(),
- managementService.getClusterUser(),
- managementService.getClusterPassword(),
- record,
- !backup,
- server.getStorageManager(),
- server);
+ Binding queueBinding = postOffice.getBinding(queueName);
- record.setBridge(bridge);
+ Queue queue;
- records.put(nodeID, record);
+ if (queueBinding != null)
+ {
+ queue = (Queue)queueBinding.getBindable();
+ }
+ else
+ {
+ // Add binding in storage so the queue will get reloaded on startup and we can find it - it's never
+ // actually routed to at that address though
- if (start)
+ queue = server.createQueue(queueName, queueName, null, true, false);
+ }
+
+ MessageFlowRecordImpl record = new MessageFlowRecordImpl(queue);
+
+ Bridge bridge = new BridgeImpl(nodeUUID,
+ queueName,
+ queue,
+ connectorPair,
+ executorFactory.getExecutor(),
+ null,
+ null,
+ scheduledExecutor,
+ null,
+ retryInterval,
+ 1d,
+ -1,
+ false,
+ useDuplicateDetection,
+ managementService.getManagementAddress(),
+ managementService.getManagementNotificationAddress(),
+ managementService.getClusterUser(),
+ managementService.getClusterPassword(),
+ record,
+ !backup,
+ server.getStorageManager(),
+ server);
+
+ record.setBridge(bridge);
+
+ records.put(nodeID, record);
+
+ bridge.start();
+ }
+ catch (Exception e)
{
- bridge.start();
+ log.error("Failed to create message flow record", e);
}
}
@@ -431,11 +513,58 @@
private volatile boolean firstReset = false;
- public MessageFlowRecordImpl(final Queue queue)
+ private final Replicator replicator;
+
+ public MessageFlowRecordImpl(final Queue queue) throws Exception
{
+ log.info("Creating message flow record on backup " + backup);
+
this.queue = queue;
+
+ this.replicator = setupReplicator();
}
+ private Replicator setupReplicator() throws Exception
+ {
+ long id = server.getStorageManager().generateUniqueID();
+
+ log.info("message flow record given id " + id);
+
+ if (backup)
+ {
+ Channel channel = new ChannelImpl(id, executorFactory.getExecutor());
+
+ channel.setHandler(new MessageFlowRecordPacketHandler(this, channel));
+
+ server.getRemotingService().getChannelManager().putChannel(channel);
+ }
+
+ RemotingConnection replicatingConnection = server.getPooledReplicatingConnection();
+
+ if (replicatingConnection != null)
+ {
+ Channel replicatingChannel = new ChannelImpl(id, replicatingConnection);
+
+ replicatingConnection.putChannel(replicatingChannel);
+
+ final Replicator replicator = new ReplicatorImpl("messageflow-", replicatingChannel);
+
+ replicatingChannel.setHandler(new ChannelHandler()
+ {
+ public void handlePacket(Packet packet)
+ {
+ replicator.replicationResponseReceived();
+ }
+ });
+
+ return replicator;
+ }
+ else
+ {
+ return null;
+ }
+ }
+
public String getAddress()
{
return address.toString();
@@ -451,51 +580,14 @@
bridge.stop();
clearBindings();
-
- // waitForReplicationsToComplete(3000);
+
+ if (replicator != null)
+ {
+ server.returnPooledReplicatingConnection(replicator.getReplicatingChannel().getConnection());
+
+ replicator.getReplicatingChannel().close();
+ }
}
-
-// private synchronized void waitForReplicationsToComplete(long timeout)
-// {
-// long toWait = timeout;
-//
-// long start = System.currentTimeMillis();
-//
-// while (replicationCount > 0 && toWait > 0)
-// {
-// try
-// {
-// wait(toWait);
-// }
-// catch (InterruptedException e)
-// {
-// }
-//
-// long now = System.currentTimeMillis();
-//
-// toWait -= now - start;
-//
-// start = now;
-// }
-//
-// if (toWait <= 0)
-// {
-// log.warn("Timed out waiting for replication responses to return");
-// }
-//
-// }
-//
-// private synchronized void replicationComplete()
-// {
-// replicationCount--;
-//
-// notify();
-// }
-//
-// private synchronized void beforeReplicate()
-// {
-// replicationCount++;
-// }
public void activate(final Queue queue) throws Exception
{
@@ -511,14 +603,32 @@
this.bridge = bridge;
}
- // public synchronized void reset() throws Exception
- // {
- // clearBindings();
- //
- // firstReset = false;
- // }
+ public void onMessage(final ClientMessage message)
+ {
+ if (replicator == null)
+ {
+ doOnMessage(message);
+ }
+ else
+ {
+ ReplicableAction action = new ReplicableAction()
+ {
+ public void run()
+ {
+ doOnMessage(message);
+ }
- public synchronized void onMessage(final ClientMessage message)
+ public Packet getPacket()
+ {
+ return new ReplicateNotificationMessage(message);
+ }
+ };
+
+ replicator.execute(action, null);
+ }
+ }
+
+ private synchronized void doOnMessage(final ClientMessage message)
{
try
{
@@ -585,14 +695,14 @@
}
private synchronized void clearBindings() throws Exception
- {
+ {
for (RemoteQueueBinding binding : new HashSet<RemoteQueueBinding>(bindings.values()))
{
removeBinding(binding.getClusterName());
- }
+ }
}
- private synchronized void doBindingAdded(final ClientMessage message) throws Exception
+ private void doBindingAdded(final ClientMessage message) throws Exception
{
Integer distance = (Integer)message.getProperty(ManagementHelper.HDR_DISTANCE);
@@ -624,21 +734,22 @@
SimpleString filterString = (SimpleString)message.getProperty(ManagementHelper.HDR_FILTERSTRING);
- Integer queueID = (Integer)message.getProperty(ManagementHelper.HDR_BINDING_ID);
+ Long queueID = (Long)message.getProperty(ManagementHelper.HDR_BINDING_ID);
if (queueID == null)
{
throw new IllegalStateException("queueID is null");
}
- RemoteQueueBinding binding = new RemoteQueueBindingImpl(server.getStorageManager().generateUniqueID(), queueAddress,
- clusterName,
- routingName,
- queueID,
- filterString,
- queue,
- bridge.getName(),
- distance + 1);
+ RemoteQueueBinding binding = new RemoteQueueBindingImpl(server.getStorageManager().generateUniqueID(),
+ queueAddress,
+ clusterName,
+ routingName,
+ queueID,
+ filterString,
+ queue,
+ bridge.getName(),
+ distance + 1);
bindings.put(clusterName, binding);
@@ -666,7 +777,7 @@
Bindings theBindings = postOffice.getBindingsForAddress(queueAddress);
theBindings.setRouteWhenNoConsumers(routeWhenNoConsumers);
-
+
}
private void doBindingRemoved(final ClientMessage message) throws Exception
@@ -680,8 +791,8 @@
removeBinding(clusterName);
}
-
- private synchronized void removeBinding(final SimpleString clusterName) throws Exception
+
+ private void removeBinding(final SimpleString clusterName) throws Exception
{
RemoteQueueBinding binding = bindings.remove(clusterName);
@@ -690,10 +801,10 @@
throw new IllegalStateException("Cannot find binding for queue " + clusterName);
}
- postOffice.removeBinding(binding.getUniqueName());
+ postOffice.removeBinding(binding.getUniqueName());
}
- private synchronized void doConsumerCreated(final ClientMessage message) throws Exception
+ private void doConsumerCreated(final ClientMessage message) throws Exception
{
Integer distance = (Integer)message.getProperty(ManagementHelper.HDR_DISTANCE);
@@ -725,10 +836,10 @@
// Need to propagate the consumer add
Notification notification = new Notification(null, CONSUMER_CREATED, message.getProperties());
- managementService.sendNotification(notification);
+ managementService.sendNotification(notification);
}
- private synchronized void doConsumerClosed(final ClientMessage message) throws Exception
+ private void doConsumerClosed(final ClientMessage message) throws Exception
{
Integer distance = (Integer)message.getProperty(ManagementHelper.HDR_DISTANCE);
@@ -760,7 +871,7 @@
// Need to propagate the consumer close
Notification notification = new Notification(null, CONSUMER_CLOSED, message.getProperties());
- managementService.sendNotification(notification);
+ managementService.sendNotification(notification);
}
}
@@ -768,43 +879,133 @@
public void handleReplicatedAddBinding(final SimpleString address,
final SimpleString uniqueName,
final SimpleString routingName,
- final int queueID,
+ final long queueID,
final SimpleString filterString,
- final SimpleString queueName,
- final int distance) throws Exception
+ final int distance)
{
- Binding queueBinding = postOffice.getBinding(queueName);
+ Binding queueBinding = postOffice.getBindingByID(queueID);
if (queueBinding == null)
{
- throw new IllegalStateException("Cannot find s & f queue " + queueName);
+ throw new IllegalStateException("Cannot find s & f queue " + queueID);
}
Queue queue = (Queue)queueBinding.getBindable();
- RemoteQueueBinding binding = new RemoteQueueBindingImpl(server.getStorageManager().generateUniqueID(), address,
- uniqueName,
- routingName,
- queueID,
- filterString,
- queue,
- queueName,
- distance);
+ try
+ {
+ RemoteQueueBinding binding = new RemoteQueueBindingImpl(server.getStorageManager().generateUniqueID(),
+ address,
+ uniqueName,
+ routingName,
+ queueID,
+ filterString,
+ queue,
+ queue.getName(),
+ distance);
- if (postOffice.getBinding(uniqueName) != null)
+ if (postOffice.getBinding(uniqueName) != null)
+ {
+ log.warn("Remoting queue binding " + uniqueName +
+ " has already been bound in the post office. Most likely cause for this is you have a loop " +
+ "in your cluster due to cluster max-hops being too large or you have multiple cluster connections to the same nodes using overlapping addresses");
+
+ return;
+ }
+
+ postOffice.addBinding(binding);
+
+ Bindings theBindings = postOffice.getBindingsForAddress(address);
+
+ theBindings.setRouteWhenNoConsumers(routeWhenNoConsumers);
+ }
+ catch (Exception e)
{
- log.warn("Remoting queue binding " + uniqueName +
- " has already been bound in the post office. Most likely cause for this is you have a loop " +
- "in your cluster due to cluster max-hops being too large or you have multiple cluster connections to the same nodes using overlapping addresses");
+ log.error("Failed to add remote binding", e);
+ }
+ }
- return;
+ public void handleRemoveRemoteQueueBinding(final SimpleString uniqueName)
+ {
+ try
+ {
+ Binding binding = server.getPostOffice().removeBinding(uniqueName);
+
+ if (binding == null)
+ {
+ throw new IllegalStateException("Cannot find binding to remove " + uniqueName);
+ }
}
+ catch (Exception e)
+ {
+ log.error("Failed to handle remove remote queue binding", e);
+ }
+ }
- postOffice.addBinding(binding);
+ public void handleAddRemoteConsumer(final SimpleString uniqueName,
+ final SimpleString filterString,
+ final TypedProperties properties)
+ {
+ RemoteQueueBinding binding = (RemoteQueueBinding)server.getPostOffice().getBinding(uniqueName);
- Bindings theBindings = postOffice.getBindingsForAddress(address);
+ if (binding == null)
+ {
+ throw new IllegalStateException("Cannot find binding " + uniqueName);
+ }
- theBindings.setRouteWhenNoConsumers(routeWhenNoConsumers);
+ try
+ {
+ binding.addConsumer(filterString);
+ }
+ catch (Exception e)
+ {
+ log.error("Failed to handle add remote consumer", e);
+ }
+
+ // Need to propagate the consumer add
+ Notification notification = new Notification(null, CONSUMER_CREATED, properties);
+
+ try
+ {
+ server.getManagementService().sendNotification(notification);
+ }
+ catch (Exception e)
+ {
+ log.error("Failed to handle add remote consumer", e);
+ }
}
+ public void handleRemoveRemoteConsumer(final SimpleString uniqueName,
+ final SimpleString filterString,
+ final TypedProperties properties)
+ {
+ RemoteQueueBinding binding = (RemoteQueueBinding)server.getPostOffice().getBinding(uniqueName);
+
+ if (binding == null)
+ {
+ throw new IllegalStateException("Cannot find binding " + uniqueName);
+ }
+
+ try
+ {
+ binding.removeConsumer(filterString);
+ }
+ catch (Exception e)
+ {
+ log.error("Failed to handle remove remote consumer", e);
+ }
+
+ // Need to propagate the consumer close
+ Notification notification = new Notification(null, CONSUMER_CLOSED, properties);
+
+ try
+ {
+ server.getManagementService().sendNotification(notification);
+ }
+ catch (Exception e)
+ {
+ log.error("Failed to handle remove remote consumer", e);
+ }
+ }
+
}
Modified: branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/server/cluster/impl/ClusterManagerImpl.java
===================================================================
--- branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/server/cluster/impl/ClusterManagerImpl.java 2009-08-06 08:44:47 UTC (rev 7669)
+++ branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/server/cluster/impl/ClusterManagerImpl.java 2009-08-06 08:56:53 UTC (rev 7670)
@@ -438,7 +438,8 @@
managementService.getClusterUser(),
managementService.getClusterPassword(),
!backup,
- server.getStorageManager());
+ server.getStorageManager(),
+ server);
bridges.put(config.getName(), bridge);
Modified: branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/server/cluster/impl/Redistributor.java
===================================================================
--- branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/server/cluster/impl/Redistributor.java 2009-08-06 08:44:47 UTC (rev 7669)
+++ branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/server/cluster/impl/Redistributor.java 2009-08-06 08:56:53 UTC (rev 7670)
@@ -28,7 +28,6 @@
import org.jboss.messaging.core.logging.Logger;
import org.jboss.messaging.core.persistence.StorageManager;
import org.jboss.messaging.core.postoffice.PostOffice;
-import org.jboss.messaging.core.remoting.Channel;
import org.jboss.messaging.core.server.Consumer;
import org.jboss.messaging.core.server.HandleStatus;
import org.jboss.messaging.core.server.MessageReference;
Modified: branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/server/cluster/impl/RemoteQueueBindingImpl.java
===================================================================
--- branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/server/cluster/impl/RemoteQueueBindingImpl.java 2009-08-06 08:44:47 UTC (rev 7669)
+++ branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/server/cluster/impl/RemoteQueueBindingImpl.java 2009-08-06 08:56:53 UTC (rev 7670)
@@ -60,7 +60,7 @@
private final SimpleString routingName;
- private final int remoteQueueID;
+ private final long remoteQueueID;
private final Filter queueFilter;
@@ -80,7 +80,7 @@
final SimpleString address,
final SimpleString uniqueName,
final SimpleString routingName,
- final int remoteQueueID,
+ final long remoteQueueID,
final SimpleString filterString,
final Queue storeAndForwardQueue,
final SimpleString bridgeName,
@@ -194,7 +194,7 @@
public void willRoute(final ServerMessage message)
{
- // We add a header with the name of the queue, holding a list of the transient ids of the queues to route to
+ // We add a header with the name of the queue, holding a list of the ids of the queues to route to
// TODO - this can be optimised
@@ -202,20 +202,20 @@
if (ids == null)
{
- ids = new byte[4];
+ ids = new byte[8];
}
else
{
- byte[] newIds = new byte[ids.length + 4];
+ byte[] newIds = new byte[ids.length + 8];
- System.arraycopy(ids, 0, newIds, 4, ids.length);
+ System.arraycopy(ids, 0, newIds, 8, ids.length);
ids = newIds;
}
ByteBuffer buff = ByteBuffer.wrap(ids);
- buff.putInt(remoteQueueID);
+ buff.putLong(remoteQueueID);
message.putBytesProperty(idsHeaderName, ids);
}
Modified: branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/server/impl/MessagingServerImpl.java
===================================================================
--- branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/server/impl/MessagingServerImpl.java 2009-08-06 08:44:47 UTC (rev 7669)
+++ branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/server/impl/MessagingServerImpl.java 2009-08-06 08:56:53 UTC (rev 7670)
@@ -208,6 +208,8 @@
private ConnectionManager pooledReplicatingConnectionManager;
private ConnectionManager nonPooledReplicatingConnectionManager;
+
+ private ClusterQueueStateManager clusterQueueStateManager;
// Constructors
// ---------------------------------------------------------------------------------
@@ -284,13 +286,15 @@
else
{
initialisePart2();
+
+ // initialisePart3();
}
-
+
// We start the remoting service here - if the server is a backup remoting service needs to be started
// so it can be initialised by the live node
remotingService.start();
- started = true;
+ //started = true;
log.info("JBoss Messaging Server version " + getVersion().getFullVersion() + " started");
}
@@ -548,14 +552,6 @@
version.getFullVersion());
}
- // if (!direct)
- // {
- // if (!registerBackupConnection(connection))
- // {
- // return null;
- // }
- // }
-
// Is this comment relevant any more ?
// Authenticate. Successful autentication will place a new SubjectContext
@@ -725,6 +721,8 @@
this.nodeID = new SimpleString(uuid.toString());
initialisePart2();
+
+ //initialisePart3();
long backupID = storageManager.getCurrentUniqueID();
@@ -737,6 +735,8 @@
backupID +
"). You're probably trying to restart a live backup pair after a crash");
}
+
+
log.info("Backup server is now ready");
}
@@ -914,7 +914,7 @@
}
}
- private boolean activatedBackup;
+ // private boolean activatedBackup;
public RemotingConnection getPooledReplicatingConnection() throws Exception
{
@@ -943,6 +943,25 @@
Channel channel1 = conn.getChannel(1);
channel1.send(new PacketImpl(PacketImpl.BACKUP_CONNECTION));
+
+// synchronized (this)
+// {
+// if (!activatedBackup)
+// {
+// // First time we get channel we send a message down it informing the backup of our node id -
+// // backup and live must have the same node id
+//
+// Packet packet = new ReplicateStartupInfoMessage(uuid, storageManager.getCurrentUniqueID());
+//
+// ChannelHandler prevHandler = channel1.getHandler();
+//
+// sendOnReplicatingAndWaitForResponse(packet, channel1);
+//
+// channel1.setHandler(prevHandler);
+//
+// activatedBackup = true;
+// }
+// }
return conn;
}
@@ -974,33 +993,31 @@
private RemotingConnection doGetNonPooledReplicatingConnection()
{
- RemotingConnection conn = null;
+ RemotingConnection conn = nonPooledReplicatingConnectionManager.getConnection(1);
- conn = nonPooledReplicatingConnectionManager.getConnection(1);
-
Channel channel1 = conn.getChannel(1);
channel1.send(new PacketImpl(PacketImpl.BACKUP_CONNECTION));
- synchronized (this)
- {
- if (!activatedBackup)
- {
- // First time we get channel we send a message down it informing the backup of our node id -
- // backup and live must have the same node id
+// synchronized (this)
+// {
+// if (!activatedBackup)
+// {
+// // First time we get channel we send a message down it informing the backup of our node id -
+// // backup and live must have the same node id
+//
+// Packet packet = new ReplicateStartupInfoMessage(uuid, storageManager.getCurrentUniqueID());
+//
+// ChannelHandler prevHandler = channel1.getHandler();
+//
+// sendOnReplicatingAndWaitForResponse(packet, channel1);
+//
+// channel1.setHandler(prevHandler);
+//
+// activatedBackup = true;
+// }
+// }
- Packet packet = new ReplicateStartupInfoMessage(uuid, storageManager.getCurrentUniqueID());
-
- ChannelHandler prevHandler = channel1.getHandler();
-
- sendOnReplicatingAndWaitForResponse(packet, channel1);
-
- channel1.setHandler(prevHandler);
-
- activatedBackup = true;
- }
- }
-
// TODO execute outstanding results when failure occurs
return conn;
@@ -1134,18 +1151,8 @@
log.info("** freezing backup connections");
- Set<RemotingConnection> connections = this.remotingService.getConnections();
+ Set<RemotingConnection> backupConnections = this.remotingService.getBackupConnections();
- Set<RemotingConnection> backupConnections = new HashSet<RemotingConnection>();
-
- for (RemotingConnection connection : connections)
- {
- if (!connection.isActive())
- {
- backupConnections.add(connection);
- }
- }
-
synchronized (backupConnections)
{
// frozen = true;
@@ -1315,44 +1322,11 @@
}
}
- // private void freezeConnections()
- // {
- // for (RemotingConnection rc : backupConnections)
- // {
- // rc.freeze();
- // }
- // }
-
- // public boolean registerBackupConnection(final RemotingConnection connection)
- // {
- // flock.lock();
- //
- // try
- // {
- // if (!frozen)
- // {
- // synchronized (backupConnections)
- // {
- // backupConnections.add(connection);
- // }
- // return true;
- // }
- // else
- // {
- // return false;
- // }
- // }
- // finally
- // {
- // flock.unlock();
- // }
- // }
-
private void initialisePart1() throws Exception
{
// Create the pools - we have two pools - one for non scheduled - and another for scheduled
- ThreadFactory tFactory = new JBMThreadThreadFactory("JBM-server-threads" + System.identityHashCode(this), false);
+ ThreadFactory tFactory = new JBMThreadFactory("JBM-server-threads" + System.identityHashCode(this), false);
if (configuration.getThreadPoolMaxSize() == -1)
{
@@ -1365,7 +1339,7 @@
executorFactory = new OrderedExecutorFactory(threadPool);
- ThreadFactory scheduledTFactory = new JBMThreadThreadFactory("JBM-scheduled-threads", false);
+ ThreadFactory scheduledTFactory = new JBMThreadFactory("JBM-scheduled-threads", false);
scheduledPool = new ScheduledThreadPoolExecutor(configuration.getScheduledThreadPoolMaxSize(), scheduledTFactory);
@@ -1381,8 +1355,6 @@
setupConnectionManagers();
}
- private ClusterQueueStateManager clusterQueueStateManager;
-
private void initialisePart2() throws Exception
{
// Create the hard-wired components
@@ -1398,7 +1370,7 @@
}
else
{
- storageManager = new NullStorageManager(configuration.isBackup());
+ storageManager = new NullStorageManager();
}
securityRepository = new HierarchicalObjectRepository<Set<Role>>();
@@ -1533,9 +1505,94 @@
}
pagingManager.startGlobalDepage();
+
+ if (pooledReplicatingConnectionManager != null)
+ {
+ //Activate the backup node
+
+ RemotingConnection conn = null;
+
+ try
+ {
+ conn = pooledReplicatingConnectionManager.getConnection(1);
+
+ Channel channel1 = conn.getChannel(1);
+
+ channel1.send(new PacketImpl(PacketImpl.BACKUP_CONNECTION));
+
+ Packet packet = new ReplicateStartupInfoMessage(uuid, storageManager.getCurrentUniqueID());
+
+ ChannelHandler prevHandler = channel1.getHandler();
+
+ sendOnReplicatingAndWaitForResponse(packet, channel1);
+
+ channel1.setHandler(prevHandler);
+ }
+ finally
+ {
+ returnPooledReplicatingConnection(conn);
+ }
+ }
initialised = true;
+
+ started = true;
}
+
+// private void initialisePart3() throws Exception
+// {
+// if (configuration.isClustered())
+// {
+// // This can't be created until node id is set
+// clusterManager = new ClusterManagerImpl(executorFactory,
+// this,
+// postOffice,
+// scheduledPool,
+// managementService,
+// configuration,
+// uuid,
+// configuration.isBackup());
+//
+// clusterManager.start();
+// }
+//
+// if (deploymentManager != null)
+// {
+// deploymentManager.start();
+// }
+//
+// pagingManager.startGlobalDepage();
+//
+// if (pooledReplicatingConnectionManager != null)
+// {
+// //Activate the backup node
+//
+// RemotingConnection conn = null;
+//
+// try
+// {
+// conn = pooledReplicatingConnectionManager.getConnection(1);
+//
+// Channel channel1 = conn.getChannel(1);
+//
+// channel1.send(new PacketImpl(PacketImpl.BACKUP_CONNECTION));
+//
+// Packet packet = new ReplicateStartupInfoMessage(uuid, storageManager.getCurrentUniqueID());
+//
+// ChannelHandler prevHandler = channel1.getHandler();
+//
+// sendOnReplicatingAndWaitForResponse(packet, channel1);
+//
+// channel1.setHandler(prevHandler);
+// }
+// finally
+// {
+// returnPooledReplicatingConnection(conn);
+// }
+// }
+//
+// initialised = true;
+// }
private void deployQueuesFromConfiguration() throws Exception
{
@@ -1700,6 +1757,8 @@
final boolean temporary,
final boolean ignoreIfExists) throws Exception
{
+ log.info("Creating queue on server with name " + queueName);
+
Binding binding = postOffice.getBinding(queueName);
if (binding != null)
@@ -1723,14 +1782,17 @@
long queueID;
+ log.info("Generating queue id");
do
{
queueID = storageManager.generateUniqueID();
}
while (queueID == 0 || queueID == 1); // 0 and 1 are reserved channels
+ log.info("Generated queue id");
Replicator replicator = getReplicatorForQueue(queueID);
+ log.info("Actually creating queue");
Queue queue = queueFactory.createQueue(queueID,
address,
queueName,
@@ -1739,6 +1801,7 @@
temporary,
replicator,
executorFactory.getExecutor());
+ log.info("Actually created queue");
binding = new LocalQueueBinding(address, queue, nodeID);
@@ -1746,11 +1809,13 @@
{
storageManager.addQueueBinding(binding);
}
-
+ log.info("Actually adding binding");
postOffice.addBinding(binding);
+ log.info("Actually added binding");
createHandlerForQueue(queue);
+ log.info("Done messaging server create queue");
return queue;
}
@@ -1867,30 +1932,5 @@
queue.activateNow(threadPool);
}
}
-
- private static class JBMThreadThreadFactory extends JBMThreadFactory
- {
- public JBMThreadThreadFactory(final String groupName, final boolean daemon)
- {
- super(groupName, daemon);
- }
-
- public JBMThreadThreadFactory(final String groupName, final int threadPriority, final boolean daemon)
- {
- super(groupName, threadPriority, daemon);
- }
-
- @Override
- public Thread newThread(final Runnable command)
- {
- Thread t = new JBMThread(group, command, "Thread-" + threadCount.getAndIncrement() +
- " (group:" +
- group.getName() +
- ")");
-
- t.setDaemon(daemon);
- t.setPriority(threadPriority);
- return t;
- }
- }
+
}
Modified: branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/server/impl/QueueImpl.java
===================================================================
--- branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/server/impl/QueueImpl.java 2009-08-06 08:44:47 UTC (rev 7669)
+++ branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/server/impl/QueueImpl.java 2009-08-06 08:56:53 UTC (rev 7670)
@@ -27,7 +27,6 @@
import java.util.Map;
import java.util.Set;
import java.util.concurrent.Executor;
-import java.util.concurrent.RejectedExecutionException;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
@@ -144,7 +143,7 @@
private final Set<Consumer> consumers = new HashSet<Consumer>();
private final ReplicationAwareMutex lock;
-
+
private final Executor executor;
public QueueImpl(final long id,
@@ -194,14 +193,12 @@
scheduledDeliveryHandler = new ScheduledDeliveryHandlerImpl(scheduledExecutor);
lock = new ReplicationAwareMutex(name.toString(), 0, true);
-
- // lock = rwLock.writeLock();
this.replicator = replicator;
-
+
this.executor = executor;
}
-
+
public void close()
{
if (replicator != null)
@@ -209,7 +206,7 @@
replicator.close();
}
}
-
+
public Replicator getReplicator()
{
return replicator;
@@ -407,9 +404,8 @@
}
if (waitingToDeliver.compareAndSet(false, true))
- {
- executor.execute(deliverRunner);
-
+ {
+ executor.execute(deliverRunner);
}
}
@@ -762,8 +758,8 @@
if (oper == null)
{
- //log.info("Creating new refs operation");
-
+ // log.info("Creating new refs operation");
+
oper = new RefsOperation();
tx.putProperty(TransactionPropertyIndexes.REFS_OPERATION, oper);
@@ -853,9 +849,9 @@
public int deleteMatchingReferences(final Filter filter) throws Exception
{
int count = 0;
-
+
Transaction tx = new TransactionImpl(storageManager);
-
+
lock.lock(12);
try
@@ -890,7 +886,7 @@
{
lock.unlock();
}
-
+
tx.commit();
return count;
@@ -905,7 +901,7 @@
lock.lock(13);
try
- {
+ {
Iterator<MessageReference> iter = messageReferences.iterator();
while (iter.hasNext())
@@ -919,15 +915,15 @@
deleted = true;
break;
}
- }
+ }
}
finally
{
lock.unlock();
}
-
+
tx.commit();
-
+
return deleted;
}
@@ -963,11 +959,11 @@
Transaction tx = new TransactionImpl(storageManager);
int count = 0;
-
+
lock.lock(15);
try
- {
+ {
Iterator<MessageReference> iter = messageReferences.iterator();
while (iter.hasNext())
@@ -980,13 +976,13 @@
iter.remove();
count++;
}
- }
+ }
}
finally
{
lock.unlock();
}
-
+
tx.commit();
return count;
@@ -1071,11 +1067,11 @@
Transaction tx = new TransactionImpl(storageManager);
int count = 0;
-
+
lock.lock(19);
try
- {
+ {
Iterator<MessageReference> iter = messageReferences.iterator();
while (iter.hasNext())
@@ -1100,13 +1096,13 @@
acknowledge(tx, ref);
count++;
}
- }
+ }
}
finally
{
lock.unlock();
}
-
+
tx.commit();
return count;
@@ -1495,7 +1491,7 @@
}
status = deliverReference(reference);
-
+
if (status == HandleStatus.HANDLED)
{
if (iterator == null)
@@ -1507,6 +1503,15 @@
iterator.remove();
}
}
+ else if (status == HandleStatus.NO_MATCH)
+ {
+ if (iterator == null)
+ {
+ iterator = messageReferences.iterator();
+
+ iterator.next();
+ }
+ }
}
}
while (status == HandleStatus.NO_MATCH);
@@ -1539,7 +1544,7 @@
if (direct)
{
// Deliver directly
-
+
HandleStatus status = deliverReference(ref);
if (status == HandleStatus.HANDLED)
@@ -1561,7 +1566,7 @@
}
}
else
- {
+ {
add = true;
}
@@ -1581,16 +1586,16 @@
messageReferences.addLast(ref, ref.getMessage().getPriority());
}
-// if (!direct && promptDelivery)
-// {
-// // We have consumers with filters which don't match, so we need
-// // to prompt delivery every time
-// // a new message arrives - this is why you really shouldn't use
-// // filters with queues - in most cases
-// // it's an ant-pattern since it would cause a queue scan on each
-// // message
-// deliverAll();
-// }
+ if (!direct && promptDelivery)
+ {
+ // We have consumers with filters which don't match, so we need
+ // to prompt delivery every time
+ // a new message arrives - this is why you really shouldn't use
+ // filters with queues - in most cases
+ // it's an anti-pattern since it would cause a queue scan on each
+ // message
+ deliverAsync();
+ }
}
}
finally
@@ -1678,7 +1683,7 @@
ServerMessage msg = ref.getMessage();
if (!scheduledDeliveryHandler.checkAndSchedule(ref, backup))
- {
+ {
messageReferences.addFirst(ref, msg.getPriority());
}
}
@@ -1690,7 +1695,7 @@
deliverAsync();
}
-
+
// Inner classes
// --------------------------------------------------------------------------
@@ -1708,12 +1713,8 @@
/*
* Attempt to deliver all the messages in the queue
*/
- private void deliverAll()
+ public void deliverAll()
{
- // direct = false;
-
- //log.info("delivering all " + this.backup);
-
HandleStatus handled;
if (replicator != null)
@@ -1767,8 +1768,6 @@
synchronized void addRef(final MessageReference ref)
{
refsToAdd.add(ref);
-
- //log.info("adding ref, now there are " + refsToAdd.size());
}
synchronized void addAck(final MessageReference ref)
@@ -1832,8 +1831,8 @@
public void afterCommit(final Transaction tx) throws Exception
{
- //log.info("after commit , to add " + refsToAdd.size() + " to ack " + refsToAck.size());
-
+ // log.info("after commit , to add " + refsToAdd.size() + " to ack " + refsToAck.size());
+
for (MessageReference ref : refsToAdd)
{
ref.getQueue().addLast(ref);
Modified: branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/server/impl/ServerSessionPacketHandler.java
===================================================================
--- branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/server/impl/ServerSessionPacketHandler.java 2009-08-06 08:44:47 UTC (rev 7669)
+++ branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/server/impl/ServerSessionPacketHandler.java 2009-08-06 08:56:53 UTC (rev 7670)
@@ -207,15 +207,6 @@
}
}
- // private static synchronized void dumpSequences(List<Long> sequences)
- // {
- // log.info("dumping sequences");
- // for (long sequence : sequences)
- // {
- // log.info(sequence);
- // }
- // }
-
private void handlePacket()
{
byte type = packet.getType();
@@ -229,6 +220,8 @@
ReplicateLockSequenceMessage msg = (ReplicateLockSequenceMessage)packet;
sequences = msg.getSequences();
+
+ //dumpSequences(sequences);
break;
}
Modified: branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/server/replication/impl/ReplicationAwareMutex.java
===================================================================
--- branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/server/replication/impl/ReplicationAwareMutex.java 2009-08-06 08:44:47 UTC (rev 7669)
+++ branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/server/replication/impl/ReplicationAwareMutex.java 2009-08-06 08:56:53 UTC (rev 7670)
@@ -277,6 +277,9 @@
throw new IllegalStateException("How can it be non replay?");
}
+// log.info("attempting to get lock " + name + " with sequence " + sequence + " current sequence " +
+// counter.get());
+
if (!sequencedLock.lock(sequence, unit.toNanos(time)))
{
// dumpLocksWithName(name);
@@ -284,6 +287,8 @@
dumpHistory(name);
}
+
+ // log.info("got lock");
}
catch (InterruptedException e)
{
@@ -312,7 +317,13 @@
freezeLatch.await();
}
- boolean ok = lock.tryLock(time, unit);
+ //boolean ok = lock.tryLock(time, unit);
+
+ lock.lock();
+
+ boolean ok = true;
+
+ //log.info("Thread " + thread + " got lock " + this + " ok "+ ok);
if (ok)
{
@@ -379,6 +390,7 @@
}
else
{
+ //log.info("Thread " + thread + " trying to unlock " + this);
lock.unlock();
}
}
Modified: branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/server/replication/impl/ReplicatorImpl.java
===================================================================
--- branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/server/replication/impl/ReplicatorImpl.java 2009-08-06 08:44:47 UTC (rev 7669)
+++ branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/server/replication/impl/ReplicatorImpl.java 2009-08-06 08:56:53 UTC (rev 7670)
@@ -25,6 +25,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.NoSuchElementException;
import java.util.Queue;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.atomic.AtomicLong;
@@ -33,7 +34,6 @@
import org.jboss.messaging.core.remoting.Channel;
import org.jboss.messaging.core.remoting.Packet;
import org.jboss.messaging.core.remoting.impl.QueuedWriteManager;
-import org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl;
import org.jboss.messaging.core.remoting.impl.wireformat.replication.ReplicateLockSequenceMessage;
import org.jboss.messaging.core.server.replication.ReplicableAction;
import org.jboss.messaging.core.server.replication.Replicator;
@@ -107,7 +107,16 @@
public void replicationResponseReceived()
{
- WaitingChannelsHolder waitingChannelsHolder = waitingChannelsQueue.remove();
+ WaitingChannelsHolder waitingChannelsHolder;
+ try
+ {
+ waitingChannelsHolder = waitingChannelsQueue.remove();
+ }
+ catch (NoSuchElementException ignore)
+ {
+ //FIXME - do not ignore this!
+ return;
+ }
for (Map.Entry<QueuedWriteManager, ChannelCount> entry: waitingChannelsHolder.channelQueuedWriteCounts.entrySet())
{
@@ -143,8 +152,8 @@
List<Triple<Long, Long, Integer>> sequences = thread.getSequences();
long id = seq.getAndIncrement();
-// log.info("replicating " + name + " seq " + id);
-// dumpSequences(sequences);
+ //log.info("replicating " + name + " seq " + id);
+ // dumpSequences(sequences);
// log.info("replicating packet " + action.getPacket());
Modified: branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/server/replication/impl/SequencedLock.java
===================================================================
--- branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/server/replication/impl/SequencedLock.java 2009-08-06 08:44:47 UTC (rev 7669)
+++ branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/core/server/replication/impl/SequencedLock.java 2009-08-06 08:56:53 UTC (rev 7670)
@@ -171,6 +171,8 @@
public SequencedLock(final long id, final String name, final long sequence)
{
this.id = id;
+
+ log.info("creating lock " + name + " with id " + id);
this.name = name;
@@ -184,6 +186,7 @@
// TODO parking with a timeout seems to be a lot slower than parking without timeout
public boolean lock(final long sequence, final long timeout) throws InterruptedException
{
+ //log.info("Attempting to get lock " + name + " id " + id + " with seq " + sequence + " current seq " + this.currentSequence);
JBMThread currentThread = JBMThread.currentThread();
QueueEntry entry = new QueueEntry(sequence, currentThread);
Modified: branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/utils/JBMThreadFactory.java
===================================================================
--- branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/utils/JBMThreadFactory.java 2009-08-06 08:44:47 UTC (rev 7669)
+++ branches/Branch_MultiThreaded_Replication/src/main/org/jboss/messaging/utils/JBMThreadFactory.java 2009-08-06 08:56:53 UTC (rev 7670)
@@ -24,6 +24,8 @@
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.atomic.AtomicInteger;
+import org.jboss.messaging.core.server.replication.impl.JBMThread;
+
/**
*
* A JBMThreadFactory
@@ -57,13 +59,14 @@
public Thread newThread(final Runnable command)
{
- Thread t = new Thread(group, command, "Thread-" + threadCount.getAndIncrement() +
- " (group:" +
- group.getName() +
- ")");
+ Thread t = new JBMThread(group, command, "Thread-" + threadCount.getAndIncrement() +
+ " (group:" +
+ group.getName() +
+ ")");
t.setDaemon(daemon);
t.setPriority(threadPriority);
return t;
}
}
+
Modified: branches/Branch_MultiThreaded_Replication/tests/src/org/jboss/messaging/tests/concurrent/server/impl/QueueTest.java
===================================================================
--- branches/Branch_MultiThreaded_Replication/tests/src/org/jboss/messaging/tests/concurrent/server/impl/QueueTest.java 2009-08-06 08:44:47 UTC (rev 7669)
+++ branches/Branch_MultiThreaded_Replication/tests/src/org/jboss/messaging/tests/concurrent/server/impl/QueueTest.java 2009-08-06 08:56:53 UTC (rev 7670)
@@ -88,7 +88,7 @@
consumer.setStatusImmediate(HandleStatus.HANDLED);
- queue.deliverNow();
+ queue.deliverAll();
if (sender.getException() != null)
{
@@ -205,7 +205,7 @@
{
consumer.setStatusImmediate(HandleStatus.HANDLED);
- queue.deliverNow();
+ queue.deliverAll();
}
toggle = !toggle;
Modified: branches/Branch_MultiThreaded_Replication/tests/src/org/jboss/messaging/tests/integration/cluster/distribution/OnewayTwoNodeClusterTest.java
===================================================================
--- branches/Branch_MultiThreaded_Replication/tests/src/org/jboss/messaging/tests/integration/cluster/distribution/OnewayTwoNodeClusterTest.java 2009-08-06 08:44:47 UTC (rev 7669)
+++ branches/Branch_MultiThreaded_Replication/tests/src/org/jboss/messaging/tests/integration/cluster/distribution/OnewayTwoNodeClusterTest.java 2009-08-06 08:56:53 UTC (rev 7670)
@@ -54,6 +54,7 @@
closeAllSessionFactories();
+ log.info("Stopping servers");
stopServers(0, 1);
super.tearDown();
@@ -1094,7 +1095,11 @@
waitForBindings(0, "queues.testaddress", 6, 6, true);
waitForBindings(0, "queues.testaddress", 6, 6, false);
+ log.info("about to send");
+
send(0, "queues.testaddress", 10, false, filter1);
+
+ log.info("sent");
verifyReceiveAll(10, 0, 2, 4, 6, 8, 10, 11);
Modified: branches/Branch_MultiThreaded_Replication/tests/src/org/jboss/messaging/tests/integration/cluster/distribution/SymmetricClusterTest.java
===================================================================
--- branches/Branch_MultiThreaded_Replication/tests/src/org/jboss/messaging/tests/integration/cluster/distribution/SymmetricClusterTest.java 2009-08-06 08:44:47 UTC (rev 7669)
+++ branches/Branch_MultiThreaded_Replication/tests/src/org/jboss/messaging/tests/integration/cluster/distribution/SymmetricClusterTest.java 2009-08-06 08:56:53 UTC (rev 7670)
@@ -175,24 +175,39 @@
setupCluster();
startServers();
+
+ log.info("*** started servers");
setupSessionFactory(0, isNetty());
setupSessionFactory(1, isNetty());
setupSessionFactory(2, isNetty());
setupSessionFactory(3, isNetty());
setupSessionFactory(4, isNetty());
+
+ log.info("setup session factorys");
createQueue(0, "queues.testaddress", "queue0", null, false);
+
+ log.info("created queue0");
+
createQueue(1, "queues.testaddress", "queue0", null, false);
+
+ log.info("created queue1");
createQueue(2, "queues.testaddress", "queue0", null, false);
+ log.info("created queue2");
createQueue(3, "queues.testaddress", "queue0", null, false);
+ log.info("created queue3");
createQueue(4, "queues.testaddress", "queue0", null, false);
+
+ log.info("created queues");
addConsumer(0, 0, "queue0", null);
addConsumer(1, 1, "queue0", null);
addConsumer(2, 2, "queue0", null);
addConsumer(3, 3, "queue0", null);
addConsumer(4, 4, "queue0", null);
+
+ log.info("added consumers");
waitForBindings(0, "queues.testaddress", 1, 1, true);
waitForBindings(1, "queues.testaddress", 1, 1, true);
@@ -206,11 +221,19 @@
waitForBindings(3, "queues.testaddress", 4, 4, false);
waitForBindings(4, "queues.testaddress", 4, 4, false);
+ log.info("sending messages");
+
send(0, "queues.testaddress", 10, false, null);
+
+ log.info("sent messages");
verifyReceiveRoundRobinInSomeOrder(10, 0, 1, 2, 3, 4);
+
+ log.info("received round robin");
this.verifyNotReceive(0, 1, 2, 3, 4);
+
+ log.info("done");
}
public void testRoundRobinMultipleQueues() throws Exception
Modified: branches/Branch_MultiThreaded_Replication/tests/src/org/jboss/messaging/tests/integration/cluster/failover/FailBackupServerTest.java
===================================================================
--- branches/Branch_MultiThreaded_Replication/tests/src/org/jboss/messaging/tests/integration/cluster/failover/FailBackupServerTest.java 2009-08-06 08:44:47 UTC (rev 7669)
+++ branches/Branch_MultiThreaded_Replication/tests/src/org/jboss/messaging/tests/integration/cluster/failover/FailBackupServerTest.java 2009-08-06 08:56:53 UTC (rev 7670)
@@ -36,6 +36,7 @@
import org.jboss.messaging.core.config.impl.ConfigurationImpl;
import org.jboss.messaging.core.exception.MessagingException;
import org.jboss.messaging.core.logging.Logger;
+import org.jboss.messaging.core.remoting.RemotingConnection;
import org.jboss.messaging.core.remoting.impl.invm.InVMRegistry;
import org.jboss.messaging.core.remoting.impl.invm.TransportConstants;
import org.jboss.messaging.core.server.Messaging;
@@ -126,11 +127,12 @@
if (i == 0)
{
- // Fail the replicating connection - this simulates the backup server crashing
+ // Fail the replicating connections - this simulates the backup server crashing
- liveServer.getReplicatingChannel()
- .getConnection()
- .fail(new MessagingException(MessagingException.NOT_CONNECTED, "blah"));
+ for (RemotingConnection conn: backupServer.getRemotingService().getBackupConnections())
+ {
+ conn.fail(new MessagingException(MessagingException.NOT_CONNECTED, "blah"));
+ }
}
message.acknowledge();
Modified: branches/Branch_MultiThreaded_Replication/tests/src/org/jboss/messaging/tests/integration/cluster/failover/SplitBrainTest.java
===================================================================
--- branches/Branch_MultiThreaded_Replication/tests/src/org/jboss/messaging/tests/integration/cluster/failover/SplitBrainTest.java 2009-08-06 08:44:47 UTC (rev 7669)
+++ branches/Branch_MultiThreaded_Replication/tests/src/org/jboss/messaging/tests/integration/cluster/failover/SplitBrainTest.java 2009-08-06 08:56:53 UTC (rev 7670)
@@ -117,12 +117,17 @@
}
//Now fail the replicating connections
- Set<RemotingConnection> conns = liveServer.getRemotingService().getConnections();
- for (RemotingConnection conn : conns)
+// Set<RemotingConnection> conns = liveServer.getRemotingService().getConnections();
+// for (RemotingConnection conn : conns)
+// {
+// RemotingConnection replicatingConnection = liveServer.getReplicatingChannel().getConnection();
+// Connection tcConn = replicatingConnection.getTransportConnection();
+// tcConn.fail(new MessagingException(MessagingException.INTERNAL_ERROR, "blah"));
+// }
+
+ for (RemotingConnection conn: backupServer.getRemotingService().getBackupConnections())
{
- RemotingConnection replicatingConnection = liveServer.getReplicatingChannel().getConnection();
- Connection tcConn = replicatingConnection.getTransportConnection();
- tcConn.fail(new MessagingException(MessagingException.INTERNAL_ERROR, "blah"));
+ conn.fail(new MessagingException(MessagingException.NOT_CONNECTED, "blah"));
}
Thread.sleep(2000);
Modified: branches/Branch_MultiThreaded_Replication/tests/src/org/jboss/messaging/tests/integration/discovery/DiscoveryTest.java
===================================================================
--- branches/Branch_MultiThreaded_Replication/tests/src/org/jboss/messaging/tests/integration/discovery/DiscoveryTest.java 2009-08-06 08:44:47 UTC (rev 7669)
+++ branches/Branch_MultiThreaded_Replication/tests/src/org/jboss/messaging/tests/integration/discovery/DiscoveryTest.java 2009-08-06 08:56:53 UTC (rev 7670)
@@ -28,7 +28,6 @@
import java.util.HashMap;
import java.util.Map;
-import org.jboss.messaging.core.cluster.DiscoveryEntry;
import org.jboss.messaging.core.cluster.DiscoveryGroup;
import org.jboss.messaging.core.cluster.DiscoveryListener;
import org.jboss.messaging.core.cluster.impl.DiscoveryGroupImpl;
@@ -54,13 +53,13 @@
public class DiscoveryTest extends UnitTestCase
{
private static final Logger log = Logger.getLogger(DiscoveryTest.class);
-
+
private static final String address1 = "230.1.2.3";
-
+
private static final String address2 = "230.1.2.4";
-
+
private static final String address3 = "230.1.2.5";
-
+
private static final String address4 = "230.1.2.6";
public void testSimpleBroadcast() throws Exception
@@ -68,7 +67,7 @@
final InetAddress groupAddress = InetAddress.getByName(address1);
final int groupPort = 6745;
final int timeout = 500;
-
+
final String nodeID = randomString();
BroadcastGroup bg = new BroadcastGroupImpl(nodeID, randomString(), null, -1, groupAddress, groupPort, true);
@@ -94,30 +93,30 @@
assertTrue(ok);
- Map<String, DiscoveryEntry> entryMap = dg.getDiscoveryEntryMap();
+ Map<String, Pair<TransportConfiguration, TransportConfiguration>> entryMap = dg.getDiscoveryEntryMap();
assertNotNull(entryMap);
assertEquals(1, entryMap.size());
- DiscoveryEntry entry = entryMap.get(nodeID);
-
+ Pair<TransportConfiguration, TransportConfiguration> entry = entryMap.get(nodeID);
+
assertNotNull(entry);
- assertEquals(connectorPair, entry.getConnectorPair());
+ assertEquals(connectorPair, entry);
bg.stop();
dg.stop();
}
-
+
public void testSimpleBroadcastWithStopStartDiscoveryGroup() throws Exception
{
final InetAddress groupAddress = InetAddress.getByName(address1);
final int groupPort = 6745;
final int timeout = 500;
-
+
final String nodeID = randomString();
BroadcastGroup bg = new BroadcastGroupImpl(nodeID, randomString(), null, -1, groupAddress, groupPort, true);
@@ -143,28 +142,28 @@
assertTrue(ok);
- Map<String, DiscoveryEntry> entryMap = dg.getDiscoveryEntryMap();
+ Map<String, Pair<TransportConfiguration, TransportConfiguration>> entryMap = dg.getDiscoveryEntryMap();
assertNotNull(entryMap);
assertEquals(1, entryMap.size());
- DiscoveryEntry entry = entryMap.get(nodeID);
-
+ Pair<TransportConfiguration, TransportConfiguration> entry = entryMap.get(nodeID);
+
assertNotNull(entry);
- assertEquals(connectorPair, entry.getConnectorPair());
+ assertEquals(connectorPair, entry);
bg.stop();
dg.stop();
-
+
dg.start();
-
+
bg.start();
-
+
bg.broadcastConnectors();
-
+
ok = dg.waitForBroadcast(1000);
assertTrue(ok);
@@ -176,19 +175,19 @@
assertEquals(1, entryMap.size());
entry = entryMap.get(nodeID);
-
+
assertNotNull(entry);
- assertEquals(connectorPair, entry.getConnectorPair());
+ assertEquals(connectorPair, entry);
}
-
+
public void testIgnoreTrafficFromOwnNode() throws Exception
{
final InetAddress groupAddress = InetAddress.getByName(address1);
final int groupPort = 6745;
final int timeout = 500;
-
+
String nodeID = randomString();
BroadcastGroup bg = new BroadcastGroupImpl(nodeID, randomString(), null, -1, groupAddress, groupPort, true);
@@ -214,7 +213,7 @@
assertFalse(ok);
- Map<String, DiscoveryEntry> entryMap = dg.getDiscoveryEntryMap();
+ Map<String, Pair<TransportConfiguration, TransportConfiguration>> entryMap = dg.getDiscoveryEntryMap();
assertNotNull(entryMap);
@@ -226,54 +225,61 @@
}
-// There is a bug in some OSes where different addresses but *Same port* will receive the traffic - hence this test won't pass
-// See http://www.jboss.org/community/docs/DOC-11710 (jboss wiki promiscuous traffic)
-
-
-// public void testSimpleBroadcastDifferentAddress() throws Exception
-// {
-// final InetAddress groupAddress = InetAddress.getByName(address1);
-// final int groupPort = 6745;
-// final int timeout = 500;
-//
-// BroadcastGroup bg = new BroadcastGroupImpl(randomString(), randomString(), null, -1, groupAddress, groupPort);
-//
-// bg.start();
-//
-// TransportConfiguration live1 = generateTC();
-//
-// TransportConfiguration backup1 = generateTC();
-//
-// Pair<TransportConfiguration, TransportConfiguration> connectorPair = new Pair<TransportConfiguration, TransportConfiguration>(live1,
-// backup1);
-//
-// bg.addConnectorPair(connectorPair);
-//
-// final InetAddress groupAddress2 = InetAddress.getByName(address2);
-//
-// DiscoveryGroup dg = new DiscoveryGroupImpl(randomString(), randomString(), groupAddress2, groupPort, timeout);
-//
-// dg.start();
-//
-// bg.broadcastConnectors();
-//
-// boolean ok = dg.waitForBroadcast(1000);
-//
-// assertFalse(ok);
-//
-// bg.stop();
-//
-// dg.stop();
-//
-// }
+ // There is a bug in some OSes where different addresses but *Same port* will receive the traffic - hence this test
+ // won't pass
+ // See http://www.jboss.org/community/docs/DOC-11710 (jboss wiki promiscuous traffic)
+ // public void testSimpleBroadcastDifferentAddress() throws Exception
+ // {
+ // final InetAddress groupAddress = InetAddress.getByName(address1);
+ // final int groupPort = 6745;
+ // final int timeout = 500;
+ //
+ // BroadcastGroup bg = new BroadcastGroupImpl(randomString(), randomString(), null, -1, groupAddress, groupPort);
+ //
+ // bg.start();
+ //
+ // TransportConfiguration live1 = generateTC();
+ //
+ // TransportConfiguration backup1 = generateTC();
+ //
+ // Pair<TransportConfiguration, TransportConfiguration> connectorPair = new Pair<TransportConfiguration,
+ // TransportConfiguration>(live1,
+ // backup1);
+ //
+ // bg.addConnectorPair(connectorPair);
+ //
+ // final InetAddress groupAddress2 = InetAddress.getByName(address2);
+ //
+ // DiscoveryGroup dg = new DiscoveryGroupImpl(randomString(), randomString(), groupAddress2, groupPort, timeout);
+ //
+ // dg.start();
+ //
+ // bg.broadcastConnectors();
+ //
+ // boolean ok = dg.waitForBroadcast(1000);
+ //
+ // assertFalse(ok);
+ //
+ // bg.stop();
+ //
+ // dg.stop();
+ //
+ // }
+
public void testSimpleBroadcastDifferentPort() throws Exception
{
final InetAddress groupAddress = InetAddress.getByName("230.1.2.3");
final int groupPort = 6745;
final int timeout = 500;
- BroadcastGroup bg = new BroadcastGroupImpl(randomString(), randomString(), null, -1, groupAddress, groupPort, true);
+ BroadcastGroup bg = new BroadcastGroupImpl(randomString(),
+ randomString(),
+ null,
+ -1,
+ groupAddress,
+ groupPort,
+ true);
bg.start();
@@ -309,7 +315,13 @@
final int groupPort = 6745;
final int timeout = 500;
- BroadcastGroup bg = new BroadcastGroupImpl(randomString(), randomString(), null, -1, groupAddress, groupPort, true);
+ BroadcastGroup bg = new BroadcastGroupImpl(randomString(),
+ randomString(),
+ null,
+ -1,
+ groupAddress,
+ groupPort,
+ true);
bg.start();
@@ -352,11 +364,11 @@
final int groupPort3 = 6747;
final int timeout = 500;
-
+
String node1 = randomString();
-
+
String node2 = randomString();
-
+
String node3 = randomString();
BroadcastGroup bg1 = new BroadcastGroupImpl(node1, randomString(), null, -1, groupAddress1, groupPort1, true);
@@ -407,30 +419,30 @@
boolean ok = dg1.waitForBroadcast(1000);
assertTrue(ok);
- Map<String, DiscoveryEntry> entryMap = dg1.getDiscoveryEntryMap();
+ Map<String, Pair<TransportConfiguration, TransportConfiguration>> entryMap = dg1.getDiscoveryEntryMap();
assertNotNull(entryMap);
assertEquals(1, entryMap.size());
- DiscoveryEntry entry = entryMap.get(node1);
+ Pair<TransportConfiguration, TransportConfiguration> entry = entryMap.get(node1);
assertNotNull(entry);
- assertEquals(connectorPair1, entry.getConnectorPair());
+ assertEquals(connectorPair1, entry);
ok = dg2.waitForBroadcast(1000);
assertTrue(ok);
entryMap = dg2.getDiscoveryEntryMap();
assertNotNull(entryMap);
assertEquals(1, entryMap.size());
- entry = entryMap.get(node2);
+ entry = entryMap.get(node2);
assertNotNull(entry);
- assertEquals(connectorPair2, entry.getConnectorPair());
+ assertEquals(connectorPair2, entry);
ok = dg3.waitForBroadcast(1000);
assertTrue(ok);
entryMap = dg3.getDiscoveryEntryMap();
assertNotNull(entryMap);
assertEquals(1, entryMap.size());
- entry = entryMap.get(node3);
+ entry = entryMap.get(node3);
assertNotNull(entry);
- assertEquals(connectorPair3, entry.getConnectorPair());
+ assertEquals(connectorPair3, entry);
bg1.stop();
bg2.stop();
@@ -446,7 +458,7 @@
final InetAddress groupAddress = InetAddress.getByName(address1);
final int groupPort = 6745;
final int timeout = 500;
-
+
String nodeID = randomString();
BroadcastGroup bg = new BroadcastGroupImpl(nodeID, randomString(), null, -1, groupAddress, groupPort, true);
@@ -470,12 +482,12 @@
assertTrue(ok);
- Map<String, DiscoveryEntry> entryMap = dg.getDiscoveryEntryMap();
+ Map<String, Pair<TransportConfiguration, TransportConfiguration>> entryMap = dg.getDiscoveryEntryMap();
assertNotNull(entryMap);
assertEquals(1, entryMap.size());
- DiscoveryEntry entry = entryMap.get(nodeID);
+ Pair<TransportConfiguration, TransportConfiguration> entry = entryMap.get(nodeID);
assertNotNull(entry);
- assertEquals(connectorPair, entry.getConnectorPair());
+ assertEquals(connectorPair, entry);
bg.stop();
@@ -488,7 +500,7 @@
final InetAddress groupAddress = InetAddress.getByName(address1);
final int groupPort = 6745;
final int timeout = 500;
-
+
String nodeID = randomString();
BroadcastGroup bg = new BroadcastGroupImpl(nodeID, randomString(), null, -1, groupAddress, groupPort, true);
@@ -545,7 +557,7 @@
final InetAddress groupAddress = InetAddress.getByName(address1);
final int groupPort = 6745;
final int timeout = 500;
-
+
String node1 = randomString();
String node2 = randomString();
String node3 = randomString();
@@ -589,12 +601,12 @@
bg1.broadcastConnectors();
boolean ok = dg.waitForBroadcast(1000);
assertTrue(ok);
- Map<String, DiscoveryEntry> entryMap = dg.getDiscoveryEntryMap();
+ Map<String, Pair<TransportConfiguration, TransportConfiguration>> entryMap = dg.getDiscoveryEntryMap();
assertNotNull(entryMap);
assertEquals(1, entryMap.size());
- DiscoveryEntry entry = entryMap.get(node1);
+ Pair<TransportConfiguration, TransportConfiguration> entry = entryMap.get(node1);
assertNotNull(entry);
- assertEquals(connectorPair1, entry.getConnectorPair());
+ assertEquals(connectorPair1, entry);
assertTrue(listener1.called);
assertTrue(listener2.called);
listener1.called = false;
@@ -605,13 +617,13 @@
assertTrue(ok);
entryMap = dg.getDiscoveryEntryMap();
assertNotNull(entryMap);
- assertEquals(2, entryMap.size());
- DiscoveryEntry entry1 = entryMap.get(node1);
+ assertEquals(2, entryMap.size());
+ Pair<TransportConfiguration, TransportConfiguration> entry1 = entryMap.get(node1);
assertNotNull(entry1);
- assertEquals(connectorPair1, entry1.getConnectorPair());
- DiscoveryEntry entry2 = entryMap.get(node2);
+ assertEquals(connectorPair1, entry1);
+ Pair<TransportConfiguration, TransportConfiguration> entry2 = entryMap.get(node2);
assertNotNull(entry2);
- assertEquals(connectorPair2, entry2.getConnectorPair());
+ assertEquals(connectorPair2, entry2);
assertTrue(listener1.called);
assertTrue(listener2.called);
listener1.called = false;
@@ -622,16 +634,16 @@
assertTrue(ok);
entryMap = dg.getDiscoveryEntryMap();
assertNotNull(entryMap);
- assertEquals(3, entryMap.size());
- entry1 = entryMap.get(node1);
+ assertEquals(3, entryMap.size());
+ entry1 = entryMap.get(node1);
assertNotNull(entry1);
- assertEquals(connectorPair1, entry1.getConnectorPair());
- entry2 = entryMap.get(node2);
+ assertEquals(connectorPair1, entry1);
+ entry2 = entryMap.get(node2);
assertNotNull(entry2);
- assertEquals(connectorPair2, entry2.getConnectorPair());
- DiscoveryEntry entry3 = entryMap.get(node3);
+ assertEquals(connectorPair2, entry2);
+ Pair<TransportConfiguration, TransportConfiguration> entry3 = entryMap.get(node3);
assertNotNull(entry3);
- assertEquals(connectorPair3, entry3.getConnectorPair());
+ assertEquals(connectorPair3, entry3);
assertTrue(listener1.called);
assertTrue(listener2.called);
listener1.called = false;
@@ -642,16 +654,16 @@
assertTrue(ok);
entryMap = dg.getDiscoveryEntryMap();
assertNotNull(entryMap);
- assertEquals(3, entryMap.size());
- entry1 = entryMap.get(node1);
+ assertEquals(3, entryMap.size());
+ entry1 = entryMap.get(node1);
assertNotNull(entry1);
- assertEquals(connectorPair1, entry1.getConnectorPair());
- entry2 = entryMap.get(node2);
+ assertEquals(connectorPair1, entry1);
+ entry2 = entryMap.get(node2);
assertNotNull(entry2);
- assertEquals(connectorPair2, entry2.getConnectorPair());
- entry3 = entryMap.get(node3);
+ assertEquals(connectorPair2, entry2);
+ entry3 = entryMap.get(node3);
assertNotNull(entry3);
- assertEquals(connectorPair3, entry3.getConnectorPair());
+ assertEquals(connectorPair3, entry3);
assertFalse(listener1.called);
assertFalse(listener2.called);
listener1.called = false;
@@ -662,16 +674,16 @@
assertTrue(ok);
entryMap = dg.getDiscoveryEntryMap();
assertNotNull(entryMap);
- assertEquals(3, entryMap.size());
- entry1 = entryMap.get(node1);
+ assertEquals(3, entryMap.size());
+ entry1 = entryMap.get(node1);
assertNotNull(entry1);
- assertEquals(connectorPair1, entry1.getConnectorPair());
- entry2 = entryMap.get(node2);
+ assertEquals(connectorPair1, entry1);
+ entry2 = entryMap.get(node2);
assertNotNull(entry2);
- assertEquals(connectorPair2, entry2.getConnectorPair());
- entry3 = entryMap.get(node3);
+ assertEquals(connectorPair2, entry2);
+ entry3 = entryMap.get(node3);
assertNotNull(entry3);
- assertEquals(connectorPair3, entry3.getConnectorPair());
+ assertEquals(connectorPair3, entry3);
assertFalse(listener1.called);
assertFalse(listener2.called);
listener1.called = false;
@@ -682,21 +694,21 @@
assertTrue(ok);
entryMap = dg.getDiscoveryEntryMap();
assertNotNull(entryMap);
- assertEquals(3, entryMap.size());
- entry1 = entryMap.get(node1);
+ assertEquals(3, entryMap.size());
+ entry1 = entryMap.get(node1);
assertNotNull(entry1);
- assertEquals(connectorPair1, entry1.getConnectorPair());
- entry2 = entryMap.get(node2);
+ assertEquals(connectorPair1, entry1);
+ entry2 = entryMap.get(node2);
assertNotNull(entry2);
- assertEquals(connectorPair2, entry2.getConnectorPair());
- entry3 = entryMap.get(node3);
+ assertEquals(connectorPair2, entry2);
+ entry3 = entryMap.get(node3);
assertNotNull(entry3);
- assertEquals(connectorPair3, entry3.getConnectorPair());
+ assertEquals(connectorPair3, entry3);
assertFalse(listener1.called);
assertFalse(listener2.called);
listener1.called = false;
listener2.called = false;
-
+
bg2.removeConnectorPair(connectorPair2);
bg2.broadcastConnectors();
ok = dg.waitForBroadcast(1000);
@@ -706,17 +718,17 @@
entryMap = dg.getDiscoveryEntryMap();
assertNotNull(entryMap);
- assertEquals(3, entryMap.size());
- entry1 = entryMap.get(node1);
+ assertEquals(3, entryMap.size());
+ entry1 = entryMap.get(node1);
assertNotNull(entry1);
- assertEquals(connectorPair1, entry1.getConnectorPair());
- entry2 = entryMap.get(node2);
+ assertEquals(connectorPair1, entry1);
+ entry2 = entryMap.get(node2);
assertNotNull(entry2);
- assertEquals(connectorPair2, entry2.getConnectorPair());
- entry3 = entryMap.get(node3);
+ assertEquals(connectorPair2, entry2);
+ entry3 = entryMap.get(node3);
assertNotNull(entry3);
- assertEquals(connectorPair3, entry3.getConnectorPair());
-
+ assertEquals(connectorPair3, entry3);
+
assertFalse(listener1.called);
assertFalse(listener2.called);
listener1.called = false;
@@ -733,14 +745,14 @@
entryMap = dg.getDiscoveryEntryMap();
assertNotNull(entryMap);
- assertEquals(2, entryMap.size());
- entry1 = entryMap.get(node1);
+ assertEquals(2, entryMap.size());
+ entry1 = entryMap.get(node1);
assertNotNull(entry1);
- assertEquals(connectorPair1, entry1.getConnectorPair());
- entry3 = entryMap.get(node3);
+ assertEquals(connectorPair1, entry1);
+ entry3 = entryMap.get(node3);
assertNotNull(entry3);
- assertEquals(connectorPair3, entry3.getConnectorPair());
-
+ assertEquals(connectorPair3, entry3);
+
assertTrue(listener1.called);
assertTrue(listener2.called);
listener1.called = false;
@@ -760,7 +772,7 @@
entryMap = dg.getDiscoveryEntryMap();
assertNotNull(entryMap);
- assertEquals(0, entryMap.size());
+ assertEquals(0, entryMap.size());
assertTrue(listener1.called);
assertTrue(listener2.called);
listener1.called = false;
@@ -775,7 +787,7 @@
entryMap = dg.getDiscoveryEntryMap();
assertNotNull(entryMap);
- assertEquals(0, entryMap.size());
+ assertEquals(0, entryMap.size());
assertFalse(listener1.called);
assertFalse(listener2.called);
@@ -791,7 +803,7 @@
final InetAddress groupAddress = InetAddress.getByName(address1);
final int groupPort = 6745;
final int timeout = 500;
-
+
String nodeID = randomString();
BroadcastGroup bg = new BroadcastGroupImpl(nodeID, randomString(), null, -1, groupAddress, groupPort, true);
@@ -805,7 +817,6 @@
backup1);
bg.addConnectorPair(connectorPair1);
-
DiscoveryGroup dg1 = new DiscoveryGroupImpl(randomString(), randomString(), groupAddress, groupPort, timeout);
@@ -821,32 +832,31 @@
boolean ok = dg1.waitForBroadcast(1000);
assertTrue(ok);
- Map<String, DiscoveryEntry> entryMap = dg1.getDiscoveryEntryMap();
+ Map<String, Pair<TransportConfiguration, TransportConfiguration>> entryMap = dg1.getDiscoveryEntryMap();
assertNotNull(entryMap);
assertEquals(1, entryMap.size());
- DiscoveryEntry entry = entryMap.get(nodeID);
+ Pair<TransportConfiguration, TransportConfiguration> entry = entryMap.get(nodeID);
assertNotNull(entry);
- assertEquals(connectorPair1, entry.getConnectorPair());
+ assertEquals(connectorPair1, entry);
ok = dg2.waitForBroadcast(1000);
assertTrue(ok);
entryMap = dg2.getDiscoveryEntryMap();
assertNotNull(entryMap);
assertEquals(1, entryMap.size());
- entry = entryMap.get(nodeID);
+ entry = entryMap.get(nodeID);
assertNotNull(entry);
- assertEquals(connectorPair1, entry.getConnectorPair());
-
-
+ assertEquals(connectorPair1, entry);
+
ok = dg3.waitForBroadcast(1000);
assertTrue(ok);
entryMap = dg3.getDiscoveryEntryMap();
assertNotNull(entryMap);
assertEquals(1, entryMap.size());
- entry = entryMap.get(nodeID);
+ entry = entryMap.get(nodeID);
assertNotNull(entry);
- assertEquals(connectorPair1, entry.getConnectorPair());
-
+ assertEquals(connectorPair1, entry);
+
bg.stop();
dg1.stop();
Modified: branches/Branch_MultiThreaded_Replication/tests/src/org/jboss/messaging/tests/integration/paging/PageCrashTest.java
===================================================================
--- branches/Branch_MultiThreaded_Replication/tests/src/org/jboss/messaging/tests/integration/paging/PageCrashTest.java 2009-08-06 08:44:47 UTC (rev 7669)
+++ branches/Branch_MultiThreaded_Replication/tests/src/org/jboss/messaging/tests/integration/paging/PageCrashTest.java 2009-08-06 08:56:53 UTC (rev 7670)
@@ -36,19 +36,25 @@
import org.jboss.messaging.core.client.ClientSession;
import org.jboss.messaging.core.client.ClientSessionFactory;
import org.jboss.messaging.core.config.Configuration;
+import org.jboss.messaging.core.journal.SequentialFileFactory;
import org.jboss.messaging.core.paging.Page;
import org.jboss.messaging.core.paging.PagedMessage;
import org.jboss.messaging.core.paging.PagingManager;
import org.jboss.messaging.core.paging.PagingStore;
+import org.jboss.messaging.core.paging.PagingStoreFactory;
import org.jboss.messaging.core.paging.impl.PagingManagerImpl;
import org.jboss.messaging.core.paging.impl.PagingStoreFactoryNIO;
import org.jboss.messaging.core.paging.impl.PagingStoreImpl;
+import org.jboss.messaging.core.persistence.StorageManager;
+import org.jboss.messaging.core.postoffice.PostOffice;
import org.jboss.messaging.core.security.JBMSecurityManager;
import org.jboss.messaging.core.security.impl.JBMSecurityManagerImpl;
+import org.jboss.messaging.core.server.ChannelManager;
import org.jboss.messaging.core.server.MessagingServer;
import org.jboss.messaging.core.server.impl.MessagingServerImpl;
import org.jboss.messaging.core.settings.impl.AddressSettings;
import org.jboss.messaging.tests.util.ServiceTestBase;
+import org.jboss.messaging.utils.ExecutorFactory;
import org.jboss.messaging.utils.OrderedExecutorFactory;
import org.jboss.messaging.utils.SimpleString;
@@ -270,7 +276,7 @@
*/
public FailurePagingStoreFactoryNIO(final String directory)
{
- super(directory, new OrderedExecutorFactory(Executors.newCachedThreadPool()));
+ super(directory, new OrderedExecutorFactory(Executors.newCachedThreadPool()), null, null);
}
// Constants -----------------------------------------------------
@@ -290,7 +296,7 @@
factoryField.setAccessible(true);
OrderedExecutorFactory factory = (org.jboss.messaging.utils.OrderedExecutorFactory)factoryField.get(this);
- return new FailingPagingStore(destinationName, settings, factory.getExecutor());
+ return new FailingPagingStore(destinationName, settings, factory);
}
// Package protected ---------------------------------------------
@@ -310,7 +316,7 @@
*/
public FailingPagingStore(final SimpleString storeName,
final AddressSettings addressSettings,
- final Executor executor)
+ final ExecutorFactory executorFactory) throws Exception
{
super(getPostOffice().getPagingManager(),
getStorageManager(),
@@ -319,7 +325,9 @@
FailurePagingStoreFactoryNIO.this,
storeName,
addressSettings,
- executor);
+ executorFactory,
+ null,
+ null);
}
@Override
Modified: branches/Branch_MultiThreaded_Replication/tests/src/org/jboss/messaging/tests/timing/core/server/impl/QueueImplTest.java
===================================================================
--- branches/Branch_MultiThreaded_Replication/tests/src/org/jboss/messaging/tests/timing/core/server/impl/QueueImplTest.java 2009-08-06 08:44:47 UTC (rev 7669)
+++ branches/Branch_MultiThreaded_Replication/tests/src/org/jboss/messaging/tests/timing/core/server/impl/QueueImplTest.java 2009-08-06 08:56:53 UTC (rev 7670)
@@ -53,35 +53,46 @@
public void setUp() throws Exception
{
- super.setUp();
+ super.setUp();
- scheduledExecutor = new ScheduledThreadPoolExecutor(1);
+ scheduledExecutor = new ScheduledThreadPoolExecutor(1);
}
public void tearDown() throws Exception
{
- scheduledExecutor.shutdownNow();
+ scheduledExecutor.shutdownNow();
super.tearDown();
}
// The tests ----------------------------------------------------------------
- public void testScheduledDirect() throws Exception
+ public void testScheduledDirect() throws Exception
{
testScheduled(true);
}
- public void testScheduledQueueing() throws Exception
+ public void testScheduledQueueing() throws Exception
{
testScheduled(false);
}
public void testScheduledNoConsumer() throws Exception
{
- Queue queue = new QueueImpl(1, new SimpleString("address1"), new SimpleString("queue1"), null, false, true, scheduledExecutor, null, null, null);
+ Queue queue = new QueueImpl(1,
+ new SimpleString("address1"),
+ new SimpleString("queue1"),
+ null,
+ false,
+ true,
+ scheduledExecutor,
+ null,
+ null,
+ null,
+ null,
+ null);
- //Send one scheduled
+ // Send one scheduled
long now = System.currentTimeMillis();
@@ -89,7 +100,7 @@
ref1.setScheduledDeliveryTime(now + 7000);
queue.addLast(ref1);
- //Send some non scheduled messages
+ // Send some non scheduled messages
MessageReference ref2 = generateReference(queue, 2);
queue.addLast(ref2);
@@ -98,9 +109,8 @@
MessageReference ref4 = generateReference(queue, 4);
queue.addLast(ref4);
+ // Now send some more scheduled messages
- //Now send some more scheduled messages
-
MessageReference ref5 = generateReference(queue, 5);
ref5.setScheduledDeliveryTime(now + 5000);
queue.addLast(ref5);
@@ -119,8 +129,8 @@
List<MessageReference> refs = new ArrayList<MessageReference>();
- //Scheduled refs are added back to *FRONT* of queue - otherwise if there were many messages in the queue
- //They may get stranded behind a big backlog
+ // Scheduled refs are added back to *FRONT* of queue - otherwise if there were many messages in the queue
+ // They may get stranded behind a big backlog
refs.add(ref1);
refs.add(ref8);
@@ -138,14 +148,25 @@
queue.addConsumer(consumer);
- queue.deliverNow();
+ queue.deliverAll();
assertRefListsIdenticalRefs(refs, consumer.getReferences());
}
private void testScheduled(boolean direct) throws Exception
{
- Queue queue = new QueueImpl(1,new SimpleString("address1"), new SimpleString("queue1"), null, false, true, scheduledExecutor, null, null, null);
+ Queue queue = new QueueImpl(1,
+ new SimpleString("address1"),
+ new SimpleString("queue1"),
+ null,
+ false,
+ true,
+ scheduledExecutor,
+ null,
+ null,
+ null,
+ null,
+ null);
FakeConsumer consumer = null;
@@ -156,7 +177,7 @@
queue.addConsumer(consumer);
}
- //Send one scheduled
+ // Send one scheduled
long now = System.currentTimeMillis();
@@ -164,7 +185,7 @@
ref1.setScheduledDeliveryTime(now + 7000);
queue.addLast(ref1);
- //Send some non scheduled messages
+ // Send some non scheduled messages
MessageReference ref2 = generateReference(queue, 2);
queue.addLast(ref2);
@@ -173,9 +194,8 @@
MessageReference ref4 = generateReference(queue, 4);
queue.addLast(ref4);
+ // Now send some more scheduled messages
- //Now send some more scheduled messages
-
MessageReference ref5 = generateReference(queue, 5);
ref5.setScheduledDeliveryTime(now + 5000);
queue.addLast(ref5);
@@ -198,7 +218,7 @@
queue.addConsumer(consumer);
- queue.deliverNow();
+ queue.deliverAll();
}
List<MessageReference> refs = new ArrayList<MessageReference>();
@@ -252,7 +272,18 @@
return HandleStatus.HANDLED;
}
};
- Queue queue = new QueueImpl(1, new SimpleString("address1"), queue1, null, false, true, scheduledExecutor, null, null, null);
+ Queue queue = new QueueImpl(1,
+ new SimpleString("address1"),
+ queue1,
+ null,
+ false,
+ true,
+ scheduledExecutor,
+ null,
+ null,
+ null,
+ null,
+ null);
MessageReference messageReference = generateReference(queue, 1);
queue.addConsumer(consumer);
messageReference.setScheduledDeliveryTime(System.currentTimeMillis() + 2000);
Modified: branches/Branch_MultiThreaded_Replication/tests/src/org/jboss/messaging/tests/unit/core/paging/impl/PagingManagerImplTest.java
===================================================================
--- branches/Branch_MultiThreaded_Replication/tests/src/org/jboss/messaging/tests/unit/core/paging/impl/PagingManagerImplTest.java 2009-08-06 08:44:47 UTC (rev 7669)
+++ branches/Branch_MultiThreaded_Replication/tests/src/org/jboss/messaging/tests/unit/core/paging/impl/PagingManagerImplTest.java 2009-08-06 08:56:53 UTC (rev 7670)
@@ -69,7 +69,8 @@
HierarchicalRepository<AddressSettings> addressSettings = new HierarchicalObjectRepository<AddressSettings>();
addressSettings.setDefault(new AddressSettings());
- PagingManagerImpl managerImpl = new PagingManagerImpl(new PagingStoreFactoryNIO(getPageDir(), new OrderedExecutorFactory(Executors.newCachedThreadPool())),
+ PagingManagerImpl managerImpl = new PagingManagerImpl(new PagingStoreFactoryNIO(getPageDir(), new OrderedExecutorFactory(Executors.newCachedThreadPool()),
+ null, null),
new NullStorageManager(),
addressSettings,
-1,
Modified: branches/Branch_MultiThreaded_Replication/tests/src/org/jboss/messaging/tests/unit/core/paging/impl/PagingStoreImplTest.java
===================================================================
--- branches/Branch_MultiThreaded_Replication/tests/src/org/jboss/messaging/tests/unit/core/paging/impl/PagingStoreImplTest.java 2009-08-06 08:44:47 UTC (rev 7669)
+++ branches/Branch_MultiThreaded_Replication/tests/src/org/jboss/messaging/tests/unit/core/paging/impl/PagingStoreImplTest.java 2009-08-06 08:56:53 UTC (rev 7670)
@@ -68,6 +68,8 @@
import org.jboss.messaging.tests.unit.core.server.impl.fakes.FakePostOffice;
import org.jboss.messaging.tests.util.RandomUtil;
import org.jboss.messaging.tests.util.UnitTestCase;
+import org.jboss.messaging.utils.ExecutorFactory;
+import org.jboss.messaging.utils.OrderedExecutorFactory;
import org.jboss.messaging.utils.Pair;
import org.jboss.messaging.utils.SimpleString;
import org.jboss.messaging.utils.UUID;
@@ -86,8 +88,10 @@
// Attributes ----------------------------------------------------
+ protected ExecutorFactory executorFactory;
+
protected ExecutorService executor;
-
+
// Static --------------------------------------------------------
// Constructors --------------------------------------------------
@@ -152,7 +156,7 @@
null,
destinationTestName,
new AddressSettings(),
- executor);
+ executorFactory, null, null);
storeImpl.start();
@@ -188,7 +192,7 @@
storeFactory,
destinationTestName,
new AddressSettings(),
- executor);
+ executorFactory, null, null);
storeImpl.start();
@@ -222,7 +226,7 @@
null,
destinationTestName,
new AddressSettings(),
- executor);
+ executorFactory, null, null);
storeImpl.start();
@@ -245,7 +249,7 @@
storeFactory,
destinationTestName,
new AddressSettings(),
- executor);
+ executorFactory, null, null);
storeImpl.start();
@@ -308,7 +312,7 @@
storeFactory,
destinationTestName,
new AddressSettings(),
- executor);
+ executorFactory, null, null);
storeImpl.start();
@@ -449,7 +453,7 @@
storeFactory,
new SimpleString("test"),
settings,
- executor);
+ executorFactory, null, null);
storeImpl.start();
@@ -604,7 +608,7 @@
storeFactory,
new SimpleString("test"),
settings,
- executor);
+ executorFactory, null, null);
storeImpl2.start();
int numberOfPages = storeImpl2.getNumberOfPages();
@@ -714,7 +718,8 @@
protected void setUp() throws Exception
{
super.setUp();
- executor = Executors.newSingleThreadExecutor();
+ executor = Executors.newCachedThreadPool();
+ executorFactory = new OrderedExecutorFactory(executor);
}
@Override
@@ -729,6 +734,12 @@
class FakePagingManager implements PagingManager
{
+ public PagingStore getPageStoreNoCreate(SimpleString address) throws Exception
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
public void activate()
{
}
Modified: branches/Branch_MultiThreaded_Replication/tests/src/org/jboss/messaging/tests/unit/core/postoffice/impl/BindingImplTest.java
===================================================================
--- branches/Branch_MultiThreaded_Replication/tests/src/org/jboss/messaging/tests/unit/core/postoffice/impl/BindingImplTest.java 2009-08-06 08:44:47 UTC (rev 7669)
+++ branches/Branch_MultiThreaded_Replication/tests/src/org/jboss/messaging/tests/unit/core/postoffice/impl/BindingImplTest.java 2009-08-06 08:56:53 UTC (rev 7670)
@@ -41,9 +41,11 @@
import org.jboss.messaging.core.server.Bindable;
import org.jboss.messaging.core.server.Consumer;
import org.jboss.messaging.core.server.Distributor;
+import org.jboss.messaging.core.server.HandleStatus;
import org.jboss.messaging.core.server.MessageReference;
import org.jboss.messaging.core.server.Queue;
import org.jboss.messaging.core.server.ServerMessage;
+import org.jboss.messaging.core.server.replication.Replicator;
import org.jboss.messaging.core.transaction.Transaction;
import org.jboss.messaging.core.transaction.TransactionOperation;
import org.jboss.messaging.tests.util.UnitTestCase;
@@ -1025,6 +1027,54 @@
class FakeQueue implements Queue
{
+ public void addRedistributor(long delay, Executor executor)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void close()
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void deliverAll()
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void deliverAsync()
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public HandleStatus deliverOne()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public Replicator getReplicator()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public void lock()
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void unlock()
+ {
+ // TODO Auto-generated method stub
+
+ }
+
private SimpleString name;
FakeQueue(SimpleString name)
Modified: branches/Branch_MultiThreaded_Replication/tests/src/org/jboss/messaging/tests/unit/core/server/impl/QueueImplTest.java
===================================================================
--- branches/Branch_MultiThreaded_Replication/tests/src/org/jboss/messaging/tests/unit/core/server/impl/QueueImplTest.java 2009-08-06 08:44:47 UTC (rev 7669)
+++ branches/Branch_MultiThreaded_Replication/tests/src/org/jboss/messaging/tests/unit/core/server/impl/QueueImplTest.java 2009-08-06 08:56:53 UTC (rev 7670)
@@ -22,15 +22,17 @@
package org.jboss.messaging.tests.unit.core.server.impl;
-
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.Executor;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import org.jboss.messaging.core.filter.Filter;
+import org.jboss.messaging.core.persistence.StorageManager;
+import org.jboss.messaging.core.postoffice.PostOffice;
import org.jboss.messaging.core.server.Consumer;
import org.jboss.messaging.core.server.Distributor;
import org.jboss.messaging.core.server.HandleStatus;
@@ -39,6 +41,9 @@
import org.jboss.messaging.core.server.ServerMessage;
import org.jboss.messaging.core.server.impl.QueueImpl;
import org.jboss.messaging.core.server.impl.RoundRobinDistributor;
+import org.jboss.messaging.core.server.replication.Replicator;
+import org.jboss.messaging.core.settings.HierarchicalRepository;
+import org.jboss.messaging.core.settings.impl.AddressSettings;
import org.jboss.messaging.tests.unit.core.server.impl.fakes.FakeConsumer;
import org.jboss.messaging.tests.unit.core.server.impl.fakes.FakeFilter;
import org.jboss.messaging.tests.unit.core.server.impl.fakes.FakePostOffice;
@@ -60,38 +65,33 @@
private static final SimpleString address1 = new SimpleString("address1");
- public void testID()
- {
- final long id = 123;
-
- Queue queue = new QueueImpl(id, address1, queue1, null, false, true, scheduledExecutor, null, null, null);
-
- assertEquals(id, queue.getID());
-
- final long id2 = 456;
-
- queue.setPersistenceID(id2);
-
- assertEquals(id2, queue.getID());
- }
-
public void testName()
{
final SimpleString name = new SimpleString("oobblle");
- Queue queue = new QueueImpl(1, address1, name, null, false, true, scheduledExecutor, null, null, null);
+ Queue queue = new QueueImpl(1, address1, name, null, false, true, scheduledExecutor, null, null, null, null, null);
assertEquals(name, queue.getName());
}
-
public void testDurable()
{
- Queue queue = new QueueImpl(1, address1, queue1, null, false, false, scheduledExecutor, null, null, null);
+ Queue queue = new QueueImpl(1,
+ address1,
+ queue1,
+ null,
+ false,
+ false,
+ scheduledExecutor,
+ null,
+ null,
+ null,
+ null,
+ null);
assertFalse(queue.isDurable());
- queue = new QueueImpl(1, address1, queue1, null, true, false, scheduledExecutor, null, null, null);
+ queue = new QueueImpl(1, address1, queue1, null, true, false, scheduledExecutor, null, null, null, null, null);
assertTrue(queue.isDurable());
}
@@ -104,7 +104,18 @@
Consumer cons3 = new FakeConsumer();
- Queue queue = new QueueImpl(1, address1, queue1, null, false, true, scheduledExecutor, null, null, null);
+ Queue queue = new QueueImpl(1,
+ address1,
+ queue1,
+ null,
+ false,
+ true,
+ scheduledExecutor,
+ null,
+ null,
+ null,
+ null,
+ null);
assertEquals(0, queue.getConsumerCount());
@@ -145,7 +156,18 @@
public void testGetSetDistributionPolicy()
{
- Queue queue = new QueueImpl(1, address1, queue1, null, false, true, scheduledExecutor, null, null, null);
+ Queue queue = new QueueImpl(1,
+ address1,
+ queue1,
+ null,
+ false,
+ true,
+ scheduledExecutor,
+ null,
+ null,
+ null,
+ null,
+ null);
assertNotNull(queue.getDistributionPolicy());
@@ -160,7 +182,18 @@
public void testGetFilter()
{
- Queue queue = new QueueImpl(1, address1, queue1, null, false, true, scheduledExecutor, null, null, null);
+ Queue queue = new QueueImpl(1,
+ address1,
+ queue1,
+ null,
+ false,
+ true,
+ scheduledExecutor,
+ null,
+ null,
+ null,
+ null,
+ null);
assertNull(queue.getFilter());
@@ -177,7 +210,7 @@
}
};
- queue = new QueueImpl(1, address1, queue1, filter, false, true, scheduledExecutor, null, null, null);
+ queue = new QueueImpl(1, address1, queue1, filter, false, true, scheduledExecutor, null, null, null, null, null);
assertEquals(filter, queue.getFilter());
@@ -185,7 +218,18 @@
public void testSimpleadd()
{
- Queue queue = new QueueImpl(1, address1, queue1, null, false, true, scheduledExecutor, null, null, null);
+ Queue queue = new QueueImpl(1,
+ address1,
+ queue1,
+ null,
+ false,
+ true,
+ scheduledExecutor,
+ null,
+ null,
+ null,
+ null,
+ null);
final int numMessages = 10;
@@ -202,9 +246,20 @@
}
- public void testSimpleDirectDelivery() throws Exception
+ public void testSimpleDirectDelivery() throws Exception
{
- Queue queue = new QueueImpl(1, address1, queue1, null, false, true, scheduledExecutor, null, null, null);
+ Queue queue = new QueueImpl(1,
+ address1,
+ queue1,
+ null,
+ false,
+ true,
+ scheduledExecutor,
+ null,
+ null,
+ null,
+ null,
+ null);
FakeConsumer consumer = new FakeConsumer();
@@ -230,9 +285,20 @@
assertRefListsIdenticalRefs(refs, consumer.getReferences());
}
- public void testSimpleNonDirectDelivery() throws Exception
+ public void testSimpleNonDirectDelivery() throws Exception
{
- Queue queue = new QueueImpl(1, address1, queue1, null, false, true, scheduledExecutor, null, null, null);
+ Queue queue = new QueueImpl(1,
+ address1,
+ queue1,
+ null,
+ false,
+ true,
+ scheduledExecutor,
+ null,
+ null,
+ null,
+ null,
+ null);
final int numMessages = 10;
@@ -251,7 +317,7 @@
assertEquals(0, queue.getScheduledCount());
assertEquals(0, queue.getDeliveringCount());
- //Now add a consumer
+ // Now add a consumer
FakeConsumer consumer = new FakeConsumer();
queue.addConsumer(consumer);
@@ -260,7 +326,7 @@
assertEquals(10, queue.getMessageCount());
assertEquals(0, queue.getScheduledCount());
- queue.deliverNow();
+ queue.deliverAll();
assertRefListsIdenticalRefs(refs, consumer.getReferences());
assertEquals(numMessages, queue.getMessageCount());
@@ -268,9 +334,20 @@
assertEquals(numMessages, queue.getDeliveringCount());
}
- public void testBusyConsumer() throws Exception
+ public void testBusyConsumer() throws Exception
{
- Queue queue = new QueueImpl(1, address1, queue1, null, false, true, scheduledExecutor, null, null, null);
+ Queue queue = new QueueImpl(1,
+ address1,
+ queue1,
+ null,
+ false,
+ true,
+ scheduledExecutor,
+ null,
+ null,
+ null,
+ null,
+ null);
FakeConsumer consumer = new FakeConsumer();
@@ -295,7 +372,7 @@
assertEquals(0, queue.getScheduledCount());
assertEquals(0, queue.getDeliveringCount());
- queue.deliverNow();
+ queue.deliverAll();
assertEquals(10, queue.getMessageCount());
assertEquals(0, queue.getScheduledCount());
@@ -304,7 +381,7 @@
consumer.setStatusImmediate(HandleStatus.HANDLED);
- queue.deliverNow();
+ queue.deliverAll();
assertRefListsIdenticalRefs(refs, consumer.getReferences());
assertEquals(10, queue.getMessageCount());
@@ -314,7 +391,18 @@
public void testBusyConsumerThenAddMoreMessages() throws Exception
{
- Queue queue = new QueueImpl(1, address1, queue1, null, false, true, scheduledExecutor, null, null, null);
+ Queue queue = new QueueImpl(1,
+ address1,
+ queue1,
+ null,
+ false,
+ true,
+ scheduledExecutor,
+ null,
+ null,
+ null,
+ null,
+ null);
FakeConsumer consumer = new FakeConsumer();
@@ -339,7 +427,7 @@
assertEquals(0, queue.getScheduledCount());
assertEquals(0, queue.getDeliveringCount());
- queue.deliverNow();
+ queue.deliverAll();
assertEquals(10, queue.getMessageCount());
assertEquals(0, queue.getScheduledCount());
@@ -371,7 +459,7 @@
queue.addLast(ref);
}
- queue.deliverNow();
+ queue.deliverAll();
assertRefListsIdenticalRefs(refs, consumer.getReferences());
assertEquals(30, queue.getMessageCount());
@@ -381,7 +469,18 @@
public void testAddFirstadd() throws Exception
{
- Queue queue = new QueueImpl(1, address1, queue1, null, false, true, scheduledExecutor, null, null, null);
+ Queue queue = new QueueImpl(1,
+ address1,
+ queue1,
+ null,
+ false,
+ true,
+ scheduledExecutor,
+ null,
+ null,
+ null,
+ null,
+ null);
final int numMessages = 10;
@@ -422,7 +521,7 @@
queue.addConsumer(consumer);
- queue.deliverNow();
+ queue.deliverAll();
List<MessageReference> allRefs = new ArrayList<MessageReference>();
@@ -433,10 +532,20 @@
assertRefListsIdenticalRefs(allRefs, consumer.getReferences());
}
-
public void testChangeConsumersAndDeliver() throws Exception
{
- Queue queue = new QueueImpl(1, address1, queue1, null, false, true, scheduledExecutor, new FakePostOffice(), null, null);
+ Queue queue = new QueueImpl(1,
+ address1,
+ queue1,
+ null,
+ false,
+ true,
+ scheduledExecutor,
+ new FakePostOffice(),
+ null,
+ null,
+ null,
+ null);
final int numMessages = 10;
@@ -459,7 +568,7 @@
queue.addConsumer(cons1);
- queue.deliverNow();
+ queue.deliverAll();
assertEquals(numMessages, queue.getMessageCount());
assertEquals(0, queue.getScheduledCount());
@@ -590,7 +699,18 @@
public void testConsumerReturningNull() throws Exception
{
- Queue queue = new QueueImpl(1, address1, queue1, null, false, true, scheduledExecutor, null, null, null);
+ Queue queue = new QueueImpl(1,
+ address1,
+ queue1,
+ null,
+ false,
+ true,
+ scheduledExecutor,
+ null,
+ null,
+ null,
+ null,
+ null);
class NullConsumer implements Consumer
{
@@ -617,13 +737,24 @@
}
catch (IllegalStateException e)
{
- //Ok
+ // Ok
}
}
public void testRoundRobinWithQueueing() throws Exception
{
- Queue queue = new QueueImpl(1, address1, queue1, null, false, true, scheduledExecutor, null, null, null);
+ Queue queue = new QueueImpl(1,
+ address1,
+ queue1,
+ null,
+ false,
+ true,
+ scheduledExecutor,
+ null,
+ null,
+ null,
+ null,
+ null);
assertTrue(queue.getDistributionPolicy() instanceof RoundRobinDistributor);
@@ -631,7 +762,7 @@
List<MessageReference> refs = new ArrayList<MessageReference>();
- //Test first with queueing
+ // Test first with queueing
for (int i = 0; i < numMessages; i++)
{
@@ -650,7 +781,7 @@
queue.addConsumer(cons2);
- queue.deliverNow();
+ queue.deliverAll();
assertEquals(numMessages / 2, cons1.getReferences().size());
@@ -668,7 +799,18 @@
public void testRoundRobinDirect() throws Exception
{
- Queue queue = new QueueImpl(1, address1, queue1, null, false, true, scheduledExecutor, null, null, null);
+ Queue queue = new QueueImpl(1,
+ address1,
+ queue1,
+ null,
+ false,
+ true,
+ scheduledExecutor,
+ null,
+ null,
+ null,
+ null,
+ null);
assertTrue(queue.getDistributionPolicy() instanceof RoundRobinDistributor);
@@ -684,7 +826,7 @@
queue.addConsumer(cons2);
- queue.deliverNow();
+ queue.deliverAll();
for (int i = 0; i < numMessages; i++)
{
@@ -711,7 +853,18 @@
public void testWithPriorities() throws Exception
{
- Queue queue = new QueueImpl(1, address1, queue1, null, false, true, scheduledExecutor, null, null, null);
+ Queue queue = new QueueImpl(1,
+ address1,
+ queue1,
+ null,
+ false,
+ true,
+ scheduledExecutor,
+ null,
+ null,
+ null,
+ null,
+ null);
final int numMessages = 10;
@@ -721,7 +874,7 @@
{
MessageReference ref = generateReference(queue, i);
- ref.getMessage().setPriority((byte) i);
+ ref.getMessage().setPriority((byte)i);
refs.add(ref);
@@ -732,11 +885,11 @@
queue.addConsumer(consumer);
- queue.deliverNow();
+ queue.deliverAll();
List<MessageReference> receivedRefs = consumer.getReferences();
- //Should be in reverse order
+ // Should be in reverse order
assertEquals(refs.size(), receivedRefs.size());
@@ -745,8 +898,8 @@
assertEquals(refs.get(i), receivedRefs.get(9 - i));
}
- //But if we send more - since we are now in direct mode - the order will be the send order
- //since the refs don't get queued
+ // But if we send more - since we are now in direct mode - the order will be the send order
+ // since the refs don't get queued
consumer.clearReferences();
@@ -756,7 +909,7 @@
{
MessageReference ref = generateReference(queue, i);
- ref.getMessage().setPriority((byte) i);
+ ref.getMessage().setPriority((byte)i);
refs.add(ref);
@@ -778,7 +931,18 @@
public void testConsumerWithFilterAddAndRemove()
{
- Queue queue = new QueueImpl(1, address1, queue1, null, false, true, scheduledExecutor, null, null, null);
+ Queue queue = new QueueImpl(1,
+ address1,
+ queue1,
+ null,
+ false,
+ true,
+ scheduledExecutor,
+ null,
+ null,
+ null,
+ null,
+ null);
Filter filter = new FakeFilter("fruit", "orange");
@@ -787,7 +951,18 @@
public void testList()
{
- Queue queue = new QueueImpl(1, address1, queue1, null, false, true, scheduledExecutor, null, null, null);
+ Queue queue = new QueueImpl(1,
+ address1,
+ queue1,
+ null,
+ false,
+ true,
+ scheduledExecutor,
+ null,
+ null,
+ null,
+ null,
+ null);
final int numMessages = 20;
@@ -811,7 +986,18 @@
public void testListWithFilter()
{
- Queue queue = new QueueImpl(1, address1, queue1, null, false, true, scheduledExecutor, null, null, null);
+ Queue queue = new QueueImpl(1,
+ address1,
+ queue1,
+ null,
+ false,
+ true,
+ scheduledExecutor,
+ null,
+ null,
+ null,
+ null,
+ null);
final int numMessages = 20;
@@ -847,7 +1033,18 @@
public void testConsumeWithFiltersAddAndRemoveConsumer() throws Exception
{
- Queue queue = new QueueImpl(1, address1, queue1, null, false, true, scheduledExecutor, new FakePostOffice(), null, null);
+ Queue queue = new QueueImpl(1,
+ address1,
+ queue1,
+ null,
+ false,
+ true,
+ scheduledExecutor,
+ new FakePostOffice(),
+ null,
+ null,
+ null,
+ null);
Filter filter = new FakeFilter("fruit", "orange");
@@ -871,7 +1068,6 @@
refs.add(ref2);
-
assertEquals(2, queue.getMessageCount());
assertEquals(1, consumer.getReferences().size());
@@ -886,9 +1082,8 @@
queue.addConsumer(consumer);
- queue.deliverNow();
+ queue.deliverAll();
-
refs.clear();
consumer.clearReferences();
@@ -920,7 +1115,18 @@
private void testConsumerWithFilters(boolean direct) throws Exception
{
- Queue queue = new QueueImpl(1, address1, queue1, null, false, true, scheduledExecutor, new FakePostOffice(), null, null);
+ Queue queue = new QueueImpl(1,
+ address1,
+ queue1,
+ null,
+ false,
+ true,
+ scheduledExecutor,
+ new FakePostOffice(),
+ null,
+ null,
+ null,
+ Executors.newSingleThreadExecutor());
Filter filter = new FakeFilter("fruit", "orange");
@@ -977,7 +1183,7 @@
{
queue.addConsumer(consumer);
- queue.deliverNow();
+ queue.deliverAll();
}
assertEquals(6, queue.getMessageCount());
@@ -997,7 +1203,7 @@
queue.addConsumer(consumer);
- queue.deliverNow();
+ queue.deliverAll();
assertEquals(4, queue.getMessageCount());
@@ -1009,18 +1215,29 @@
public void testMessageOrder() throws Exception
{
FakeConsumer consumer = new FakeConsumer();
- Queue queue = new QueueImpl(1, address1, queue1, null, false, true, scheduledExecutor, null, null, null);
+ Queue queue = new QueueImpl(1,
+ address1,
+ queue1,
+ null,
+ false,
+ true,
+ scheduledExecutor,
+ null,
+ null,
+ null,
+ null,
+ null);
MessageReference messageReference = generateReference(queue, 1);
MessageReference messageReference2 = generateReference(queue, 2);
MessageReference messageReference3 = generateReference(queue, 3);
queue.addFirst(messageReference);
queue.addLast(messageReference2);
queue.addFirst(messageReference3);
-
+
assertEquals(0, consumer.getReferences().size());
queue.addConsumer(consumer);
- queue.deliverNow();
-
+ queue.deliverAll();
+
assertEquals(3, consumer.getReferences().size());
assertEquals(messageReference3, consumer.getReferences().get(0));
assertEquals(messageReference, consumer.getReferences().get(1));
@@ -1029,7 +1246,18 @@
public void testMessagesAdded() throws Exception
{
- Queue queue = new QueueImpl(1, address1, queue1, null, false, true, scheduledExecutor, null, null, null);
+ Queue queue = new QueueImpl(1,
+ address1,
+ queue1,
+ null,
+ false,
+ true,
+ scheduledExecutor,
+ null,
+ null,
+ null,
+ null,
+ null);
MessageReference messageReference = generateReference(queue, 1);
MessageReference messageReference2 = generateReference(queue, 2);
MessageReference messageReference3 = generateReference(queue, 3);
@@ -1039,10 +1267,20 @@
assertEquals(queue.getMessagesAdded(), 3);
}
-
public void testGetReference() throws Exception
{
- Queue queue = new QueueImpl(1, address1, queue1, null, false, true, scheduledExecutor, null, null, null);
+ Queue queue = new QueueImpl(1,
+ address1,
+ queue1,
+ null,
+ false,
+ true,
+ scheduledExecutor,
+ null,
+ null,
+ null,
+ null,
+ null);
MessageReference messageReference = generateReference(queue, 1);
MessageReference messageReference2 = generateReference(queue, 2);
MessageReference messageReference3 = generateReference(queue, 3);
@@ -1055,7 +1293,18 @@
public void testGetNonExistentReference() throws Exception
{
- Queue queue = new QueueImpl(1, address1, queue1, null, false, true, scheduledExecutor, null, null, null);
+ Queue queue = new QueueImpl(1,
+ address1,
+ queue1,
+ null,
+ false,
+ true,
+ scheduledExecutor,
+ null,
+ null,
+ null,
+ null,
+ null);
MessageReference messageReference = generateReference(queue, 1);
MessageReference messageReference2 = generateReference(queue, 2);
MessageReference messageReference3 = generateReference(queue, 3);
@@ -1066,16 +1315,22 @@
}
-
class AddtoQueueRunner implements Runnable
{
Queue queue;
+
MessageReference messageReference;
+
boolean added = false;
+
CountDownLatch countDownLatch;
+
boolean first;
- public AddtoQueueRunner(boolean first, Queue queue, MessageReference messageReference, CountDownLatch countDownLatch)
+ public AddtoQueueRunner(boolean first,
+ Queue queue,
+ MessageReference messageReference,
+ CountDownLatch countDownLatch)
{
this.queue = queue;
this.messageReference = messageReference;
@@ -1101,11 +1356,12 @@
class DummyDistributionPolicy implements Distributor
{
public List<Consumer> getConsumers()
- {
+ {
return null;
}
Consumer consumer;
+
public Consumer select(ServerMessage message, boolean redeliver)
{
return null;
@@ -1145,7 +1401,7 @@
public int getCurrentPosition()
{
- return 0;
+ return 0;
}
}
Modified: branches/Branch_MultiThreaded_Replication/tests/src/org/jboss/messaging/tests/unit/core/server/impl/fakes/FakePostOffice.java
===================================================================
--- branches/Branch_MultiThreaded_Replication/tests/src/org/jboss/messaging/tests/unit/core/server/impl/fakes/FakePostOffice.java 2009-08-06 08:44:47 UTC (rev 7669)
+++ branches/Branch_MultiThreaded_Replication/tests/src/org/jboss/messaging/tests/unit/core/server/impl/fakes/FakePostOffice.java 2009-08-06 08:56:53 UTC (rev 7670)
@@ -38,6 +38,12 @@
public class FakePostOffice implements PostOffice
{
+ public Binding getBindingByID(long id)
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
public Object getNotificationLock()
{
return null;
Modified: branches/Branch_MultiThreaded_Replication/tests/src/org/jboss/messaging/tests/unit/core/server/impl/fakes/FakeQueueFactory.java
===================================================================
--- branches/Branch_MultiThreaded_Replication/tests/src/org/jboss/messaging/tests/unit/core/server/impl/fakes/FakeQueueFactory.java 2009-08-06 08:44:47 UTC (rev 7669)
+++ branches/Branch_MultiThreaded_Replication/tests/src/org/jboss/messaging/tests/unit/core/server/impl/fakes/FakeQueueFactory.java 2009-08-06 08:56:53 UTC (rev 7670)
@@ -18,10 +18,11 @@
* 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.unit.core.server.impl.fakes;
+import java.util.concurrent.Executor;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
@@ -30,6 +31,7 @@
import org.jboss.messaging.core.server.Queue;
import org.jboss.messaging.core.server.QueueFactory;
import org.jboss.messaging.core.server.impl.QueueImpl;
+import org.jboss.messaging.core.server.replication.Replicator;
import org.jboss.messaging.utils.SimpleString;
/**
@@ -41,20 +43,37 @@
*/
public class FakeQueueFactory implements QueueFactory
{
- private final ScheduledExecutorService scheduledExecutor = Executors.newSingleThreadScheduledExecutor();
-
- private PostOffice postOffice;
+ private final ScheduledExecutorService scheduledExecutor = Executors.newSingleThreadScheduledExecutor();
- public Queue createQueue(long persistenceID, final SimpleString address, SimpleString name, Filter filter,
- boolean durable, boolean temporary)
- {
- return new QueueImpl(persistenceID, address, name, filter, durable, temporary, scheduledExecutor, postOffice, null, null);
- }
-
+ private PostOffice postOffice;
+
+ public Queue createQueue(long persistenceID,
+ final SimpleString address,
+ SimpleString name,
+ Filter filter,
+ boolean durable,
+ boolean temporary,
+ Replicator replicator,
+ Executor executor)
+ {
+ return new QueueImpl(persistenceID,
+ address,
+ name,
+ filter,
+ durable,
+ temporary,
+ scheduledExecutor,
+ postOffice,
+ null,
+ null,
+ replicator,
+ executor);
+ }
+
public void setPostOffice(PostOffice postOffice)
{
this.postOffice = postOffice;
-
+
}
}
Modified: branches/Branch_MultiThreaded_Replication/tests/src/org/jboss/messaging/tests/unit/core/server/replication/impl/QueuedWriteManagerTest.java
===================================================================
--- branches/Branch_MultiThreaded_Replication/tests/src/org/jboss/messaging/tests/unit/core/server/replication/impl/QueuedWriteManagerTest.java 2009-08-06 08:44:47 UTC (rev 7669)
+++ branches/Branch_MultiThreaded_Replication/tests/src/org/jboss/messaging/tests/unit/core/server/replication/impl/QueuedWriteManagerTest.java 2009-08-06 08:56:53 UTC (rev 7670)
@@ -679,14 +679,42 @@
public void replicationResponseReceived()
{
- // TODO Auto-generated method stub
+ // TODO Auto-generated method stub
}
+ public void close()
+ {
+ }
+
+ public Channel getReplicatingChannel()
+ {
+ return null;
+ }
+
+
}
private class DummyChannel implements Channel
{
+ public Thread getExecutingThread()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public void setFrozen(boolean frozen)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void waitForAllExecutions()
+ {
+ // TODO Auto-generated method stub
+
+ }
+
public void close()
{
// TODO Auto-generated method stub
Modified: branches/Branch_MultiThreaded_Replication/tests/src/org/jboss/messaging/tests/unit/core/server/replication/impl/SequencedLockTest.java
===================================================================
--- branches/Branch_MultiThreaded_Replication/tests/src/org/jboss/messaging/tests/unit/core/server/replication/impl/SequencedLockTest.java 2009-08-06 08:44:47 UTC (rev 7669)
+++ branches/Branch_MultiThreaded_Replication/tests/src/org/jboss/messaging/tests/unit/core/server/replication/impl/SequencedLockTest.java 2009-08-06 08:56:53 UTC (rev 7670)
@@ -48,7 +48,7 @@
for (int i = 0; i < 1000; i++)
{
// log.info("iter " + i);
- this.doTestSequences(true, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9);
+ this.doTestSequences(0, 1, 2, 3, 4, 5, 6, 7, 8, 9);
}
}
@@ -57,7 +57,7 @@
for (int i = 0; i < 1000; i++)
{
// log.info("iter " + i);
- this.doTestSequences(true, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0);
+ this.doTestSequences(9, 8, 7, 6, 5, 4, 3, 2, 1, 0);
}
}
@@ -66,7 +66,7 @@
for (int i = 0; i < 1000; i++)
{
// log.info("iter " + i);
- this.doTestSequences(true, 9, 0, 8, 1, 7, 2, 6, 3, 5, 4);
+ this.doTestSequences(9, 0, 8, 1, 7, 2, 6, 3, 5, 4);
}
}
@@ -75,49 +75,13 @@
for (int i = 0; i < 1000; i++)
{
// log.info("iter " + i);
- this.doTestSequences(true, 3, 9, 5, 7, 1, 2, 0, 8, 6, 4);
+ this.doTestSequences(3, 9, 5, 7, 1, 2, 0, 8, 6, 4);
}
}
- public void testAscendingNonStrict() throws Exception
- {
- for (int i = 0; i < 1000; i++)
- {
- // log.info("iter " + i);
- this.doTestSequences(false, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9);
- }
- }
-
- public void testDescendingNonStrict() throws Exception
- {
- for (int i = 0; i < 1000; i++)
- {
- // log.info("iter " + i);
- this.doTestSequences(false, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0);
- }
- }
-
- public void testAlternateNonStrict() throws Exception
- {
- for (int i = 0; i < 1000; i++)
- {
- // log.info("iter " + i);
- this.doTestSequences(false, 9, 0, 8, 1, 7, 2, 6, 3, 5, 4);
- }
- }
-
- public void testRandomNonStrict() throws Exception
- {
- for (int i = 0; i < 1000; i++)
- {
- // log.info("iter " + i);
- this.doTestSequences(false, 3, 9, 5, 7, 1, 2, 0, 8, 6, 4);
- }
- }
-
public void testSpeed() throws Exception
{
- SequencedLock lock = new SequencedLock(0);
+ SequencedLock lock = new SequencedLock(0, "blah", 0);
AtomicInteger counter = new AtomicInteger(0);
@@ -159,57 +123,7 @@
}
- public void testSpeedChangeNonStrict() throws Exception
- {
- SequencedLock lock = new SequencedLock(0);
-
- AtomicInteger counter = new AtomicInteger(0);
-
- AtomicInteger obcounter = new AtomicInteger(0);
-
- final int numThreads = 10;
-
- final int acquires = 10000;
-
- MyThread2[] threads = new MyThread2[numThreads];
-
- for (int i = 0; i < numThreads; i++)
- {
- threads[i] = new MyThread2(lock, acquires, counter, obcounter, false);
- }
-
- long start = System.currentTimeMillis();
-
- for (int i = 0; i < numThreads; i++)
- {
- threads[i].start();
- }
-
- // Thread.sleep(500);
-
- log.info("Setting non strict");
-
- lock.setNonStrict();
-
- for (int i = 0; i < numThreads; i++)
- {
- threads[i].join();
- }
-
- for (int i = 0; i < numThreads; i++)
- {
- assertNull(threads[i].exception);
- }
-
- log.info("done");
-
- long end = System.currentTimeMillis();
-
- double rate = 1000 * ((double)acquires * numThreads) / (end - start);
-
- System.out.println("Rate " + rate);
- }
-
+
class MyThread2 extends JBMThread
{
private int acquireCount;
@@ -274,15 +188,10 @@
}
}
- private void doTestSequences(final boolean strict, final int... sequences) throws Exception
+ private void doTestSequences(final int... sequences) throws Exception
{
- SequencedLock lock = new SequencedLock(0);
+ SequencedLock lock = new SequencedLock(0, "blah", 0);
- if (!strict)
- {
- lock.setNonStrict();
- }
-
AtomicInteger counter = new AtomicInteger(0);
MyThread[] threads = new MyThread[sequences.length];
@@ -307,13 +216,10 @@
assertNull(threads[i].exception);
}
- if (strict)
+ for (int i = 0; i < sequences.length; i++)
{
- for (int i = 0; i < sequences.length; i++)
- {
- assertEquals(sequences[i], threads[i].getObtainedSeq());
- }
- }
+ assertEquals(sequences[i], threads[i].getObtainedSeq());
+ }
}
class MyThread extends JBMThread
More information about the jboss-cvs-commits
mailing list