activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From martyntay...@apache.org
Subject [18/41] activemq-artemis git commit: [ARTEMIS-803] Fix colocated backups with http-upgrade acceptor
Date Fri, 21 Oct 2016 09:56:21 GMT
[ARTEMIS-803] Fix colocated backups with http-upgrade acceptor

*  Do not offset ports for Netty connector/acceptor with http-upgrade
enabled.
* Pass the name of the ActiveMQ server to the HTTP request to initiate
the Upgrade so that the HTTP endpoint on the app server can find the
correct ActiveMQ broker that must handle the upgrade.

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


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

Branch: refs/heads/ARTEMIS-780
Commit: c1ecddcb717be023d1d852c53325a9b08286fbd0
Parents: a80bd4b
Author: Jeff Mesnil <jmesnil@gmail.com>
Authored: Mon Oct 17 11:42:57 2016 +0200
Committer: Clebert Suconic <clebertsuconic@apache.org>
Committed: Tue Oct 18 09:00:36 2016 -0400

----------------------------------------------------------------------
 .../remoting/impl/netty/NettyConnector.java     |  4 +++
 .../remoting/impl/netty/TransportConstants.java |  3 +++
 .../server/cluster/ha/ColocatedHAManager.java   | 26 +++++++++++++++-----
 3 files changed, 27 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/c1ecddcb/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyConnector.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyConnector.java
b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyConnector.java
index 326fe27..346e866 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyConnector.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyConnector.java
@@ -653,6 +653,10 @@ public class NettyConnector extends AbstractConnector {
                request.headers().set(HttpHeaders.Names.HOST, host);
                request.headers().set(HttpHeaders.Names.UPGRADE, ACTIVEMQ_REMOTING);
                request.headers().set(HttpHeaders.Names.CONNECTION, HttpHeaders.Values.UPGRADE);
+               final String serverName = ConfigurationHelper.getStringProperty(TransportConstants.ACTIVEMQ_SERVER_NAME,
null, configuration);
+               if (serverName != null) {
+                  request.headers().set(TransportConstants.ACTIVEMQ_SERVER_NAME, serverName);
+               }
 
                final String endpoint = ConfigurationHelper.getStringProperty(TransportConstants.HTTP_UPGRADE_ENDPOINT_PROP_NAME,
null, configuration);
                if (endpoint != null) {

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/c1ecddcb/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/TransportConstants.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/TransportConstants.java
b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/TransportConstants.java
index 864bce7..dfa2ce2 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/TransportConstants.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/TransportConstants.java
@@ -53,6 +53,8 @@ public class TransportConstants {
 
    public static final String USE_INVM_PROP_NAME = "useInvm";
 
+   public static final String ACTIVEMQ_SERVER_NAME = "activemqServerName";
+
    /**
     * @deprecated use PROTOCOLS_PROP_NAME
     */
@@ -252,6 +254,7 @@ public class TransportConstants {
       ALLOWABLE_ACCEPTOR_KEYS = Collections.unmodifiableSet(allowableAcceptorKeys);
 
       Set<String> allowableConnectorKeys = new HashSet<>();
+      allowableConnectorKeys.add(TransportConstants.ACTIVEMQ_SERVER_NAME);
       allowableConnectorKeys.add(TransportConstants.SSL_ENABLED_PROP_NAME);
       allowableConnectorKeys.add(TransportConstants.HTTP_ENABLED_PROP_NAME);
       allowableConnectorKeys.add(TransportConstants.HTTP_CLIENT_IDLE_PROP_NAME);

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/c1ecddcb/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ha/ColocatedHAManager.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ha/ColocatedHAManager.java
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ha/ColocatedHAManager.java
index e730c71..c08fcf6 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ha/ColocatedHAManager.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ha/ColocatedHAManager.java
@@ -26,11 +26,13 @@ import org.apache.activemq.artemis.api.core.SimpleString;
 import org.apache.activemq.artemis.api.core.TransportConfiguration;
 import org.apache.activemq.artemis.api.core.client.TopologyMember;
 import org.apache.activemq.artemis.core.config.Configuration;
+import org.apache.activemq.artemis.core.remoting.impl.netty.TransportConstants;
 import org.apache.activemq.artemis.core.server.ActivationParams;
 import org.apache.activemq.artemis.core.server.ActiveMQServer;
 import org.apache.activemq.artemis.core.server.ActiveMQServerLogger;
 import org.apache.activemq.artemis.core.server.cluster.ClusterControl;
 import org.apache.activemq.artemis.core.server.cluster.ClusterController;
+import org.apache.activemq.artemis.utils.ConfigurationHelper;
 
 public class ColocatedHAManager implements HAManager {
 
@@ -268,19 +270,31 @@ public class ColocatedHAManager implements HAManager {
       }
    }
 
+   /**
+    * Offset the port for Netty connector/acceptor (unless HTTP upgrade is enabled) and the
server ID for invm connector/acceptor.
+    *
+    * The port is not offset for Netty connector/acceptor when HTTP upgrade is enabled. In
this case, the app server that
+    * embed ActiveMQ is "owning" the port and is charge to delegate the HTTP ugprade to the
correct broker (that can be
+    * the main one or any colocated backup hosted on the main broker). Delegation to the
correct broker is done by looking at the
+    * {@link TransportConstants#ACTIVEMQ_SERVER_NAME} property [ARTEMIS-803]
+    */
    private static void updatebackupParams(String name, int portOffset, Map<String, Object>
params) {
       if (params != null) {
-         Object port = params.get("port");
+         Object port = params.get(TransportConstants.PORT_PROP_NAME);
          if (port != null) {
-            Integer integer = Integer.valueOf(port.toString());
-            integer += portOffset;
-            params.put("port", integer.toString());
+            boolean httpUpgradeEnabled = ConfigurationHelper.getBooleanProperty(TransportConstants.HTTP_UPGRADE_ENABLED_PROP_NAME,
TransportConstants.DEFAULT_HTTP_UPGRADE_ENABLED, params);
+            if (!httpUpgradeEnabled) {
+               Integer integer = Integer.valueOf(port.toString());
+               integer += portOffset;
+               params.put(TransportConstants.PORT_PROP_NAME, integer.toString());
+            }
          }
-         Object serverId = params.get("serverId");
+         Object serverId = params.get(org.apache.activemq.artemis.core.remoting.impl.invm.TransportConstants.SERVER_ID_PROP_NAME);
          if (serverId != null) {
             Integer newid = Integer.parseInt(serverId.toString()) + portOffset;
-            params.put("serverId", newid.toString());
+            params.put(org.apache.activemq.artemis.core.remoting.impl.invm.TransportConstants.SERVER_ID_PROP_NAME,
newid.toString());
          }
+         params.put(TransportConstants.ACTIVEMQ_SERVER_NAME, name);
       }
    }
 }


Mime
View raw message