use of com.netflix.control.clutch.ClutchConfiguration in project mantis by Netflix.
the class RpsScaleComputerTest method testApply.
@Test
public void testApply() {
ClutchRpsPIDConfig rpsConfig = new ClutchRpsPIDConfig(0.0, Tuple.of(0.0, 0.0), 0.0, 0.0, Option.none(), Option.of(40.0), Option.of(60.0), Option.of(2.0), Option.of(0.5));
RpsScaleComputer scaleComputer = new RpsScaleComputer(rpsConfig);
ClutchConfiguration config = ClutchConfiguration.builder().minSize(1).maxSize(1000).build();
double scale = scaleComputer.apply(config, 100L, 0.1);
assertEquals(100, scale, 1e-10);
scale = scaleComputer.apply(config, 100L, 0.5);
assertEquals(200, scale, 1e-10);
scale = scaleComputer.apply(config, 100L, -0.7);
assertEquals(65, scale, 1e-10);
}
use of com.netflix.control.clutch.ClutchConfiguration in project mantis by Netflix.
the class RpsClutchConfigurationSelectorTest method testReturnSameConfigIfSetPointWithin5Percent.
@Test
public void testReturnSameConfigIfSetPointWithin5Percent() {
UpdateDoublesSketch rpsSketch = UpdateDoublesSketch.builder().setK(1024).build();
for (int i = 1; i <= 100; i++) {
rpsSketch.update(i);
}
Map<Clutch.Metric, UpdateDoublesSketch> sketches = ImmutableMap.of(Clutch.Metric.RPS, rpsSketch);
StageScalingPolicy scalingPolicy = new StageScalingPolicy(1, 2, 9, 0, 0, 400L, null);
StageSchedulingInfo schedulingInfo = StageSchedulingInfo.builder().numberOfInstances(3).scalingPolicy(scalingPolicy).scalable(true).build();
RpsClutchConfigurationSelector selector = new RpsClutchConfigurationSelector(1, schedulingInfo, null);
ClutchConfiguration config = selector.apply(sketches);
assertEquals(76.0, config.getSetPoint(), 1e-10);
for (int i = 101; i <= 105; i++) {
rpsSketch.update(i);
}
ClutchConfiguration newConfig = selector.apply(sketches);
// Instance equality
assertTrue(config == newConfig);
for (int i = 106; i < 110; i++) {
rpsSketch.update(i);
}
newConfig = selector.apply(sketches);
assertTrue(config != newConfig);
assertEquals(82.0, newConfig.getSetPoint(), 1e-10);
}
use of com.netflix.control.clutch.ClutchConfiguration in project mantis by Netflix.
the class RpsClutchConfigurationSelectorTest method testSetPointDriftAdjust.
@Test
public void testSetPointDriftAdjust() {
UpdateDoublesSketch rpsSketch = UpdateDoublesSketch.builder().setK(1024).build();
for (int i = 1; i <= 100; i++) {
if (i <= 76) {
rpsSketch.update(i);
} else {
rpsSketch.update(1000 + i);
}
}
Map<Clutch.Metric, UpdateDoublesSketch> sketches = ImmutableMap.of(Clutch.Metric.RPS, rpsSketch);
StageScalingPolicy scalingPolicy = new StageScalingPolicy(1, 2, 9, 0, 0, 400L, null);
StageSchedulingInfo schedulingInfo = StageSchedulingInfo.builder().numberOfInstances(3).scalingPolicy(scalingPolicy).scalable(true).build();
RpsClutchConfigurationSelector selector = new RpsClutchConfigurationSelector(1, schedulingInfo, null);
ClutchConfiguration config = selector.apply(sketches);
assertEquals(83.6, config.getSetPoint(), 1e-10);
}
Aggregations