activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clebertsuco...@apache.org
Subject [2/3] activemq-artemis git commit: ARTEMIS-1781 Connector parameters not backward compatible (Fix)
Date Tue, 17 Apr 2018 15:42:56 GMT
ARTEMIS-1781 Connector parameters not backward compatible (Fix)


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

Branch: refs/heads/master
Commit: a8d0db2c14356fbde4e4233db980d903348f928b
Parents: 284c620
Author: Tomas Hofman <thofman@redhat.com>
Authored: Tue Apr 17 11:27:22 2018 -0400
Committer: Clebert Suconic <clebertsuconic@apache.org>
Committed: Tue Apr 17 11:38:19 2018 -0400

----------------------------------------------------------------------
 .../core/impl/BackwardsCompatibilityUtils.java  | 153 ++++++++++++++++++-
 .../deployers/impl/FileConfigurationParser.java |  12 +-
 .../protocol/core/impl/CoreProtocolManager.java |   2 +-
 3 files changed, 154 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/a8d0db2c/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/BackwardsCompatibilityUtils.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/BackwardsCompatibilityUtils.java
b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/BackwardsCompatibilityUtils.java
index 9419796..c441fc0 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/BackwardsCompatibilityUtils.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/BackwardsCompatibilityUtils.java
@@ -20,27 +20,168 @@ package org.apache.activemq.artemis.core.protocol.core.impl;
 import org.apache.activemq.artemis.api.core.Pair;
 import org.apache.activemq.artemis.api.core.TransportConfiguration;
 import org.apache.activemq.artemis.api.core.client.TopologyMember;
+import org.apache.activemq.artemis.core.remoting.impl.netty.TransportConstants;
+
+import java.util.HashMap;
+import java.util.Map;
 
 /**
- * This is a utility class to house any HornetQ client specific backwards compatibility methods.
+ * There are a few properties that were changed between HornetQ and Artemis.
+ * When sending topology updates to clients, if these properties are used we need to convert
them properly
  */
 public class BackwardsCompatibilityUtils {
 
    private static int INITIAL_ACTIVEMQ_INCREMENTING_VERSION = 126;
 
-   public static Pair<TransportConfiguration, TransportConfiguration> getTCPair(int
clientIncrementingVersion,
-                                                                                TopologyMember
member) {
+
+   public static final String SSL_ENABLED_PROP_NAME = "ssl-enabled";
+
+   public static final String HTTP_ENABLED_PROP_NAME = "http-enabled";
+
+   public static final String HTTP_CLIENT_IDLE_PROP_NAME = "http-client-idle-time";
+
+   public static final String HTTP_CLIENT_IDLE_SCAN_PERIOD = "http-client-idle-scan-period";
+
+   public static final String HTTP_RESPONSE_TIME_PROP_NAME = "http-response-time";
+
+   public static final String HTTP_SERVER_SCAN_PERIOD_PROP_NAME = "http-server-scan-period";
+
+   public static final String HTTP_REQUIRES_SESSION_ID = "http-requires-session-id";
+
+   public static final String USE_SERVLET_PROP_NAME = "use-servlet";
+
+   public static final String SERVLET_PATH = "servlet-path";
+
+   public static final String USE_NIO_PROP_NAME = "use-nio";
+
+   public static final String USE_NIO_GLOBAL_WORKER_POOL_PROP_NAME = "use-nio-global-worker-pool";
+
+   public static final String USE_INVM_PROP_NAME = "use-invm";
+
+   public static final String PROTOCOL_PROP_NAME = "protocol";
+
+   public static final String HOST_PROP_NAME = "host";
+
+   public static final String PORT_PROP_NAME = "port";
+
+   public static final String LOCAL_ADDRESS_PROP_NAME = "local-address";
+
+   public static final String LOCAL_PORT_PROP_NAME = "local-port";
+
+   public static final String KEYSTORE_PROVIDER_PROP_NAME = "key-store-provider";
+
+   public static final String KEYSTORE_PATH_PROP_NAME = "key-store-path";
+
+   public static final String KEYSTORE_PASSWORD_PROP_NAME = "key-store-password";
+
+   public static final String TRUSTSTORE_PROVIDER_PROP_NAME = "trust-store-provider";
+
+   public static final String TRUSTSTORE_PATH_PROP_NAME = "trust-store-path";
+
+   public static final String TRUSTSTORE_PASSWORD_PROP_NAME = "trust-store-password";
+
+   public static final String NEED_CLIENT_AUTH_PROP_NAME = "need-client-auth";
+
+   public static final String BACKLOG_PROP_NAME = "backlog";
+
+   public static final String TCP_NODELAY_PROPNAME = "tcp-no-delay";
+
+   public static final String TCP_SENDBUFFER_SIZE_PROPNAME = "tcp-send-buffer-size";
+
+   public static final String TCP_RECEIVEBUFFER_SIZE_PROPNAME = "tcp-receive-buffer-size";
+
+   public static final String NIO_REMOTING_THREADS_PROPNAME = "nio-remoting-threads";
+
+   public static final String BATCH_DELAY = "batch-delay";
+
+   public static final String DIRECT_DELIVER = "direct-deliver";
+
+   public static final String CLUSTER_CONNECTION = "cluster-connection";
+
+   public static final String STOMP_CONSUMERS_CREDIT = "stomp-consumer-credits";
+
+   public static final Map<String, String> OLD_PARAMETERS_MAP = new HashMap<>();
+
+   static {
+      OLD_PARAMETERS_MAP.put(TransportConstants.SSL_ENABLED_PROP_NAME, SSL_ENABLED_PROP_NAME);
+      OLD_PARAMETERS_MAP.put(TransportConstants.HTTP_ENABLED_PROP_NAME, HTTP_ENABLED_PROP_NAME);
+      OLD_PARAMETERS_MAP.put(TransportConstants.HTTP_CLIENT_IDLE_PROP_NAME, HTTP_CLIENT_IDLE_PROP_NAME);
+      OLD_PARAMETERS_MAP.put(TransportConstants.HTTP_CLIENT_IDLE_SCAN_PERIOD, HTTP_CLIENT_IDLE_SCAN_PERIOD);
+      OLD_PARAMETERS_MAP.put(TransportConstants.HTTP_RESPONSE_TIME_PROP_NAME, HTTP_RESPONSE_TIME_PROP_NAME);
+      OLD_PARAMETERS_MAP.put(TransportConstants.HTTP_SERVER_SCAN_PERIOD_PROP_NAME, HTTP_SERVER_SCAN_PERIOD_PROP_NAME);
+      OLD_PARAMETERS_MAP.put(TransportConstants.HTTP_REQUIRES_SESSION_ID, HTTP_REQUIRES_SESSION_ID);
+      OLD_PARAMETERS_MAP.put(TransportConstants.USE_SERVLET_PROP_NAME, USE_SERVLET_PROP_NAME);
+      OLD_PARAMETERS_MAP.put(TransportConstants.SERVLET_PATH, SERVLET_PATH);
+      OLD_PARAMETERS_MAP.put(TransportConstants.USE_NIO_PROP_NAME, USE_NIO_PROP_NAME);
+      OLD_PARAMETERS_MAP.put(TransportConstants.USE_NIO_GLOBAL_WORKER_POOL_PROP_NAME, USE_NIO_GLOBAL_WORKER_POOL_PROP_NAME);
+      OLD_PARAMETERS_MAP.put(TransportConstants.USE_INVM_PROP_NAME, USE_INVM_PROP_NAME);
+      OLD_PARAMETERS_MAP.put(TransportConstants.PROTOCOL_PROP_NAME, PROTOCOL_PROP_NAME);
+      OLD_PARAMETERS_MAP.put(TransportConstants.HOST_PROP_NAME, HOST_PROP_NAME);
+      OLD_PARAMETERS_MAP.put(TransportConstants.PORT_PROP_NAME, PORT_PROP_NAME);
+      OLD_PARAMETERS_MAP.put(TransportConstants.LOCAL_ADDRESS_PROP_NAME, LOCAL_ADDRESS_PROP_NAME);
+      OLD_PARAMETERS_MAP.put(TransportConstants.LOCAL_PORT_PROP_NAME, LOCAL_PORT_PROP_NAME);
+      OLD_PARAMETERS_MAP.put(TransportConstants.KEYSTORE_PROVIDER_PROP_NAME, KEYSTORE_PROVIDER_PROP_NAME);
+      OLD_PARAMETERS_MAP.put(TransportConstants.KEYSTORE_PATH_PROP_NAME, KEYSTORE_PATH_PROP_NAME);
+      OLD_PARAMETERS_MAP.put(TransportConstants.KEYSTORE_PASSWORD_PROP_NAME, KEYSTORE_PASSWORD_PROP_NAME);
+      OLD_PARAMETERS_MAP.put(TransportConstants.TRUSTSTORE_PROVIDER_PROP_NAME, TRUSTSTORE_PROVIDER_PROP_NAME);
+      OLD_PARAMETERS_MAP.put(TransportConstants.TRUSTSTORE_PATH_PROP_NAME, TRUSTSTORE_PATH_PROP_NAME);
+      OLD_PARAMETERS_MAP.put(TransportConstants.TRUSTSTORE_PASSWORD_PROP_NAME, TRUSTSTORE_PASSWORD_PROP_NAME);
+      OLD_PARAMETERS_MAP.put(TransportConstants.NEED_CLIENT_AUTH_PROP_NAME, NEED_CLIENT_AUTH_PROP_NAME);
+      OLD_PARAMETERS_MAP.put(TransportConstants.BACKLOG_PROP_NAME, BACKLOG_PROP_NAME);
+      OLD_PARAMETERS_MAP.put(TransportConstants.TCP_NODELAY_PROPNAME, TCP_NODELAY_PROPNAME);
+      OLD_PARAMETERS_MAP.put(TransportConstants.TCP_SENDBUFFER_SIZE_PROPNAME, TCP_SENDBUFFER_SIZE_PROPNAME);
+      OLD_PARAMETERS_MAP.put(TransportConstants.TCP_RECEIVEBUFFER_SIZE_PROPNAME, TCP_RECEIVEBUFFER_SIZE_PROPNAME);
+      OLD_PARAMETERS_MAP.put(TransportConstants.NIO_REMOTING_THREADS_PROPNAME, NIO_REMOTING_THREADS_PROPNAME);
+      OLD_PARAMETERS_MAP.put(TransportConstants.BATCH_DELAY, BATCH_DELAY);
+      OLD_PARAMETERS_MAP.put(TransportConstants.DIRECT_DELIVER, DIRECT_DELIVER);
+      OLD_PARAMETERS_MAP.put(TransportConstants.CLUSTER_CONNECTION, CLUSTER_CONNECTION);
+      OLD_PARAMETERS_MAP.put(TransportConstants.STOMP_CONSUMERS_CREDIT, STOMP_CONSUMERS_CREDIT);
+   }
+
+   /**
+    * Translates V3 strings to V2 strings.
+    * <p>
+    * Returns the string as if it's not found in the conversion map.
+    */
+   public static String convertParameter(String name) {
+      String oldParameter = OLD_PARAMETERS_MAP.get(name);
+      if (oldParameter != null) {
+         return oldParameter;
+      } else {
+         return name;
+      }
+   }
+
+
+
+   public static Pair<TransportConfiguration, TransportConfiguration> checkTCPPairConversion(int
clientIncrementingVersion,
+                                                                                        
    TopologyMember member) {
       if (clientIncrementingVersion < INITIAL_ACTIVEMQ_INCREMENTING_VERSION) {
-         return new Pair<>(replaceClassName(member.getLive()), replaceClassName(member.getBackup()));
+         return new Pair<>(convertTransport(member.getLive()), convertTransport(member.getBackup()));
       }
       return new Pair<>(member.getLive(), member.getBackup());
    }
 
-   private static TransportConfiguration replaceClassName(TransportConfiguration tc) {
+   /**
+    * Replaces class name and parameter names to HornetQ values.
+    */
+   private static TransportConfiguration convertTransport(TransportConfiguration tc) {
       if (tc != null) {
          String className = tc.getFactoryClassName().replace("org.apache.activemq.artemis",
"org.hornetq").replace("ActiveMQ", "HornetQ");
-         return new TransportConfiguration(className, tc.getParams(), tc.getName());
+         return new TransportConfiguration(className, convertParameters(tc.getParams()),
tc.getName());
       }
       return tc;
    }
+
+   private static Map<String, Object> convertParameters(Map<String, Object> params)
{
+      if (params == null) {
+         return null;
+      }
+      Map<String, Object> convertedParams = new HashMap<>(params.size());
+      for (Map.Entry<String, Object> entry: params.entrySet()) {
+         convertedParams.put(convertParameter(entry.getKey()), entry.getValue());
+      }
+      return convertedParams;
+   }
+
 }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/a8d0db2c/artemis-server/src/main/java/org/apache/activemq/artemis/core/deployers/impl/FileConfigurationParser.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/deployers/impl/FileConfigurationParser.java
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/deployers/impl/FileConfigurationParser.java
index d3cf13d..c4e4ea1 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/deployers/impl/FileConfigurationParser.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/deployers/impl/FileConfigurationParser.java
@@ -1174,10 +1174,10 @@ public final class FileConfigurationParser extends XMLConfigurationUtil
{
 
       if (mainConfig.isMaskPassword() != null) {
          params.put(ActiveMQDefaultConfiguration.getPropMaskPassword(), mainConfig.isMaskPassword());
-      }
 
-      if (mainConfig.getPasswordCodec() != null) {
-         params.put(ActiveMQDefaultConfiguration.getPropPasswordCodec(), mainConfig.getPasswordCodec());
+         if (mainConfig.isMaskPassword() && mainConfig.getPasswordCodec() != null)
{
+            params.put(ActiveMQDefaultConfiguration.getPropPasswordCodec(), mainConfig.getPasswordCodec());
+         }
       }
 
       return configurations.get(0);
@@ -1197,10 +1197,10 @@ public final class FileConfigurationParser extends XMLConfigurationUtil
{
 
       if (mainConfig.isMaskPassword() != null) {
          params.put(ActiveMQDefaultConfiguration.getPropMaskPassword(), mainConfig.isMaskPassword());
-      }
 
-      if (mainConfig.getPasswordCodec() != null) {
-         params.put(ActiveMQDefaultConfiguration.getPropPasswordCodec(), mainConfig.getPasswordCodec());
+         if (mainConfig.isMaskPassword() && mainConfig.getPasswordCodec() != null)
{
+            params.put(ActiveMQDefaultConfiguration.getPropPasswordCodec(), mainConfig.getPasswordCodec());
+         }
       }
 
       return configurations.get(0);

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/a8d0db2c/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/CoreProtocolManager.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/CoreProtocolManager.java
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/CoreProtocolManager.java
index 0b5432a..7a416d9 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/CoreProtocolManager.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/CoreProtocolManager.java
@@ -260,7 +260,7 @@ public class CoreProtocolManager implements ProtocolManager<Interceptor>
{
                @Override
                public void nodeUP(final TopologyMember topologyMember, final boolean last)
{
                   try {
-                     final Pair<TransportConfiguration, TransportConfiguration> connectorPair
= BackwardsCompatibilityUtils.getTCPair(channel0.getConnection().getChannelVersion(), topologyMember);
+                     final Pair<TransportConfiguration, TransportConfiguration> connectorPair
= BackwardsCompatibilityUtils.checkTCPPairConversion(channel0.getConnection().getChannelVersion(),
topologyMember);
 
                      final String nodeID = topologyMember.getNodeId();
                      // Using an executor as most of the notifications on the Topology


Mime
View raw message