All Downloads are FREE. Search and download functionalities are using the official Maven repository.

netflix.ocelli.functions.Weightings Maven / Gradle / Ivy

There is a newer version: 0.1.0-rc.2
Show newest version
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);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy