From a812f29bab93a5e841a9b3c3190fca343fab6e71 Mon Sep 17 00:00:00 2001 From: Kai Wang Date: Sun, 24 Apr 2022 15:30:04 +0800 Subject: [PATCH] [refactor][broker] Move loadbalancer used data classes package position (#14945) ### Motivation I'm working on improving the loadbalancer, but I find they are four classes used in loadbalancer and the package position is under the `org.apache.pulsar.broker`. This is strange because another class named `LocalBrokerData` is in `org.apache.pulsar.policies.data.loadbalancer`. We should move it to pulsar-common and put them together with `LocalBrokerData` for future extensions. ### Modifications Move loadbalancer used data classes package position to `org.apache.pulsar.policies.data.loadbalancer` --- .../apache/pulsar/broker/loadbalance/BrokerFilter.java | 2 +- .../org/apache/pulsar/broker/loadbalance/LoadData.java | 4 ++-- .../pulsar/broker/loadbalance/ModularLoadManager.java | 2 +- .../broker/loadbalance/ModularLoadManagerStrategy.java | 2 +- .../broker/loadbalance/impl/BrokerVersionFilter.java | 4 ++-- .../broker/loadbalance/impl/BundleSplitterTask.java | 2 +- .../pulsar/broker/loadbalance/impl/DeviationShedder.java | 2 +- .../broker/loadbalance/impl/LeastLongTermMessageRate.java | 8 ++++---- .../pulsar/broker/loadbalance/impl/LoadManagerShared.java | 2 +- .../broker/loadbalance/impl/ModularLoadManagerImpl.java | 8 ++++---- .../pulsar/broker/loadbalance/impl/OverloadShedder.java | 4 ++-- .../pulsar/broker/loadbalance/impl/ThresholdShedder.java | 6 +++--- .../broker/loadbalance/impl/UniformLoadShedder.java | 6 +++--- .../pulsar/common/naming/NamespaceBundleFactory.java | 2 +- .../apache/pulsar/broker/TimeAverageBrokerDataTest.java | 3 +++ .../broker/loadbalance/BrokerVersionFilterTest.java | 2 +- .../broker/loadbalance/ModularLoadManagerImplTest.java | 8 ++++---- .../loadbalance/ModularLoadManagerStrategyTest.java | 7 ++++--- .../broker/loadbalance/impl/BundleSplitterTaskTest.java | 6 +++--- .../broker/loadbalance/impl/OverloadShedderTest.java | 6 +++--- .../broker/loadbalance/impl/ThresholdShedderTest.java | 6 +++--- .../pulsar/broker/namespace/NamespaceServiceTest.java | 2 +- .../pulsar/policies/data/loadbalancer}/BrokerData.java | 3 +-- .../pulsar/policies/data/loadbalancer}/BundleData.java | 4 +--- .../data/loadbalancer}/TimeAverageBrokerData.java | 3 +-- .../data/loadbalancer}/TimeAverageMessageData.java | 4 +--- .../java/org/apache/pulsar/testclient/BrokerMonitor.java | 2 +- .../pulsar/testclient/LoadSimulationController.java | 2 +- 28 files changed, 55 insertions(+), 57 deletions(-) rename {pulsar-broker/src/main/java/org/apache/pulsar/broker => pulsar-common/src/main/java/org/apache/pulsar/policies/data/loadbalancer}/BrokerData.java (94%) rename {pulsar-broker/src/main/java/org/apache/pulsar/broker => pulsar-common/src/main/java/org/apache/pulsar/policies/data/loadbalancer}/BundleData.java (97%) rename {pulsar-broker/src/main/java/org/apache/pulsar/broker => pulsar-common/src/main/java/org/apache/pulsar/policies/data/loadbalancer}/TimeAverageBrokerData.java (97%) rename {pulsar-broker/src/main/java/org/apache/pulsar/broker => pulsar-common/src/main/java/org/apache/pulsar/policies/data/loadbalancer}/TimeAverageMessageData.java (98%) diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/BrokerFilter.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/BrokerFilter.java index 3c2be94a399a6..0e58be3bfcc62 100644 --- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/BrokerFilter.java +++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/BrokerFilter.java @@ -19,8 +19,8 @@ package org.apache.pulsar.broker.loadbalance; import java.util.Set; -import org.apache.pulsar.broker.BundleData; import org.apache.pulsar.broker.ServiceConfiguration; +import org.apache.pulsar.policies.data.loadbalancer.BundleData; /** * Load management component which determines what brokers should not be considered for topic placement by the placement diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/LoadData.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/LoadData.java index 4243420391993..066b656a9dd0a 100644 --- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/LoadData.java +++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/LoadData.java @@ -21,10 +21,10 @@ import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import java.util.stream.Collectors; -import org.apache.pulsar.broker.BrokerData; -import org.apache.pulsar.broker.BundleData; import org.apache.pulsar.broker.namespace.NamespaceService; import org.apache.pulsar.common.naming.NamespaceBundle; +import org.apache.pulsar.policies.data.loadbalancer.BrokerData; +import org.apache.pulsar.policies.data.loadbalancer.BundleData; /** * This class represents all data that could be relevant when making a load management decision. diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/ModularLoadManager.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/ModularLoadManager.java index 265fe0e972213..b0ca2b5412408 100644 --- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/ModularLoadManager.java +++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/ModularLoadManager.java @@ -22,11 +22,11 @@ import java.util.Optional; import java.util.Set; import java.util.concurrent.CompletableFuture; -import org.apache.pulsar.broker.BundleData; import org.apache.pulsar.broker.PulsarServerException; import org.apache.pulsar.broker.PulsarService; import org.apache.pulsar.common.naming.ServiceUnitId; import org.apache.pulsar.common.stats.Metrics; +import org.apache.pulsar.policies.data.loadbalancer.BundleData; import org.apache.pulsar.policies.data.loadbalancer.LocalBrokerData; /** diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/ModularLoadManagerStrategy.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/ModularLoadManagerStrategy.java index c6b8adec6efb4..0143283d6381e 100644 --- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/ModularLoadManagerStrategy.java +++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/ModularLoadManagerStrategy.java @@ -20,9 +20,9 @@ import java.util.Optional; import java.util.Set; -import org.apache.pulsar.broker.BundleData; import org.apache.pulsar.broker.ServiceConfiguration; import org.apache.pulsar.broker.loadbalance.impl.LeastLongTermMessageRate; +import org.apache.pulsar.policies.data.loadbalancer.BundleData; /** * Interface which serves as a component for ModularLoadManagerImpl, flexibly allowing the injection of potentially diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/BrokerVersionFilter.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/BrokerVersionFilter.java index 99d1d82bb7eb8..db709cce978c0 100644 --- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/BrokerVersionFilter.java +++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/BrokerVersionFilter.java @@ -21,12 +21,12 @@ import com.github.zafarkhaja.semver.Version; import java.util.Iterator; import java.util.Set; -import org.apache.pulsar.broker.BrokerData; -import org.apache.pulsar.broker.BundleData; import org.apache.pulsar.broker.ServiceConfiguration; import org.apache.pulsar.broker.loadbalance.BrokerFilter; import org.apache.pulsar.broker.loadbalance.BrokerFilterBadVersionException; import org.apache.pulsar.broker.loadbalance.LoadData; +import org.apache.pulsar.policies.data.loadbalancer.BrokerData; +import org.apache.pulsar.policies.data.loadbalancer.BundleData; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/BundleSplitterTask.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/BundleSplitterTask.java index ac78cec2c3cf3..14f34ac1bb38f 100644 --- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/BundleSplitterTask.java +++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/BundleSplitterTask.java @@ -23,12 +23,12 @@ import java.util.Set; import org.apache.pulsar.broker.PulsarService; import org.apache.pulsar.broker.ServiceConfiguration; -import org.apache.pulsar.broker.TimeAverageMessageData; import org.apache.pulsar.broker.loadbalance.BundleSplitStrategy; import org.apache.pulsar.broker.loadbalance.LoadData; import org.apache.pulsar.common.naming.NamespaceName; import org.apache.pulsar.policies.data.loadbalancer.LocalBrokerData; import org.apache.pulsar.policies.data.loadbalancer.NamespaceBundleStats; +import org.apache.pulsar.policies.data.loadbalancer.TimeAverageMessageData; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/DeviationShedder.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/DeviationShedder.java index 9b8ed83d03d87..de2ce6cedc7de 100644 --- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/DeviationShedder.java +++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/DeviationShedder.java @@ -24,10 +24,10 @@ import java.util.TreeSet; import org.apache.commons.lang3.tuple.ImmutablePair; import org.apache.commons.lang3.tuple.Pair; -import org.apache.pulsar.broker.BrokerData; import org.apache.pulsar.broker.ServiceConfiguration; import org.apache.pulsar.broker.loadbalance.LoadData; import org.apache.pulsar.broker.loadbalance.LoadSheddingStrategy; +import org.apache.pulsar.policies.data.loadbalancer.BrokerData; /** * An abstract class which makes a LoadSheddingStrategy which makes decisions based on standard deviation easier to diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/LeastLongTermMessageRate.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/LeastLongTermMessageRate.java index 96a6f9af41ecb..6ac49ab2cf3bd 100644 --- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/LeastLongTermMessageRate.java +++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/LeastLongTermMessageRate.java @@ -22,14 +22,14 @@ import java.util.Optional; import java.util.Set; import java.util.concurrent.ThreadLocalRandom; -import org.apache.pulsar.broker.BrokerData; -import org.apache.pulsar.broker.BundleData; import org.apache.pulsar.broker.ServiceConfiguration; -import org.apache.pulsar.broker.TimeAverageBrokerData; -import org.apache.pulsar.broker.TimeAverageMessageData; import org.apache.pulsar.broker.loadbalance.LoadData; import org.apache.pulsar.broker.loadbalance.ModularLoadManagerStrategy; +import org.apache.pulsar.policies.data.loadbalancer.BrokerData; +import org.apache.pulsar.policies.data.loadbalancer.BundleData; import org.apache.pulsar.policies.data.loadbalancer.LocalBrokerData; +import org.apache.pulsar.policies.data.loadbalancer.TimeAverageBrokerData; +import org.apache.pulsar.policies.data.loadbalancer.TimeAverageMessageData; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/LoadManagerShared.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/LoadManagerShared.java index 7423485d7e176..cbaddc209a44c 100644 --- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/LoadManagerShared.java +++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/LoadManagerShared.java @@ -35,7 +35,6 @@ import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; import org.apache.commons.lang3.StringUtils; -import org.apache.pulsar.broker.BrokerData; import org.apache.pulsar.broker.PulsarService; import org.apache.pulsar.broker.loadbalance.BrokerHostUsage; import org.apache.pulsar.broker.loadbalance.LoadData; @@ -45,6 +44,7 @@ import org.apache.pulsar.common.util.FutureUtil; import org.apache.pulsar.common.util.collections.ConcurrentOpenHashMap; import org.apache.pulsar.common.util.collections.ConcurrentOpenHashSet; +import org.apache.pulsar.policies.data.loadbalancer.BrokerData; import org.apache.pulsar.policies.data.loadbalancer.ResourceUsage; import org.apache.pulsar.policies.data.loadbalancer.SystemResourceUsage; import org.slf4j.Logger; diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/ModularLoadManagerImpl.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/ModularLoadManagerImpl.java index f9438a5656302..19e00000bc900 100644 --- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/ModularLoadManagerImpl.java +++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/ModularLoadManagerImpl.java @@ -46,13 +46,9 @@ import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.SystemUtils; -import org.apache.pulsar.broker.BrokerData; -import org.apache.pulsar.broker.BundleData; import org.apache.pulsar.broker.PulsarServerException; import org.apache.pulsar.broker.PulsarService; import org.apache.pulsar.broker.ServiceConfiguration; -import org.apache.pulsar.broker.TimeAverageBrokerData; -import org.apache.pulsar.broker.TimeAverageMessageData; import org.apache.pulsar.broker.loadbalance.BrokerFilter; import org.apache.pulsar.broker.loadbalance.BrokerFilterException; import org.apache.pulsar.broker.loadbalance.BrokerHostUsage; @@ -83,9 +79,13 @@ import org.apache.pulsar.metadata.api.coordination.LockManager; import org.apache.pulsar.metadata.api.coordination.ResourceLock; import org.apache.pulsar.metadata.api.extended.SessionEvent; +import org.apache.pulsar.policies.data.loadbalancer.BrokerData; +import org.apache.pulsar.policies.data.loadbalancer.BundleData; import org.apache.pulsar.policies.data.loadbalancer.LocalBrokerData; import org.apache.pulsar.policies.data.loadbalancer.NamespaceBundleStats; import org.apache.pulsar.policies.data.loadbalancer.SystemResourceUsage; +import org.apache.pulsar.policies.data.loadbalancer.TimeAverageBrokerData; +import org.apache.pulsar.policies.data.loadbalancer.TimeAverageMessageData; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/OverloadShedder.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/OverloadShedder.java index 985ed6fd5f81e..1eff3dd250a44 100644 --- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/OverloadShedder.java +++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/OverloadShedder.java @@ -24,12 +24,12 @@ import org.apache.commons.lang3.mutable.MutableBoolean; import org.apache.commons.lang3.mutable.MutableDouble; import org.apache.commons.lang3.tuple.Pair; -import org.apache.pulsar.broker.BundleData; import org.apache.pulsar.broker.ServiceConfiguration; -import org.apache.pulsar.broker.TimeAverageMessageData; import org.apache.pulsar.broker.loadbalance.LoadData; import org.apache.pulsar.broker.loadbalance.LoadSheddingStrategy; +import org.apache.pulsar.policies.data.loadbalancer.BundleData; import org.apache.pulsar.policies.data.loadbalancer.LocalBrokerData; +import org.apache.pulsar.policies.data.loadbalancer.TimeAverageMessageData; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/ThresholdShedder.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/ThresholdShedder.java index 99f2ea56301fd..586a2fe101269 100644 --- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/ThresholdShedder.java +++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/ThresholdShedder.java @@ -25,13 +25,13 @@ import org.apache.commons.lang3.mutable.MutableBoolean; import org.apache.commons.lang3.mutable.MutableDouble; import org.apache.commons.lang3.tuple.Pair; -import org.apache.pulsar.broker.BrokerData; -import org.apache.pulsar.broker.BundleData; import org.apache.pulsar.broker.ServiceConfiguration; -import org.apache.pulsar.broker.TimeAverageMessageData; import org.apache.pulsar.broker.loadbalance.LoadData; import org.apache.pulsar.broker.loadbalance.LoadSheddingStrategy; +import org.apache.pulsar.policies.data.loadbalancer.BrokerData; +import org.apache.pulsar.policies.data.loadbalancer.BundleData; import org.apache.pulsar.policies.data.loadbalancer.LocalBrokerData; +import org.apache.pulsar.policies.data.loadbalancer.TimeAverageMessageData; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/UniformLoadShedder.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/UniformLoadShedder.java index 0f3256ca7adc8..645019c0ddf00 100644 --- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/UniformLoadShedder.java +++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/UniformLoadShedder.java @@ -26,13 +26,13 @@ import org.apache.commons.lang3.mutable.MutableInt; import org.apache.commons.lang3.mutable.MutableObject; import org.apache.commons.lang3.tuple.Triple; -import org.apache.pulsar.broker.BrokerData; -import org.apache.pulsar.broker.BundleData; import org.apache.pulsar.broker.ServiceConfiguration; -import org.apache.pulsar.broker.TimeAverageMessageData; import org.apache.pulsar.broker.loadbalance.LoadData; import org.apache.pulsar.broker.loadbalance.LoadSheddingStrategy; +import org.apache.pulsar.policies.data.loadbalancer.BrokerData; +import org.apache.pulsar.policies.data.loadbalancer.BundleData; import org.apache.pulsar.policies.data.loadbalancer.LocalBrokerData; +import org.apache.pulsar.policies.data.loadbalancer.TimeAverageMessageData; /** * This strategy tends to distribute load uniformly across all brokers. This strategy checks load difference between diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/common/naming/NamespaceBundleFactory.java b/pulsar-broker/src/main/java/org/apache/pulsar/common/naming/NamespaceBundleFactory.java index 9b7a0ec64c4ee..76dd73cfaa765 100644 --- a/pulsar-broker/src/main/java/org/apache/pulsar/common/naming/NamespaceBundleFactory.java +++ b/pulsar-broker/src/main/java/org/apache/pulsar/common/naming/NamespaceBundleFactory.java @@ -45,7 +45,6 @@ import java.util.concurrent.TimeUnit; import org.apache.commons.lang3.tuple.ImmutablePair; import org.apache.commons.lang3.tuple.Pair; -import org.apache.pulsar.broker.BundleData; import org.apache.pulsar.broker.PulsarService; import org.apache.pulsar.broker.loadbalance.LoadManager; import org.apache.pulsar.broker.loadbalance.impl.ModularLoadManagerWrapper; @@ -57,6 +56,7 @@ import org.apache.pulsar.common.policies.data.Policies; import org.apache.pulsar.metadata.api.MetadataCache; import org.apache.pulsar.metadata.api.Notification; +import org.apache.pulsar.policies.data.loadbalancer.BundleData; import org.apache.pulsar.stats.CacheMetricsCollector; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/broker/TimeAverageBrokerDataTest.java b/pulsar-broker/src/test/java/org/apache/pulsar/broker/TimeAverageBrokerDataTest.java index 091fd7ada66b4..1993c718aa542 100644 --- a/pulsar-broker/src/test/java/org/apache/pulsar/broker/TimeAverageBrokerDataTest.java +++ b/pulsar-broker/src/test/java/org/apache/pulsar/broker/TimeAverageBrokerDataTest.java @@ -24,6 +24,9 @@ import java.util.HashSet; import java.util.Map; import java.util.Set; +import org.apache.pulsar.policies.data.loadbalancer.BundleData; +import org.apache.pulsar.policies.data.loadbalancer.TimeAverageBrokerData; +import org.apache.pulsar.policies.data.loadbalancer.TimeAverageMessageData; import org.testng.annotations.Test; diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/broker/loadbalance/BrokerVersionFilterTest.java b/pulsar-broker/src/test/java/org/apache/pulsar/broker/loadbalance/BrokerVersionFilterTest.java index ae0a8c3234efc..ebf08e6932de3 100644 --- a/pulsar-broker/src/test/java/org/apache/pulsar/broker/loadbalance/BrokerVersionFilterTest.java +++ b/pulsar-broker/src/test/java/org/apache/pulsar/broker/loadbalance/BrokerVersionFilterTest.java @@ -21,10 +21,10 @@ import java.util.Set; import java.util.TreeSet; -import org.apache.pulsar.broker.BrokerData; import org.apache.pulsar.broker.ServiceConfiguration; import org.apache.pulsar.broker.loadbalance.impl.BrokerVersionFilter; import org.apache.pulsar.policies.data.loadbalancer.LocalBrokerData; +import org.apache.pulsar.policies.data.loadbalancer.BrokerData; import org.testng.Assert; import org.testng.annotations.Test; diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/broker/loadbalance/ModularLoadManagerImplTest.java b/pulsar-broker/src/test/java/org/apache/pulsar/broker/loadbalance/ModularLoadManagerImplTest.java index 22629cc73173b..9d4f80860d8eb 100644 --- a/pulsar-broker/src/test/java/org/apache/pulsar/broker/loadbalance/ModularLoadManagerImplTest.java +++ b/pulsar-broker/src/test/java/org/apache/pulsar/broker/loadbalance/ModularLoadManagerImplTest.java @@ -48,13 +48,9 @@ import java.util.concurrent.atomic.AtomicReference; import java.util.function.Supplier; import lombok.extern.slf4j.Slf4j; -import org.apache.pulsar.broker.BrokerData; -import org.apache.pulsar.broker.BundleData; import org.apache.pulsar.broker.PulsarServerException; import org.apache.pulsar.broker.PulsarService; import org.apache.pulsar.broker.ServiceConfiguration; -import org.apache.pulsar.broker.TimeAverageBrokerData; -import org.apache.pulsar.broker.TimeAverageMessageData; import org.apache.pulsar.broker.loadbalance.impl.LoadManagerShared; import org.apache.pulsar.broker.loadbalance.impl.LoadManagerShared.BrokerTopicLoadingPredicate; import org.apache.pulsar.broker.loadbalance.impl.ModularLoadManagerImpl; @@ -78,6 +74,10 @@ import org.apache.pulsar.policies.data.loadbalancer.NamespaceBundleStats; import org.apache.pulsar.policies.data.loadbalancer.ResourceUsage; import org.apache.pulsar.policies.data.loadbalancer.SystemResourceUsage; +import org.apache.pulsar.policies.data.loadbalancer.BrokerData; +import org.apache.pulsar.policies.data.loadbalancer.BundleData; +import org.apache.pulsar.policies.data.loadbalancer.TimeAverageBrokerData; +import org.apache.pulsar.policies.data.loadbalancer.TimeAverageMessageData; import org.apache.pulsar.zookeeper.LocalBookkeeperEnsemble; import org.awaitility.Awaitility; import org.mockito.Mockito; diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/broker/loadbalance/ModularLoadManagerStrategyTest.java b/pulsar-broker/src/test/java/org/apache/pulsar/broker/loadbalance/ModularLoadManagerStrategyTest.java index dffb4d6d7e95f..c767a650c47c2 100644 --- a/pulsar-broker/src/test/java/org/apache/pulsar/broker/loadbalance/ModularLoadManagerStrategyTest.java +++ b/pulsar-broker/src/test/java/org/apache/pulsar/broker/loadbalance/ModularLoadManagerStrategyTest.java @@ -23,13 +23,14 @@ import java.util.Map; import java.util.Optional; -import org.apache.pulsar.broker.BrokerData; -import org.apache.pulsar.broker.BundleData; + import org.apache.pulsar.broker.ServiceConfiguration; -import org.apache.pulsar.broker.TimeAverageBrokerData; import org.apache.pulsar.broker.loadbalance.impl.LeastLongTermMessageRate; import org.apache.pulsar.policies.data.loadbalancer.LocalBrokerData; import org.apache.pulsar.policies.data.loadbalancer.ResourceUsage; +import org.apache.pulsar.policies.data.loadbalancer.BrokerData; +import org.apache.pulsar.policies.data.loadbalancer.BundleData; +import org.apache.pulsar.policies.data.loadbalancer.TimeAverageBrokerData; import org.testng.annotations.Test; @Test(groups = "broker") diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/broker/loadbalance/impl/BundleSplitterTaskTest.java b/pulsar-broker/src/test/java/org/apache/pulsar/broker/loadbalance/impl/BundleSplitterTaskTest.java index 0b10624f105a0..e9d93b46c173f 100644 --- a/pulsar-broker/src/test/java/org/apache/pulsar/broker/loadbalance/impl/BundleSplitterTaskTest.java +++ b/pulsar-broker/src/test/java/org/apache/pulsar/broker/loadbalance/impl/BundleSplitterTaskTest.java @@ -19,14 +19,14 @@ package org.apache.pulsar.broker.loadbalance.impl; import lombok.extern.slf4j.Slf4j; -import org.apache.pulsar.broker.BrokerData; -import org.apache.pulsar.broker.BundleData; import org.apache.pulsar.broker.PulsarService; import org.apache.pulsar.broker.ServiceConfiguration; -import org.apache.pulsar.broker.TimeAverageMessageData; import org.apache.pulsar.broker.loadbalance.LoadData; +import org.apache.pulsar.policies.data.loadbalancer.BrokerData; +import org.apache.pulsar.policies.data.loadbalancer.BundleData; import org.apache.pulsar.policies.data.loadbalancer.LocalBrokerData; import org.apache.pulsar.policies.data.loadbalancer.NamespaceBundleStats; +import org.apache.pulsar.policies.data.loadbalancer.TimeAverageMessageData; import org.apache.pulsar.zookeeper.LocalBookkeeperEnsemble; import org.testng.Assert; import org.testng.annotations.AfterMethod; diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/broker/loadbalance/impl/OverloadShedderTest.java b/pulsar-broker/src/test/java/org/apache/pulsar/broker/loadbalance/impl/OverloadShedderTest.java index f14cb4390e17e..84b24fc3121e3 100644 --- a/pulsar-broker/src/test/java/org/apache/pulsar/broker/loadbalance/impl/OverloadShedderTest.java +++ b/pulsar-broker/src/test/java/org/apache/pulsar/broker/loadbalance/impl/OverloadShedderTest.java @@ -26,13 +26,13 @@ import com.google.common.collect.Multimap; import com.google.common.collect.Sets; -import org.apache.pulsar.broker.BrokerData; -import org.apache.pulsar.broker.BundleData; import org.apache.pulsar.broker.ServiceConfiguration; -import org.apache.pulsar.broker.TimeAverageMessageData; import org.apache.pulsar.broker.loadbalance.LoadData; import org.apache.pulsar.policies.data.loadbalancer.LocalBrokerData; import org.apache.pulsar.policies.data.loadbalancer.ResourceUsage; +import org.apache.pulsar.policies.data.loadbalancer.BrokerData; +import org.apache.pulsar.policies.data.loadbalancer.BundleData; +import org.apache.pulsar.policies.data.loadbalancer.TimeAverageMessageData; import org.testng.annotations.Test; @Test(groups = "broker") diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/broker/loadbalance/impl/ThresholdShedderTest.java b/pulsar-broker/src/test/java/org/apache/pulsar/broker/loadbalance/impl/ThresholdShedderTest.java index 4f6ad7f8c988d..4af7d784909b2 100644 --- a/pulsar-broker/src/test/java/org/apache/pulsar/broker/loadbalance/impl/ThresholdShedderTest.java +++ b/pulsar-broker/src/test/java/org/apache/pulsar/broker/loadbalance/impl/ThresholdShedderTest.java @@ -25,13 +25,13 @@ import com.google.common.collect.Multimap; import com.google.common.collect.Sets; import lombok.extern.slf4j.Slf4j; -import org.apache.pulsar.broker.BrokerData; -import org.apache.pulsar.broker.BundleData; import org.apache.pulsar.broker.ServiceConfiguration; -import org.apache.pulsar.broker.TimeAverageMessageData; import org.apache.pulsar.broker.loadbalance.LoadData; import org.apache.pulsar.policies.data.loadbalancer.LocalBrokerData; import org.apache.pulsar.policies.data.loadbalancer.ResourceUsage; +import org.apache.pulsar.policies.data.loadbalancer.BrokerData; +import org.apache.pulsar.policies.data.loadbalancer.BundleData; +import org.apache.pulsar.policies.data.loadbalancer.TimeAverageMessageData; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/broker/namespace/NamespaceServiceTest.java b/pulsar-broker/src/test/java/org/apache/pulsar/broker/namespace/NamespaceServiceTest.java index fc09648883f95..5c0ffebbeec83 100644 --- a/pulsar-broker/src/test/java/org/apache/pulsar/broker/namespace/NamespaceServiceTest.java +++ b/pulsar-broker/src/test/java/org/apache/pulsar/broker/namespace/NamespaceServiceTest.java @@ -47,7 +47,6 @@ import org.apache.bookkeeper.mledger.ManagedLedger; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang3.tuple.Pair; -import org.apache.pulsar.broker.BundleData; import org.apache.pulsar.broker.loadbalance.LoadManager; import org.apache.pulsar.broker.loadbalance.impl.ModularLoadManagerImpl; import org.apache.pulsar.broker.loadbalance.impl.ModularLoadManagerWrapper; @@ -73,6 +72,7 @@ import org.apache.pulsar.policies.data.loadbalancer.LoadReport; import org.apache.pulsar.policies.data.loadbalancer.LocalBrokerData; import org.apache.pulsar.policies.data.loadbalancer.NamespaceBundleStats; +import org.apache.pulsar.policies.data.loadbalancer.BundleData; import org.awaitility.Awaitility; import org.mockito.stubbing.Answer; import org.slf4j.Logger; diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/BrokerData.java b/pulsar-common/src/main/java/org/apache/pulsar/policies/data/loadbalancer/BrokerData.java similarity index 94% rename from pulsar-broker/src/main/java/org/apache/pulsar/broker/BrokerData.java rename to pulsar-common/src/main/java/org/apache/pulsar/policies/data/loadbalancer/BrokerData.java index 39d92dff916e4..91a9ec1bd412e 100644 --- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/BrokerData.java +++ b/pulsar-common/src/main/java/org/apache/pulsar/policies/data/loadbalancer/BrokerData.java @@ -16,12 +16,11 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.pulsar.broker; +package org.apache.pulsar.policies.data.loadbalancer; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import lombok.Data; -import org.apache.pulsar.policies.data.loadbalancer.LocalBrokerData; /** * Data class containing three components comprising all the data available for the leader broker about other brokers: - diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/BundleData.java b/pulsar-common/src/main/java/org/apache/pulsar/policies/data/loadbalancer/BundleData.java similarity index 97% rename from pulsar-broker/src/main/java/org/apache/pulsar/broker/BundleData.java rename to pulsar-common/src/main/java/org/apache/pulsar/policies/data/loadbalancer/BundleData.java index 552cba6cc71bf..3537acaee6d7c 100644 --- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/BundleData.java +++ b/pulsar-common/src/main/java/org/apache/pulsar/policies/data/loadbalancer/BundleData.java @@ -16,9 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.pulsar.broker; - -import org.apache.pulsar.policies.data.loadbalancer.NamespaceBundleStats; +package org.apache.pulsar.policies.data.loadbalancer; /** * Data class comprising the short term and long term historical data for this bundle. diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/TimeAverageBrokerData.java b/pulsar-common/src/main/java/org/apache/pulsar/policies/data/loadbalancer/TimeAverageBrokerData.java similarity index 97% rename from pulsar-broker/src/main/java/org/apache/pulsar/broker/TimeAverageBrokerData.java rename to pulsar-common/src/main/java/org/apache/pulsar/policies/data/loadbalancer/TimeAverageBrokerData.java index 0676a116ff10d..4d1e2057380db 100644 --- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/TimeAverageBrokerData.java +++ b/pulsar-common/src/main/java/org/apache/pulsar/policies/data/loadbalancer/TimeAverageBrokerData.java @@ -16,13 +16,12 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.pulsar.broker; +package org.apache.pulsar.policies.data.loadbalancer; import java.util.Map; import java.util.Set; import lombok.Data; import lombok.NoArgsConstructor; -import org.apache.pulsar.policies.data.loadbalancer.NamespaceBundleStats; /** * Data class aggregating the short term and long term data across all bundles belonging to a broker. diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/TimeAverageMessageData.java b/pulsar-common/src/main/java/org/apache/pulsar/policies/data/loadbalancer/TimeAverageMessageData.java similarity index 98% rename from pulsar-broker/src/main/java/org/apache/pulsar/broker/TimeAverageMessageData.java rename to pulsar-common/src/main/java/org/apache/pulsar/policies/data/loadbalancer/TimeAverageMessageData.java index fd0a34683b2f8..1512f896b2ea6 100644 --- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/TimeAverageMessageData.java +++ b/pulsar-common/src/main/java/org/apache/pulsar/policies/data/loadbalancer/TimeAverageMessageData.java @@ -16,9 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.pulsar.broker; - -import org.apache.pulsar.policies.data.loadbalancer.NamespaceBundleStats; +package org.apache.pulsar.policies.data.loadbalancer; /** * Data class comprising the average message data over a fixed period of time. diff --git a/pulsar-testclient/src/main/java/org/apache/pulsar/testclient/BrokerMonitor.java b/pulsar-testclient/src/main/java/org/apache/pulsar/testclient/BrokerMonitor.java index 7b56462bfe3d5..bb970dcf3173e 100644 --- a/pulsar-testclient/src/main/java/org/apache/pulsar/testclient/BrokerMonitor.java +++ b/pulsar-testclient/src/main/java/org/apache/pulsar/testclient/BrokerMonitor.java @@ -31,12 +31,12 @@ import java.util.Map; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; -import org.apache.pulsar.broker.TimeAverageBrokerData; import org.apache.pulsar.broker.loadbalance.impl.ModularLoadManagerImpl; import org.apache.pulsar.policies.data.loadbalancer.LoadReport; import org.apache.pulsar.policies.data.loadbalancer.LocalBrokerData; import org.apache.pulsar.policies.data.loadbalancer.ResourceUsage; import org.apache.pulsar.policies.data.loadbalancer.SystemResourceUsage; +import org.apache.pulsar.policies.data.loadbalancer.TimeAverageBrokerData; import org.apache.pulsar.testclient.utils.FixedColumnLengthTableMaker; import org.apache.zookeeper.WatchedEvent; import org.apache.zookeeper.Watcher; diff --git a/pulsar-testclient/src/main/java/org/apache/pulsar/testclient/LoadSimulationController.java b/pulsar-testclient/src/main/java/org/apache/pulsar/testclient/LoadSimulationController.java index b345b1b757eeb..91ea6e320c6da 100644 --- a/pulsar-testclient/src/main/java/org/apache/pulsar/testclient/LoadSimulationController.java +++ b/pulsar-testclient/src/main/java/org/apache/pulsar/testclient/LoadSimulationController.java @@ -40,10 +40,10 @@ import java.util.concurrent.Executors; import java.util.concurrent.Future; import org.apache.bookkeeper.util.ZkUtils; -import org.apache.pulsar.broker.BundleData; import org.apache.pulsar.broker.loadbalance.LoadManager; import org.apache.pulsar.common.policies.data.ResourceQuota; import org.apache.pulsar.common.util.ObjectMapperFactory; +import org.apache.pulsar.policies.data.loadbalancer.BundleData; import org.apache.pulsar.policies.data.loadbalancer.LoadReport; import org.apache.pulsar.policies.data.loadbalancer.NamespaceBundleStats; import org.apache.zookeeper.CreateMode;