Author: ataylor
Date: 2011-02-16 12:56:44 -0500 (Wed, 16 Feb 2011)
New Revision: 10219
Modified:
branches/Branch_2_2_EAP/src/main/org/hornetq/core/client/impl/Topology.java
branches/Branch_2_2_EAP/src/main/org/hornetq/core/server/cluster/impl/ClusterManagerImpl.java
Log:
relaxed synching to avoid contention
Modified: branches/Branch_2_2_EAP/src/main/org/hornetq/core/client/impl/Topology.java
===================================================================
--- branches/Branch_2_2_EAP/src/main/org/hornetq/core/client/impl/Topology.java 2011-02-16
13:41:38 UTC (rev 10218)
+++ branches/Branch_2_2_EAP/src/main/org/hornetq/core/client/impl/Topology.java 2011-02-16
17:56:44 UTC (rev 10219)
@@ -88,12 +88,13 @@
return (member != null);
}
- public synchronized void fireListeners(ClusterTopologyListener listener)
+ public void sendTopology(ClusterTopologyListener listener)
{
int count = 0;
- for (Map.Entry<String, TopologyMember> entry : topology.entrySet())
+ Map<String, TopologyMember> copy = new HashMap<String,
TopologyMember>(topology);
+ for (Map.Entry<String, TopologyMember> entry : copy.entrySet())
{
- listener.nodeUP(entry.getKey(), entry.getValue().getConnector(), ++count ==
topology.size());
+ listener.nodeUP(entry.getKey(), entry.getValue().getConnector(), ++count ==
copy.size());
}
}
Modified:
branches/Branch_2_2_EAP/src/main/org/hornetq/core/server/cluster/impl/ClusterManagerImpl.java
===================================================================
---
branches/Branch_2_2_EAP/src/main/org/hornetq/core/server/cluster/impl/ClusterManagerImpl.java 2011-02-16
13:41:38 UTC (rev 10218)
+++
branches/Branch_2_2_EAP/src/main/org/hornetq/core/server/cluster/impl/ClusterManagerImpl.java 2011-02-16
17:56:44 UTC (rev 10219)
@@ -29,8 +29,6 @@
import org.hornetq.api.core.client.ClientSessionFactory;
import org.hornetq.api.core.client.ClusterTopologyListener;
import org.hornetq.api.core.client.HornetQClient;
-import org.hornetq.api.core.client.ServerLocator;
-import org.hornetq.core.client.impl.ServerLocatorImpl;
import org.hornetq.core.client.impl.ServerLocatorInternal;
import org.hornetq.core.client.impl.Topology;
import org.hornetq.core.client.impl.TopologyMember;
@@ -300,20 +298,23 @@
return clusterConnections.get(name.toString());
}
- public synchronized void addClusterTopologyListener(final ClusterTopologyListener
listener,
+ public void addClusterTopologyListener(final ClusterTopologyListener listener,
final boolean clusterConnection)
{
- if (clusterConnection)
+ synchronized (this)
{
- this.clusterConnectionListeners.add(listener);
+ if (clusterConnection)
+ {
+ this.clusterConnectionListeners.add(listener);
+ }
+ else
+ {
+ this.clientListeners.add(listener);
+ }
}
- else
- {
- this.clientListeners.add(listener);
- }
// We now need to send the current topology to the client
- topology.fireListeners(listener);
+ topology.sendTopology(listener);
}
public synchronized void removeClusterTopologyListener(final ClusterTopologyListener
listener,
Show replies by date