You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by cl...@apache.org on 2017/09/25 14:33:45 UTC

[1/2] activemq-artemis git commit: This closes #1546

Repository: activemq-artemis
Updated Branches:
  refs/heads/master bb8c11b1e -> d170639bf


This closes #1546


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

Branch: refs/heads/master
Commit: d170639bfedf95ec46c01f27fb622c940e4eef7c
Parents: bb8c11b 0010b0a
Author: Clebert Suconic <cl...@apache.org>
Authored: Mon Sep 25 10:33:56 2017 -0400
Committer: Clebert Suconic <cl...@apache.org>
Committed: Mon Sep 25 10:33:56 2017 -0400

----------------------------------------------------------------------
 .../core/client/impl/ServerLocatorImpl.java     |  4 +++-
 .../ActiveMQClientProtocolManagerFactory.java   |  6 +++++
 .../remoting/ClientProtocolManagerFactory.java  | 10 +++++++++
 .../HornetQClientProtocolManagerFactory.java    | 23 ++++++++++++++++++++
 ...ctiveMQServerSideProtocolManagerFactory.java |  6 +++++
 .../xa/recovery/XARecoveryConfig.java           |  6 ++++-
 6 files changed, 53 insertions(+), 2 deletions(-)
----------------------------------------------------------------------



[2/2] activemq-artemis git commit: [ARTMIS-1431] Adapt transport configuration in ClientProtocolManagerFactory

Posted by cl...@apache.org.
[ARTMIS-1431] Adapt transport configuration in ClientProtocolManagerFactory

add the adaptTransportConfiguration() method to the
ClientProtocolManagerFactory so that transport configurations used by
the ClientProtocolManager have an opportunity to adapt their transport
configuration.

This allows the HornetQClientProtocolManagerFactory to adapt the
transport configuration received by remote HornetQ broker to replace the
HornetQ-based NettyConnectorFactory by the Artemis-based one.

JIRA: https://issues.apache.org/jira/browse/ARTEMIS-1431


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

Branch: refs/heads/master
Commit: 0010b0a090487192edbacc881f31e0649a62e7f0
Parents: bb8c11b
Author: Jeff Mesnil <jm...@gmail.com>
Authored: Fri Sep 22 16:35:36 2017 +0200
Committer: Clebert Suconic <cl...@apache.org>
Committed: Mon Sep 25 10:33:56 2017 -0400

----------------------------------------------------------------------
 .../core/client/impl/ServerLocatorImpl.java     |  4 +++-
 .../ActiveMQClientProtocolManagerFactory.java   |  6 +++++
 .../remoting/ClientProtocolManagerFactory.java  | 10 +++++++++
 .../HornetQClientProtocolManagerFactory.java    | 23 ++++++++++++++++++++
 ...ctiveMQServerSideProtocolManagerFactory.java |  6 +++++
 .../xa/recovery/XARecoveryConfig.java           |  6 ++++-
 6 files changed, 53 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/0010b0a0/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ServerLocatorImpl.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ServerLocatorImpl.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ServerLocatorImpl.java
index adae8f7..02c17c6 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ServerLocatorImpl.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ServerLocatorImpl.java
@@ -1504,7 +1504,9 @@ public final class ServerLocatorImpl implements ServerLocatorInternal, Discovery
 
          int count = 0;
          for (TopologyMemberImpl pair : membersCopy) {
-            topologyArrayLocal[count++] = pair.getConnector();
+            Pair<TransportConfiguration, TransportConfiguration> transportConfigs = pair.getConnector();
+            topologyArrayLocal[count++] = new Pair<>(protocolManagerFactory.adaptTransportConfiguration(transportConfigs.getA()),
+                    protocolManagerFactory.adaptTransportConfiguration(transportConfigs.getB()));
          }
 
          this.topologyArray = topologyArrayLocal;

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/0010b0a0/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/ActiveMQClientProtocolManagerFactory.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/ActiveMQClientProtocolManagerFactory.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/ActiveMQClientProtocolManagerFactory.java
index 5675fff..866713c 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/ActiveMQClientProtocolManagerFactory.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/ActiveMQClientProtocolManagerFactory.java
@@ -16,6 +16,7 @@
  */
 package org.apache.activemq.artemis.core.protocol.core.impl;
 
+import org.apache.activemq.artemis.api.core.TransportConfiguration;
 import org.apache.activemq.artemis.api.core.client.ServerLocator;
 import org.apache.activemq.artemis.spi.core.remoting.ClientProtocolManager;
 import org.apache.activemq.artemis.spi.core.remoting.ClientProtocolManagerFactory;
@@ -49,4 +50,9 @@ public class ActiveMQClientProtocolManagerFactory implements ClientProtocolManag
    public ClientProtocolManager newProtocolManager() {
       return new ActiveMQClientProtocolManager();
    }
+
+   @Override
+   public TransportConfiguration adaptTransportConfiguration(TransportConfiguration tc) {
+      return tc;
+   }
 }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/0010b0a0/artemis-core-client/src/main/java/org/apache/activemq/artemis/spi/core/remoting/ClientProtocolManagerFactory.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/spi/core/remoting/ClientProtocolManagerFactory.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/spi/core/remoting/ClientProtocolManagerFactory.java
index 7e82238..96e9ead 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/spi/core/remoting/ClientProtocolManagerFactory.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/spi/core/remoting/ClientProtocolManagerFactory.java
@@ -16,6 +16,7 @@
  */
 package org.apache.activemq.artemis.spi.core.remoting;
 
+import org.apache.activemq.artemis.api.core.TransportConfiguration;
 import org.apache.activemq.artemis.api.core.client.ServerLocator;
 
 public interface ClientProtocolManagerFactory {
@@ -25,4 +26,13 @@ public interface ClientProtocolManagerFactory {
    void setLocator(ServerLocator locator);
 
    ServerLocator getLocator();
+
+   /**
+    * Adapt the transport configuration passed in parameter and return an adapted one that is suitable to use with ClientProtocolManager
+    * created by this factory.
+    *
+    * @param tc the original TransportConfiguration
+    * @return the adapted TransportConfiguration
+    */
+   TransportConfiguration adaptTransportConfiguration(TransportConfiguration tc);
 }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/0010b0a0/artemis-protocols/artemis-hqclient-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/hornetq/client/HornetQClientProtocolManagerFactory.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-hqclient-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/hornetq/client/HornetQClientProtocolManagerFactory.java b/artemis-protocols/artemis-hqclient-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/hornetq/client/HornetQClientProtocolManagerFactory.java
index 99cfcb9..57f2c94 100644
--- a/artemis-protocols/artemis-hqclient-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/hornetq/client/HornetQClientProtocolManagerFactory.java
+++ b/artemis-protocols/artemis-hqclient-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/hornetq/client/HornetQClientProtocolManagerFactory.java
@@ -17,8 +17,10 @@
 
 package org.apache.activemq.artemis.core.protocol.hornetq.client;
 
+import org.apache.activemq.artemis.api.core.TransportConfiguration;
 import org.apache.activemq.artemis.api.core.client.ServerLocator;
 import org.apache.activemq.artemis.core.protocol.hornetq.HQPropertiesConversionInterceptor;
+import org.apache.activemq.artemis.core.remoting.impl.netty.NettyConnectorFactory;
 import org.apache.activemq.artemis.spi.core.remoting.ClientProtocolManager;
 import org.apache.activemq.artemis.spi.core.remoting.ClientProtocolManagerFactory;
 import org.osgi.service.component.annotations.Component;
@@ -40,6 +42,27 @@ public class HornetQClientProtocolManagerFactory implements ClientProtocolManage
       locator.addOutgoingInterceptor(new HQPropertiesConversionInterceptor(false));
    }
 
+   /**
+    * Adapt the transport configuration by replacing the factoryClassName corresponding to an HornetQ's NettyConnectorFactory
+    * by the Artemis-based implementation.
+    */
+   @Override
+   public TransportConfiguration adaptTransportConfiguration(TransportConfiguration tc) {
+      if (tc == null) {
+         return null;
+      }
+
+      String factoryClassName = tc.getFactoryClassName();
+      if (factoryClassName.equals("org.hornetq.core.remoting.impl.netty.NettyConnectorFactory")) {
+         factoryClassName = NettyConnectorFactory.class.getName();
+      }
+      TransportConfiguration newConfig = new TransportConfiguration(factoryClassName,
+              tc.getParams(),
+              tc.getName(),
+              tc.getExtraParams());
+      return newConfig;
+   }
+
    @Override
    public ClientProtocolManager newProtocolManager() {
       return new HornetQClientProtocolManager();

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/0010b0a0/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ActiveMQServerSideProtocolManagerFactory.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ActiveMQServerSideProtocolManagerFactory.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ActiveMQServerSideProtocolManagerFactory.java
index 3c9791e..85ad3a3 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ActiveMQServerSideProtocolManagerFactory.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ActiveMQServerSideProtocolManagerFactory.java
@@ -16,6 +16,7 @@
  */
 package org.apache.activemq.artemis.core.server.cluster;
 
+import org.apache.activemq.artemis.api.core.TransportConfiguration;
 import org.apache.activemq.artemis.api.core.client.ServerLocator;
 import org.apache.activemq.artemis.core.protocol.ServerPacketDecoder;
 import org.apache.activemq.artemis.core.protocol.core.impl.ActiveMQClientProtocolManager;
@@ -52,6 +53,11 @@ public class ActiveMQServerSideProtocolManagerFactory implements ClientProtocolM
    private static final long serialVersionUID = 1;
 
    @Override
+   public TransportConfiguration adaptTransportConfiguration(TransportConfiguration tc) {
+      return tc;
+   }
+
+   @Override
    public ClientProtocolManager newProtocolManager() {
       return new ActiveMQReplicationProtocolManager();
    }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/0010b0a0/artemis-service-extensions/src/main/java/org/apache/activemq/artemis/service/extensions/xa/recovery/XARecoveryConfig.java
----------------------------------------------------------------------
diff --git a/artemis-service-extensions/src/main/java/org/apache/activemq/artemis/service/extensions/xa/recovery/XARecoveryConfig.java b/artemis-service-extensions/src/main/java/org/apache/activemq/artemis/service/extensions/xa/recovery/XARecoveryConfig.java
index f2f7864..292395a 100644
--- a/artemis-service-extensions/src/main/java/org/apache/activemq/artemis/service/extensions/xa/recovery/XARecoveryConfig.java
+++ b/artemis-service-extensions/src/main/java/org/apache/activemq/artemis/service/extensions/xa/recovery/XARecoveryConfig.java
@@ -65,7 +65,11 @@ public class XARecoveryConfig {
                            final ClientProtocolManagerFactory clientProtocolManager) {
       TransportConfiguration[] newTransportConfiguration = new TransportConfiguration[transportConfiguration.length];
       for (int i = 0; i < transportConfiguration.length; i++) {
-         newTransportConfiguration[i] = transportConfiguration[i].newTransportConfig("");
+         if (clientProtocolManager != null) {
+            newTransportConfiguration[i] = clientProtocolManager.adaptTransportConfiguration(transportConfiguration[i].newTransportConfig(""));
+         } else {
+            newTransportConfiguration[i] = transportConfiguration[i].newTransportConfig("");
+         }
       }
 
       this.transportConfiguration = newTransportConfiguration;