netflix.ocelli.functions.Weightings Maven / Gradle / Ivy
package netflix.ocelli.functions;
import rx.functions.Func1;
import netflix.ocelli.loadbalancer.weighting.EqualWeightStrategy;
import netflix.ocelli.loadbalancer.weighting.InverseMaxWeightingStrategy;
import netflix.ocelli.loadbalancer.weighting.LinearWeightingStrategy;
import netflix.ocelli.loadbalancer.weighting.WeightingStrategy;
public abstract class Weightings {
/**
* @return Strategy that provides a uniform weight to each client
*/
public static WeightingStrategy uniform() {
return new EqualWeightStrategy();
}
/**
* @param func
* @return Strategy that uses the output of the function as the weight
*/
public static WeightingStrategy identity(Func1 func) {
return new LinearWeightingStrategy(func);
}
/**
* @param func
* @return Strategy that sets the weight to the difference between the max
* value of all clients and the client value.
*/
public static WeightingStrategy inverseMax(Func1 func) {
return new InverseMaxWeightingStrategy(func);
}
}