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 2021/01/28 20:26:27 UTC

[activemq-artemis] branch master updated: ARTEMIS-3064 - ensure useTopologyForLoadBalancing is disabled when ha=false

This is an automated email from the ASF dual-hosted git repository.

clebertsuconic pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/activemq-artemis.git


The following commit(s) were added to refs/heads/master by this push:
     new 05e9cfe  ARTEMIS-3064 - ensure useTopologyForLoadBalancing is disabled when ha=false
     new e5a5ce1  This closes #3418
05e9cfe is described below

commit 05e9cfed4cf458fd276d18e148d0bc3f9068309b
Author: gtully <ga...@gmail.com>
AuthorDate: Fri Jan 22 12:18:48 2021 +0000

    ARTEMIS-3064 - ensure useTopologyForLoadBalancing is disabled when ha=false
---
 .../server/federation/FederationConnection.java    |  4 +
 .../FederatedServerLocatorConfigTest.java          | 86 ++++++++++++++++++++++
 2 files changed, 90 insertions(+)

diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/federation/FederationConnection.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/federation/FederationConnection.java
index 2b00b3c..b88617f 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/federation/FederationConnection.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/federation/FederationConnection.java
@@ -69,6 +69,10 @@ public class FederationConnection {
          }
       }
 
+      if (!config.isHA()) {
+         serverLocator.setUseTopologyForLoadBalancing(false);
+      }
+
       serverLocator.setConnectionTTL(config.getConnectionTTL());
       serverLocator.setClientFailureCheckPeriod(config.getClientFailureCheckPeriod());
       serverLocator.setReconnectAttempts(config.getReconnectAttempts());
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/federation/FederatedServerLocatorConfigTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/federation/FederatedServerLocatorConfigTest.java
new file mode 100644
index 0000000..c40d35b
--- /dev/null
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/federation/FederatedServerLocatorConfigTest.java
@@ -0,0 +1,86 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.artemis.tests.integration.federation;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.activemq.artemis.api.core.TransportConfiguration;
+import org.apache.activemq.artemis.core.config.Configuration;
+import org.apache.activemq.artemis.core.config.FederationConfiguration;
+import org.apache.activemq.artemis.core.config.federation.FederationUpstreamConfiguration;
+import org.apache.activemq.artemis.core.config.impl.ConfigurationImpl;
+import org.apache.activemq.artemis.core.server.federation.Federation;
+import org.apache.activemq.artemis.core.server.federation.FederationUpstream;
+import org.junit.Before;
+import org.junit.Test;
+
+public class FederatedServerLocatorConfigTest extends FederatedTestBase {
+
+
+   @Override
+   @Before
+   public void setUp() throws Exception {
+      super.setUp();
+   }
+
+   @Override
+   protected int numberOfServers() {
+      return 2;
+   }
+
+   @Override
+   protected Configuration createDefaultConfig(final int serverID, final boolean netty) throws Exception {
+
+      ConfigurationImpl configuration = createBasicConfig(serverID).setJMXManagementEnabled(false).addAcceptorConfiguration(new TransportConfiguration(INVM_ACCEPTOR_FACTORY, generateInVMParams(serverID), "invm"));
+
+      HashMap<String, Object> params = new HashMap<>();
+      params.put(org.apache.activemq.artemis.core.remoting.impl.netty.TransportConstants.PORT_PROP_NAME, org.apache.activemq.artemis.core.remoting.impl.netty.TransportConstants.DEFAULT_PORT + serverID);
+
+      configuration.addAcceptorConfiguration(new TransportConfiguration(NETTY_ACCEPTOR_FACTORY, params, "netty", new HashMap<>()));
+
+      return configuration;
+   }
+
+   @Test
+   public void testFederatedAddressServerLocatorConfigFromUrl() throws Exception {
+      String address = getName();
+
+      // we still won't pick up url params, restricted locator config is explicit
+      // bundling getUseTopologyForLoadBalancing with HA=false is consistent with simplification
+      String connectorName = "server1WithUrlParams";
+      Map<String, Object> params = new HashMap<>();
+      params.put("host", "localhost");
+      params.put("port",  org.apache.activemq.artemis.core.remoting.impl.netty.TransportConstants.DEFAULT_PORT + 1);
+
+      getServer(0).getConfiguration().addConnectorConfiguration(connectorName, new TransportConfiguration(NETTY_CONNECTOR_FACTORY, params));
+
+      FederationConfiguration federationConfiguration0 = FederatedTestUtil.createAddressUpstreamFederationConfiguration("server1WithUrlParams", address, 2);
+      for (FederationUpstreamConfiguration upstreamConfiguration : federationConfiguration0.getUpstreamConfigurations()) {
+         upstreamConfiguration.getConnectionConfiguration().setHA(false);
+      }
+      getServer(0).getConfiguration().getFederationConfigurations().add(federationConfiguration0);
+      getServer(0).getFederationManager().deploy();
+
+
+      // lets peek at the server locator
+      Federation fed = getServer(0).getFederationManager().get(federationConfiguration0.getName());
+      assertNotNull(fed);
+      FederationUpstream federationUpstream = fed.get(connectorName);
+      assertFalse(federationUpstream.getConnection().clientSessionFactory().getServerLocator().getUseTopologyForLoadBalancing());
+   }
+}