Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 0B25E200BB3 for ; Tue, 18 Oct 2016 15:00:47 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 09AB7160ACC; Tue, 18 Oct 2016 13:00:47 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 32DD6160ADC for ; Tue, 18 Oct 2016 15:00:46 +0200 (CEST) Received: (qmail 31975 invoked by uid 500); 18 Oct 2016 13:00:45 -0000 Mailing-List: contact commits-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@activemq.apache.org Delivered-To: mailing list commits@activemq.apache.org Received: (qmail 31936 invoked by uid 99); 18 Oct 2016 13:00:43 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 18 Oct 2016 13:00:43 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 08361E0ADC; Tue, 18 Oct 2016 13:00:43 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: clebertsuconic@apache.org To: commits@activemq.apache.org Date: Tue, 18 Oct 2016 13:00:43 -0000 Message-Id: In-Reply-To: <9fb6cf5c418243be9e2e3bc7fed5c42c@git.apache.org> References: <9fb6cf5c418243be9e2e3bc7fed5c42c@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [2/2] activemq-artemis git commit: [ARTEMIS-803] Fix colocated backups with http-upgrade acceptor archived-at: Tue, 18 Oct 2016 13:00:47 -0000 [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/master Commit: c1ecddcb717be023d1d852c53325a9b08286fbd0 Parents: a80bd4b Author: Jeff Mesnil Authored: Mon Oct 17 11:42:57 2016 +0200 Committer: Clebert Suconic 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 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 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); } } }