Search in sources :

Example 21 with LoadBalancerStrategyTestRunnerBuilder

use of com.linkedin.d2.balancer.strategies.framework.LoadBalancerStrategyTestRunnerBuilder in project rest.li by linkedin.

the class TestLoadBalancerPerformanceSimulation method buildRelativeRunnerWithRandomLatencyInRange.

private LoadBalancerStrategyTestRunner buildRelativeRunnerWithRandomLatencyInRange(boolean isFastRecovery, long badHostBaseLatency, long regularBaseLatency) {
    int numHosts = 20;
    int numRequestsPerInterval = 20;
    List<LatencyCorrelation> latencyCorrelationList = new ArrayList<>();
    long leftLimit = 0L;
    long rightLimit = 400L;
    latencyCorrelationList.add((requestsPerInterval, intervalIndex) -> badHostBaseLatency + (long) (Math.random() * (rightLimit - leftLimit)));
    for (int i = 1; i < numHosts; i++) {
        latencyCorrelationList.add((requestsPerInterval, intervalIndex) -> regularBaseLatency + (long) (Math.random() * (rightLimit - leftLimit)));
    }
    D2RelativeStrategyProperties relativeStrategyProperties = new D2RelativeStrategyProperties().setEnableFastRecovery(isFastRecovery);
    return new LoadBalancerStrategyTestRunnerBuilder(loadBalancerStrategyType.RELATIVE, DEFAULT_SERVICE_NAME, numHosts).setConstantRequestCount(numRequestsPerInterval).setNumIntervals(200).setDynamicLatency(latencyCorrelationList).setRelativeLoadBalancerStrategies(relativeStrategyProperties).build();
}
Also used : LatencyCorrelation(com.linkedin.d2.balancer.strategies.framework.LatencyCorrelation) LoadBalancerStrategyTestRunnerBuilder(com.linkedin.d2.balancer.strategies.framework.LoadBalancerStrategyTestRunnerBuilder) ArrayList(java.util.ArrayList) D2RelativeStrategyProperties(com.linkedin.d2.D2RelativeStrategyProperties)

Example 22 with LoadBalancerStrategyTestRunnerBuilder

use of com.linkedin.d2.balancer.strategies.framework.LoadBalancerStrategyTestRunnerBuilder in project rest.li by linkedin.

the class TestLoadBalancerPerformanceSimulation method buildRelativeRunnerWithDifferentLatency.

private LoadBalancerStrategyTestRunner buildRelativeRunnerWithDifferentLatency(double relativeLatencyHighThresholdFactor) {
    int minBaseLatency = 100;
    int baseLatencyDiff = 20;
    int numHosts = 10;
    double hostLinearFactor = 0.05;
    List<LatencyCorrelation> latencyCorrelationList = new ArrayList<>();
    for (int i = 0; i < numHosts; i++) {
        long baseLatency = i * baseLatencyDiff + minBaseLatency;
        latencyCorrelationList.add((requestsPerInterval, intervalIndex) -> baseLatency + (long) (hostLinearFactor * requestsPerInterval));
    }
    D2RelativeStrategyProperties relativeStrategyProperties = new D2RelativeStrategyProperties().setRelativeLatencyHighThresholdFactor(relativeLatencyHighThresholdFactor);
    return new LoadBalancerStrategyTestRunnerBuilder(loadBalancerStrategyType.RELATIVE, DEFAULT_SERVICE_NAME, numHosts).setConstantRequestCount(10000).setNumIntervals(100).setDynamicLatency(latencyCorrelationList).setRelativeLoadBalancerStrategies(relativeStrategyProperties).build();
}
Also used : LatencyCorrelation(com.linkedin.d2.balancer.strategies.framework.LatencyCorrelation) LoadBalancerStrategyTestRunnerBuilder(com.linkedin.d2.balancer.strategies.framework.LoadBalancerStrategyTestRunnerBuilder) ArrayList(java.util.ArrayList) D2RelativeStrategyProperties(com.linkedin.d2.D2RelativeStrategyProperties)

Example 23 with LoadBalancerStrategyTestRunnerBuilder

use of com.linkedin.d2.balancer.strategies.framework.LoadBalancerStrategyTestRunnerBuilder in project rest.li by linkedin.

the class TestLoadBalancerPerformanceSimulation method buildDefaultRunnerWithRecoveringBadHost.

private LoadBalancerStrategyTestRunner buildDefaultRunnerWithRecoveringBadHost(int numHosts, LatencyCorrelation recoveringHostLatencyCorrelation, double relativeLatencyLowThresholdFactor) {
    List<LatencyCorrelation> latencyCorrelationList = new ArrayList<>();
    latencyCorrelationList.add(recoveringHostLatencyCorrelation);
    for (int i = 0; i < numHosts - 1; i++) {
        latencyCorrelationList.add(HEALTHY_HOST_LATENCY_CORRELATION);
    }
    D2RelativeStrategyProperties relativeStrategyProperties = new D2RelativeStrategyProperties().setRelativeLatencyLowThresholdFactor(relativeLatencyLowThresholdFactor).setRelativeLatencyHighThresholdFactor(1.5);
    return new LoadBalancerStrategyTestRunnerBuilder(loadBalancerStrategyType.RELATIVE, DEFAULT_SERVICE_NAME, numHosts).setConstantRequestCount(DEFAULT_REQUESTS_PER_INTERVAL).setNumIntervals(200).setDynamicLatency(latencyCorrelationList).setRelativeLoadBalancerStrategies(relativeStrategyProperties).build();
}
Also used : LatencyCorrelation(com.linkedin.d2.balancer.strategies.framework.LatencyCorrelation) LoadBalancerStrategyTestRunnerBuilder(com.linkedin.d2.balancer.strategies.framework.LoadBalancerStrategyTestRunnerBuilder) ArrayList(java.util.ArrayList) D2RelativeStrategyProperties(com.linkedin.d2.D2RelativeStrategyProperties)

Aggregations

LoadBalancerStrategyTestRunnerBuilder (com.linkedin.d2.balancer.strategies.framework.LoadBalancerStrategyTestRunnerBuilder)22 D2RelativeStrategyProperties (com.linkedin.d2.D2RelativeStrategyProperties)17 LoadBalancerStrategyTestRunner (com.linkedin.d2.balancer.strategies.framework.LoadBalancerStrategyTestRunner)17 Test (org.testng.annotations.Test)17 HashMap (java.util.HashMap)15 URI (java.net.URI)9 ArrayList (java.util.ArrayList)5 D2QuarantineProperties (com.linkedin.d2.D2QuarantineProperties)4 LatencyCorrelation (com.linkedin.d2.balancer.strategies.framework.LatencyCorrelation)4 PartitionData (com.linkedin.d2.balancer.properties.PartitionData)3 HttpStatusCodeRange (com.linkedin.d2.HttpStatusCodeRange)1 HttpStatusCodeRangeArray (com.linkedin.d2.HttpStatusCodeRangeArray)1 ServiceProperties (com.linkedin.d2.balancer.properties.ServiceProperties)1