use of io.mantisrx.runtime.descriptor.StageScalingPolicy in project mantis by Netflix.
the class DataFormatAdapterTest method convertMantisStageMetaTest.
@Test
public void convertMantisStageMetaTest() {
Map<StageScalingPolicy.ScalingReason, StageScalingPolicy.Strategy> smap = new HashMap<>();
smap.put(StageScalingPolicy.ScalingReason.CPU, new StageScalingPolicy.Strategy(StageScalingPolicy.ScalingReason.CPU, 0.5, 0.75, null));
smap.put(StageScalingPolicy.ScalingReason.DataDrop, new StageScalingPolicy.Strategy(StageScalingPolicy.ScalingReason.DataDrop, 0.0, 2.0, null));
int stageNo = 1;
int min = 3;
int max = 10;
int increment = 1;
int decrement = 1;
int coolDownSecs = 300;
StageScalingPolicy stageScalingPolicy = new StageScalingPolicy(stageNo, min, max, increment, decrement, coolDownSecs, smap);
List<JobConstraints> softConstraintsList = new ArrayList<>();
softConstraintsList.add(JobConstraints.ExclusiveHost);
List<JobConstraints> hardConstraintsList = new ArrayList<>();
hardConstraintsList.add(JobConstraints.M3Cluster);
JobId jobId = new JobId("cName", 1);
int numWorkers = 1;
int numStages = 2;
boolean isScalable = true;
IMantisStageMetadata stageMeta = new MantisStageMetadataImpl.Builder().withStageNum(stageNo).withScalingPolicy(stageScalingPolicy).withNumWorkers(numWorkers).withMachineDefinition(DEFAULT_MACHINE_DEFINITION).withNumStages(numStages).withSoftConstraints(softConstraintsList).withHardConstraints(hardConstraintsList).withJobId(jobId).isScalable(isScalable).build();
MantisStageMetadataWritable stageMetadataWritable = DataFormatAdapter.convertMantisStageMetadataToMantisStageMetadataWriteable(stageMeta);
assertEquals(jobId.getId(), stageMetadataWritable.getJobId());
assertEquals(JobConstraints.M3Cluster, stageMetadataWritable.getHardConstraints().get(0));
assertEquals(JobConstraints.ExclusiveHost, stageMetadataWritable.getSoftConstraints().get(0));
assertEquals(stageScalingPolicy, stageMetadataWritable.getScalingPolicy());
assertTrue(stageMetadataWritable.getScalable());
assertEquals(DEFAULT_MACHINE_DEFINITION, stageMetadataWritable.getMachineDefinition());
assertEquals(numWorkers, stageMetadataWritable.getNumWorkers());
assertEquals(numStages, stageMetadataWritable.getNumStages());
assertEquals(stageNo, stageMetadataWritable.getStageNum());
IMantisStageMetadata reconverted = DataFormatAdapter.convertMantisStageMetadataWriteableToMantisStageMetadata(stageMetadataWritable, eventPublisher);
assertEquals(stageMeta, reconverted);
}
use of io.mantisrx.runtime.descriptor.StageScalingPolicy 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 io.mantisrx.runtime.descriptor.StageScalingPolicy 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