codelipenghui commented on code in PR #19560:
URL: https://github.com/apache/pulsar/pull/19560#discussion_r1117908214
##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/ThresholdShedder.java:
##########
@@ -233,5 +237,23 @@ private Pair<Boolean, String> getMaxUsageBroker(
}
return Pair.of(hasBrokerBelowLowerBound, maxUsageBrokerName);
}
+ @Override
+ public void onBrokerChange(Set<String> newBrokers) {
+ synchronized (activeBrokers) {
+ activeBrokers.clear();
+ activeBrokers.addAll(newBrokers);
+ }
Review Comment:
Why not update the `brokerAvgResourceUsage` without maintaining a new
`activeBrokers` map?
##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/LoadSheddingStrategy.java:
##########
@@ -36,4 +37,11 @@ public interface LoadSheddingStrategy {
* @return A map from all selected bundles to the brokers on which they
reside.
*/
Multimap<String, String> findBundlesForUnloading(LoadData loadData,
ServiceConfiguration conf);
+
+ /**
+ * Triggered when active broker changes.
+ *
+ * @param activeBrokers active Brokers
+ */
+ default void onBrokerChange(Set<String> activeBrokers) {}
Review Comment:
```suggestion
default void onActiveBrokersChange(Set<String> activeBrokers) {}
```
##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/LoadSheddingStrategy.java:
##########
@@ -36,4 +37,11 @@ public interface LoadSheddingStrategy {
* @return A map from all selected bundles to the brokers on which they
reside.
*/
Multimap<String, String> findBundlesForUnloading(LoadData loadData,
ServiceConfiguration conf);
+
+ /**
+ * Triggered when active broker changes.
+ *
+ * @param activeBrokers active Brokers
+ */
+ default void onBrokerChange(Set<String> activeBrokers) {}
Review Comment:
Is it better to introduce an event listener interface to the LoadManager?
Not all load shedding strategies are required the broker's change event. So who
cares about the event, then add the listener to the load manager.
--
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]