[Imporve][Master] Refine the doselect annotation of the distribution policy (#16149)

This commit is contained in:
Cancai Cai 2024-06-14 11:57:21 +08:00 committed by GitHub
parent 8d0202ccaf
commit 834c320d72
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 21 additions and 3 deletions

View File

@ -25,10 +25,12 @@ import java.util.Collection;
public class LowerWeightRoundRobin extends AbstractSelector<HostWeight> {
/**
* 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<HostWeight> sources) {

View File

@ -27,6 +27,14 @@ import java.util.concurrent.ThreadLocalRandom;
*/
public class RandomSelector extends AbstractSelector<HostWorker> {
/**
* 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<HostWorker> source) {

View File

@ -73,6 +73,14 @@ public class RoundRobinSelector extends AbstractSelector<HostWorker> {
}
/**
* 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<HostWorker> source) {