From 834c320d72feffaa40f3a37dbfea7c68c9fd474b Mon Sep 17 00:00:00 2001 From: Cancai Cai <77189278+caicancai@users.noreply.github.com> Date: Fri, 14 Jun 2024 11:57:21 +0800 Subject: [PATCH] [Imporve][Master] Refine the doselect annotation of the distribution policy (#16149) --- .../dispatch/host/assign/LowerWeightRoundRobin.java | 8 +++++--- .../master/dispatch/host/assign/RandomSelector.java | 8 ++++++++ .../master/dispatch/host/assign/RoundRobinSelector.java | 8 ++++++++ 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/dispatch/host/assign/LowerWeightRoundRobin.java b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/dispatch/host/assign/LowerWeightRoundRobin.java index d03fd59ada..9c3c4fd696 100644 --- a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/dispatch/host/assign/LowerWeightRoundRobin.java +++ b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/dispatch/host/assign/LowerWeightRoundRobin.java @@ -25,10 +25,12 @@ import java.util.Collection; public class LowerWeightRoundRobin extends AbstractSelector { /** - * select + * Selects a HostWeight from a collection of HostWeight objects. + * The selection is based on the current weight of each HostWeight. + * The HostWeight with the smallest current weight is selected. * - * @param sources sources - * @return HostWeight + * @param sources A collection of HostWeight objects to select from. + * @return The selected HostWeight with the smallest current weight. */ @Override public HostWeight doSelect(Collection sources) { diff --git a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/dispatch/host/assign/RandomSelector.java b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/dispatch/host/assign/RandomSelector.java index 2b7488a370..a0f83232a2 100644 --- a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/dispatch/host/assign/RandomSelector.java +++ b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/dispatch/host/assign/RandomSelector.java @@ -27,6 +27,14 @@ import java.util.concurrent.ThreadLocalRandom; */ public class RandomSelector extends AbstractSelector { + /** + * This method selects a HostWorker from a collection of HostWorker objects using a weighted random algorithm. + * The selection is based on the weight of each HostWorker. + * A random number is generated and the HostWorker whose weight spans this random number is selected. + * + * @param source A collection of HostWorker objects to select from. + * @return The selected HostWorker based on the weighted random algorithm. + */ @Override public HostWorker doSelect(final Collection source) { diff --git a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/dispatch/host/assign/RoundRobinSelector.java b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/dispatch/host/assign/RoundRobinSelector.java index 8f21acef6d..b47eff87b9 100644 --- a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/dispatch/host/assign/RoundRobinSelector.java +++ b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/dispatch/host/assign/RoundRobinSelector.java @@ -73,6 +73,14 @@ public class RoundRobinSelector extends AbstractSelector { } + /** + * This method selects a HostWorker from a collection of HostWorker objects using a weighted round-robin algorithm. + * The selection is based on the current weight of each HostWorker. + * The HostWorker with the highest current weight is selected. + * + * @param source A collection of HostWorker objects to select from. + * @return The selected HostWorker with the highest current weight. + */ @Override public HostWorker doSelect(Collection source) {