Search in sources :

Example 26 with StageScalingPolicy

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);
}
Also used : HashMap(java.util.HashMap) MantisStageMetadataWritable(io.mantisrx.server.master.store.MantisStageMetadataWritable) ArrayList(java.util.ArrayList) JobConstraints(io.mantisrx.runtime.JobConstraints) StageScalingPolicy(io.mantisrx.runtime.descriptor.StageScalingPolicy) IMantisStageMetadata(io.mantisrx.master.jobcluster.job.IMantisStageMetadata) Test(org.junit.Test)

Example 27 with StageScalingPolicy

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);
}
Also used : StageScalingPolicy(io.mantisrx.runtime.descriptor.StageScalingPolicy) UpdateDoublesSketch(com.yahoo.sketches.quantiles.UpdateDoublesSketch) StageSchedulingInfo(io.mantisrx.runtime.descriptor.StageSchedulingInfo) ClutchConfiguration(com.netflix.control.clutch.ClutchConfiguration) Test(org.junit.Test)

Example 28 with StageScalingPolicy

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);
}
Also used : StageScalingPolicy(io.mantisrx.runtime.descriptor.StageScalingPolicy) UpdateDoublesSketch(com.yahoo.sketches.quantiles.UpdateDoublesSketch) StageSchedulingInfo(io.mantisrx.runtime.descriptor.StageSchedulingInfo) ClutchConfiguration(com.netflix.control.clutch.ClutchConfiguration) Test(org.junit.Test)

Aggregations

StageScalingPolicy (io.mantisrx.runtime.descriptor.StageScalingPolicy)28 Test (org.junit.Test)24 HashMap (java.util.HashMap)19 SchedulingInfo (io.mantisrx.runtime.descriptor.SchedulingInfo)18 MachineDefinition (io.mantisrx.runtime.MachineDefinition)15 StageSchedulingInfo (io.mantisrx.runtime.descriptor.StageSchedulingInfo)14 ActorRef (akka.actor.ActorRef)10 MantisJobStore (io.mantisrx.server.master.persistence.MantisJobStore)10 MantisScheduler (io.mantisrx.server.master.scheduler.MantisScheduler)10 ScalingReason (io.mantisrx.runtime.descriptor.StageScalingPolicy.ScalingReason)9 Strategy (io.mantisrx.runtime.descriptor.StageScalingPolicy.Strategy)9 JobClusterManagerProto (io.mantisrx.master.jobcluster.proto.JobClusterManagerProto)8 TestKit (akka.testkit.javadsl.TestKit)7 Matchers.anyString (org.mockito.Matchers.anyString)6 Context (io.mantisrx.runtime.Context)5 JobSchedulingInfo (io.mantisrx.server.core.JobSchedulingInfo)5 MantisMasterClientApi (io.mantisrx.server.master.client.MantisMasterClientApi)5 JobId (io.mantisrx.server.master.domain.JobId)5 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)5 ClutchConfiguration (com.netflix.control.clutch.ClutchConfiguration)4