i3wangyi commented on a change in pull request #422: Redefine the hard/soft constraints URL: https://github.com/apache/helix/pull/422#discussion_r315956128
########## File path: helix-core/src/main/java/org/apache/helix/controller/rebalancer/waged/constraints/SoftConstraint.java ########## @@ -27,23 +27,31 @@ * Evaluate a partition allocation proposal and return a score within the normalized range. * A higher score means the proposal is more preferred. */ -public interface SoftConstraint { - float MIN_SCORE = -1000.0f; - float MAX_SCORE = 1000.0f; +public abstract class SoftConstraint { + private Type _type; - /** - * The scoring function returns a score between MINIMAL_SCORE and MAXIMUM_SCORE, which is then weighted by the - * individual normalized constraint weights. - * Each individual constraint will define the meaning of MINIMAL_SCORE to MAXIMUM_SCORE differently. - */ - float assignmentScore(AssignableNode node, AssignableReplica rep, ClusterContext clusterContext); + public SoftConstraint(Type type) { + _type = type; + } + + enum Type { + LEAST_USED_NODE, + LEAST_PARTITION_COUNT, + LEAST_MOVEMENTS + } /** - * Set the importance factor of the soft constraint. - * The more important it is, the more contribution it will make to the final evaluation. - * @param importance + * The scoring function returns a score between MINIMAL_SCORE and MAXIMUM_SCORE, which is then Review comment: How about adding one more abstract method in SoftConstraint class. Child class either creates their own or inherit the base scale function from the abstract base class. `ScaleFunction getScaleFunction();` Then the `WeightModel` class will basically ``` foreach softconstraint s: score = s.getScaleFunction().apply(s.getscore()); ``` It's cleaner IMO and allow each child class to customize own its own. ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@helix.apache.org For additional commands, e-mail: reviews-h...@helix.apache.org