From 789d284d6a073e61abac27da875f38df27c5217d Mon Sep 17 00:00:00 2001 From: Rajan Dhabalia Date: Tue, 24 Oct 2023 16:14:44 -0700 Subject: [PATCH] [fix][broker] Allow broker deployment in heterogeneous hw config cluster without restricting nic speed detection (#21409) --- .../java/org/apache/pulsar/broker/PulsarService.java | 9 --------- .../extensions/ExtensibleLoadManagerImplTest.java | 8 ++++++++ .../loadbalance/ExtensibleLoadManagerTest.java | 5 ++++- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/PulsarService.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/PulsarService.java index e2950594047df..9a202c28c2acc 100644 --- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/PulsarService.java +++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/PulsarService.java @@ -83,7 +83,6 @@ import org.apache.pulsar.broker.intercept.BrokerInterceptors; import org.apache.pulsar.broker.loadbalance.LeaderBroker; import org.apache.pulsar.broker.loadbalance.LeaderElectionService; -import org.apache.pulsar.broker.loadbalance.LinuxInfoUtils; import org.apache.pulsar.broker.loadbalance.LoadManager; import org.apache.pulsar.broker.loadbalance.LoadReportUpdaterTask; import org.apache.pulsar.broker.loadbalance.LoadResourceQuotaUpdaterTask; @@ -733,14 +732,6 @@ public void start() throws PulsarServerException { config.getDefaultRetentionTimeInMinutes() * 60)); } - if (config.getLoadBalancerOverrideBrokerNicSpeedGbps().isEmpty() - && config.isLoadBalancerEnabled() - && LinuxInfoUtils.isLinux() - && !LinuxInfoUtils.checkHasNicSpeeds()) { - throw new IllegalStateException("Unable to read VM NIC speed. You must set " - + "[loadBalancerOverrideBrokerNicSpeedGbps] to override it when load balancer is enabled."); - } - localMetadataSynchronizer = StringUtils.isNotBlank(config.getMetadataSyncEventTopic()) ? new PulsarMetadataEventSynchronizer(this, config.getMetadataSyncEventTopic()) : null; diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/broker/loadbalance/extensions/ExtensibleLoadManagerImplTest.java b/pulsar-broker/src/test/java/org/apache/pulsar/broker/loadbalance/extensions/ExtensibleLoadManagerImplTest.java index 20ba9500cb1fd..c7cd55e183bee 100644 --- a/pulsar-broker/src/test/java/org/apache/pulsar/broker/loadbalance/extensions/ExtensibleLoadManagerImplTest.java +++ b/pulsar-broker/src/test/java/org/apache/pulsar/broker/loadbalance/extensions/ExtensibleLoadManagerImplTest.java @@ -256,6 +256,14 @@ public void testCheckOwnershipAsync() throws Exception { TopicName topicName = TopicName.get(defaultTestNamespace + "/test-check-ownership"); NamespaceBundle bundle = getBundleAsync(pulsar1, topicName).get(); // 1. The bundle is never assigned. + retryStrategically((test) -> { + try { + return !primaryLoadManager.checkOwnershipAsync(Optional.empty(), bundle).get() + && !secondaryLoadManager.checkOwnershipAsync(Optional.empty(), bundle).get(); + } catch (Exception e) { + return false; + } + }, 5, 200); assertFalse(primaryLoadManager.checkOwnershipAsync(Optional.empty(), bundle).get()); assertFalse(secondaryLoadManager.checkOwnershipAsync(Optional.empty(), bundle).get()); diff --git a/tests/integration/src/test/java/org/apache/pulsar/tests/integration/loadbalance/ExtensibleLoadManagerTest.java b/tests/integration/src/test/java/org/apache/pulsar/tests/integration/loadbalance/ExtensibleLoadManagerTest.java index 035d88c7be0e0..158827ca34db6 100644 --- a/tests/integration/src/test/java/org/apache/pulsar/tests/integration/loadbalance/ExtensibleLoadManagerTest.java +++ b/tests/integration/src/test/java/org/apache/pulsar/tests/integration/loadbalance/ExtensibleLoadManagerTest.java @@ -19,6 +19,7 @@ package org.apache.pulsar.tests.integration.loadbalance; import static org.apache.pulsar.tests.integration.containers.PulsarContainer.BROKER_HTTP_PORT; +import static org.apache.pulsar.tests.integration.suites.PulsarTestSuite.retryStrategically; import static org.assertj.core.api.Assertions.assertThat; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertFalse; @@ -308,7 +309,7 @@ public void testAntiaffinityPolicy() throws PulsarAdminException { } @Test(timeOut = 40 * 1000) - public void testIsolationPolicy() throws PulsarAdminException { + public void testIsolationPolicy() throws Exception { final String namespaceIsolationPolicyName = "my-isolation-policy"; final String isolationEnabledNameSpace = DEFAULT_TENANT + "/my-isolation-policy" + nsSuffix; Map parameters1 = new HashMap<>(); @@ -346,6 +347,8 @@ public void testIsolationPolicy() throws PulsarAdminException { broker = admin.lookups().lookupTopic(topic); + final String brokerName = broker; + retryStrategically((test) -> extractBrokerIndex(brokerName) == 1, 100, 200); assertEquals(extractBrokerIndex(broker), 1); for (BrokerContainer container : pulsarCluster.getBrokers()) {