heesung-sn commented on code in PR #21085:
URL: https://github.com/apache/pulsar/pull/21085#discussion_r1309136466
##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/ModularLoadManagerImpl.java:
##########
@@ -1139,6 +1143,23 @@ public void writeBrokerDataOnZooKeeper(boolean force) {
}
}
+ /**
+ * sort bundles by load and select topK bundles for each broker.
+ * @return the number of bundles selected
+ */
+ private int selectTopKBundle() {
+ bundleArr.clear();
+
+ bundleArr.addAll(loadData.getBundleData().entrySet());
Review Comment:
Are these thread-safe?
##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/ModularLoadManagerImpl.java:
##########
@@ -1139,6 +1143,23 @@ public void writeBrokerDataOnZooKeeper(boolean force) {
}
}
+ /**
+ * sort bundles by load and select topK bundles for each broker.
+ * @return the number of bundles selected
+ */
+ private int selectTopKBundle() {
+ bundleArr.clear();
+
+ bundleArr.addAll(loadData.getBundleData().entrySet());
+ // select topK bundle for each broker, so select topK * brokerCount
bundle in total
+ int brokerCount = loadData.getBrokerData().size();
Review Comment:
can brokerCount be 0? are we handling this case?
##########
pulsar-common/src/main/java/org/apache/pulsar/policies/data/loadbalancer/TimeAverageMessageData.java:
##########
@@ -177,4 +175,40 @@ public double totalMsgRate() {
public double totalMsgThroughput() {
return msgThroughputIn + msgThroughputOut;
}
+
+ @Override
+ public int compareTo(TimeAverageMessageData other) {
+ int result = this.compareByBandwidthIn(other);
+
+ if (result == 0) {
+ result = this.compareByBandwidthOut(other);
+ }
Review Comment:
Why do we have separate bandwithIn and Out checks here? What if some
bundles' bandwithOut is way greater than bandwithIn?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]