activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clebertsuco...@apache.org
Subject [2/4] activemq-artemis git commit: Topology executor should be final
Date Mon, 18 May 2015 15:45:16 GMT
Topology executor should be final


Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/3c6e213f
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/3c6e213f
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/3c6e213f

Branch: refs/heads/master
Commit: 3c6e213f66e661760aebb6902e298e56a84b2b75
Parents: 59e4f34
Author: Thiago Kronig <caa_tkronig@uolinc.com>
Authored: Wed May 13 21:07:23 2015 -0300
Committer: Thiago Kronig <thiagokronig@gmail.com>
Committed: Thu May 14 18:26:04 2015 -0300

----------------------------------------------------------------------
 .../artemis/core/client/impl/Topology.java      | 50 ++++++++++----------
 .../cluster/impl/ClusterConnectionImpl.java     |  6 +--
 2 files changed, 28 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/3c6e213f/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/Topology.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/Topology.java
b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/Topology.java
index 6dcb1a7..34b44b9 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/Topology.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/Topology.java
@@ -34,10 +34,9 @@ import org.apache.activemq.artemis.spi.core.remoting.Connector;
 public final class Topology
 {
 
+   private final Set<ClusterTopologyListener> topologyListeners;
 
-   private final Set<ClusterTopologyListener> topologyListeners = new HashSet<ClusterTopologyListener>();
-
-   private final Executor executor = null;
+   private final Executor executor;
 
    /**
     * Used to debug operations.
@@ -54,12 +53,31 @@ public final class Topology
     * keys are node IDs
     * values are a pair of live/backup transport configurations
     */
-   private final Map<String, TopologyMemberImpl> topology = new ConcurrentHashMap<String,
TopologyMemberImpl>();
+   private final Map<String, TopologyMemberImpl> topology;
 
    private Map<String, Long> mapDelete;
 
+   private static final class DirectExecutor implements Executor
+   {
+      public void execute(final Runnable runnable)
+      {
+         runnable.run();
+      }
+   }
    public Topology(final Object owner)
    {
+      this(owner, new DirectExecutor());
+   }
+
+   public Topology(final Object owner, final Executor executor)
+   {
+      this.topologyListeners = new HashSet<>();
+      this.topology = new ConcurrentHashMap<>();
+      if (executor == null)
+      {
+         throw new IllegalArgumentException("Executor is required");
+      }
+      this.executor = executor;
       this.owner = owner;
       if (ActiveMQClientLogger.LOGGER.isTraceEnabled())
       {
@@ -68,11 +86,6 @@ public final class Topology
       }
    }
 
-   public void setExecutor(final Executor executor)
-   {
-      this.executor = executor;
-   }
-
    /**
     * It will remove all elements as if it haven't received anyone from the server.
     */
@@ -271,7 +284,7 @@ public final class Topology
 
       if (copy.size() > 0)
       {
-         execute(new Runnable()
+         executor.execute(new Runnable()
          {
             public void run()
             {
@@ -351,7 +364,7 @@ public final class Topology
       {
          final ArrayList<ClusterTopologyListener> copy = copyListeners();
 
-         execute(new Runnable()
+         executor.execute(new Runnable()
          {
             public void run()
             {
@@ -372,23 +385,10 @@ public final class Topology
                }
             }
          });
-
       }
       return member != null;
    }
 
-   private void execute(final Runnable runnable)
-   {
-      if (executor != null)
-      {
-         executor.execute(runnable);
-      }
-      else
-      {
-         runnable.run();
-      }
-   }
-
    public synchronized void sendTopology(final ClusterTopologyListener listener)
    {
       if (ActiveMQClientLogger.LOGGER.isDebugEnabled())
@@ -396,7 +396,7 @@ public final class Topology
          ActiveMQClientLogger.LOGGER.debug(this + " is sending topology to " + listener);
       }
 
-      execute(new Runnable()
+      executor.execute(new Runnable()
       {
          public void run()
          {

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/3c6e213f/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/impl/ClusterConnectionImpl.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/impl/ClusterConnectionImpl.java
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/impl/ClusterConnectionImpl.java
index 43c7e45..2bd3cf4 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/impl/ClusterConnectionImpl.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/impl/ClusterConnectionImpl.java
@@ -151,7 +151,7 @@ public final class ClusterConnectionImpl implements ClusterConnection,
AfterConn
 
    // Stuff that used to be on the ClusterManager
 
-   private final Topology topology = new Topology(this);
+   private final Topology topology;
 
    private volatile boolean stopping = false;
 
@@ -228,7 +228,7 @@ public final class ClusterConnectionImpl implements ClusterConnection,
AfterConn
 
       this.executor = executorFactory.getExecutor();
 
-      this.topology.setExecutor(executor);
+      this.topology = new Topology(this, executor);
 
       this.server = server;
 
@@ -341,7 +341,7 @@ public final class ClusterConnectionImpl implements ClusterConnection,
AfterConn
 
       this.executor = executorFactory.getExecutor();
 
-      this.topology.setExecutor(executor);
+      this.topology = new Topology(this, executor);
 
       this.server = server;
 


Mime
View raw message