Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make SchedulingInfo builder method naming consistent #413

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public Builder numberOfStages(int numberOfStages) {
return this;
}

public Builder singleWorkerStageWithConstraints(
public Builder addStageWithConstraints(
MachineDefinition machineDefinition,
List<JobConstraints> hardConstraints,
List<JobConstraints> softConstraints) {
Expand All @@ -96,7 +96,7 @@ public Builder singleWorkerStageWithConstraints(
.build());
}

public Builder singleWorkerStageWithConstraints(
public Builder addStageWithConstraints(
MachineDefinition machineDefinition,
List<JobConstraints> hardConstraints,
List<JobConstraints> softConstraints,
Expand All @@ -111,15 +111,15 @@ public Builder singleWorkerStageWithConstraints(
.build());
}

public Builder singleWorkerStage(MachineDefinition machineDefinition) {
public Builder addStageWithMachineDefinition(MachineDefinition machineDefinition) {
return this.addStage(
StageSchedulingInfo.builder()
.numberOfInstances(1)
.machineDefinition(machineDefinition)
.build());
}

public Builder singleWorkerStage(MachineDefinition machineDefinition, Map<String, String> containerAttributes) {
public Builder addStageWithMachineDefinition(MachineDefinition machineDefinition, Map<String, String> containerAttributes) {
return this.addStage(
StageSchedulingInfo.builder()
.numberOfInstances(1)
Expand All @@ -128,9 +128,9 @@ public Builder singleWorkerStage(MachineDefinition machineDefinition, Map<String
.build());
}

public Builder multiWorkerScalableStageWithConstraints(int numberOfWorkers, MachineDefinition machineDefinition,
List<JobConstraints> hardConstraints, List<JobConstraints> softConstraints,
StageScalingPolicy scalingPolicy) {
public Builder addMultiScalableStagesWithConstraints(int numberOfWorkers, MachineDefinition machineDefinition,
List<JobConstraints> hardConstraints, List<JobConstraints> softConstraints,
StageScalingPolicy scalingPolicy) {
StageScalingPolicy ssp = new StageScalingPolicy(currentStage, scalingPolicy.getMin(), scalingPolicy.getMax(),
scalingPolicy.getIncrement(), scalingPolicy.getDecrement(), scalingPolicy.getCoolDownSecs(), scalingPolicy.getStrategies());
return this.addStage(
Expand All @@ -144,9 +144,9 @@ public Builder multiWorkerScalableStageWithConstraints(int numberOfWorkers, Mach
.build());
}

public Builder multiWorkerScalableStageWithConstraints(int numberOfWorkers, MachineDefinition machineDefinition,
List<JobConstraints> hardConstraints, List<JobConstraints> softConstraints,
StageScalingPolicy scalingPolicy, Map<String, String> containerAttributes) {
public Builder addMultiScalableStagesWithConstraints(int numberOfWorkers, MachineDefinition machineDefinition,
List<JobConstraints> hardConstraints, List<JobConstraints> softConstraints,
StageScalingPolicy scalingPolicy, Map<String, String> containerAttributes) {
StageScalingPolicy ssp = new StageScalingPolicy(currentStage, scalingPolicy.getMin(), scalingPolicy.getMax(),
scalingPolicy.getIncrement(), scalingPolicy.getDecrement(), scalingPolicy.getCoolDownSecs(), scalingPolicy.getStrategies());
return this.addStage(
Expand All @@ -161,8 +161,8 @@ public Builder multiWorkerScalableStageWithConstraints(int numberOfWorkers, Mach
.build());
}

public Builder multiWorkerStageWithConstraints(int numberOfWorkers, MachineDefinition machineDefinition,
List<JobConstraints> hardConstraints, List<JobConstraints> softConstraints) {
public Builder addMultiStagesWithConstraints(int numberOfWorkers, MachineDefinition machineDefinition,
List<JobConstraints> hardConstraints, List<JobConstraints> softConstraints) {
return this.addStage(
StageSchedulingInfo.builder()
.numberOfInstances(numberOfWorkers)
Expand All @@ -172,8 +172,8 @@ public Builder multiWorkerStageWithConstraints(int numberOfWorkers, MachineDefin
.build());
}

public Builder multiWorkerStageWithConstraints(int numberOfWorkers, MachineDefinition machineDefinition,
List<JobConstraints> hardConstraints, List<JobConstraints> softConstraints, Map<String, String> containerAttributes) {
public Builder addMultiStagesWithConstraints(int numberOfWorkers, MachineDefinition machineDefinition,
List<JobConstraints> hardConstraints, List<JobConstraints> softConstraints, Map<String, String> containerAttributes) {
return this.addStage(
StageSchedulingInfo.builder()
.numberOfInstances(numberOfWorkers)
Expand All @@ -184,16 +184,16 @@ public Builder multiWorkerStageWithConstraints(int numberOfWorkers, MachineDefin
.build());
}

public Builder multiWorkerStage(int numberOfWorkers, MachineDefinition machineDefinition) {
return multiWorkerStage(numberOfWorkers, machineDefinition, false);
public Builder addMultiStages(int numberOfWorkers, MachineDefinition machineDefinition) {
return addMultiStages(numberOfWorkers, machineDefinition, false);
}

public Builder multiWorkerStage(
public Builder addMultiStages(
int numberOfWorkers, MachineDefinition machineDefinition, Map<String, String> containerAttributes) {
return multiWorkerStage(numberOfWorkers, machineDefinition, false, containerAttributes);
return addMultiStages(numberOfWorkers, machineDefinition, false, containerAttributes);
}

public Builder multiWorkerStage(int numberOfWorkers, MachineDefinition machineDefinition, boolean scalable) {
public Builder addMultiStages(int numberOfWorkers, MachineDefinition machineDefinition, boolean scalable) {
return this.addStage(
StageSchedulingInfo.builder()
.numberOfInstances(numberOfWorkers)
Expand All @@ -202,7 +202,7 @@ public Builder multiWorkerStage(int numberOfWorkers, MachineDefinition machineDe
.build());
}

public Builder multiWorkerStage(
public Builder addMultiStages(
int numberOfWorkers, MachineDefinition machineDefinition, boolean scalable,
Map<String, String> containerAttributes) {
return this.addStage(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,13 +149,13 @@ public void testSerialization() throws Exception {
smap.put(StageScalingPolicy.ScalingReason.Memory, new StageScalingPolicy.Strategy(StageScalingPolicy.ScalingReason.Memory, 0.1, 0.6, null));
Builder builder = new Builder()
.numberOfStages(2)
.multiWorkerScalableStageWithConstraints(
.addMultiScalableStagesWithConstraints(
2,
new MachineDefinition(1, 1.24, 0.0, 1, 1),
null, null,
new StageScalingPolicy(1, 1, 3, 1, 1, 60, smap)
)
.multiWorkerScalableStageWithConstraints(
.addMultiScalableStagesWithConstraints(
3,
new MachineDefinition(1, 1.24, 0.0, 1, 1),
null, null,
Expand Down Expand Up @@ -260,14 +260,14 @@ public void testSerializationWithSkuId() throws Exception {
smap.put(StageScalingPolicy.ScalingReason.Memory, new StageScalingPolicy.Strategy(StageScalingPolicy.ScalingReason.Memory, 0.1, 0.6, null));
Builder builder = new Builder()
.numberOfStages(2)
.multiWorkerScalableStageWithConstraints(
.addMultiScalableStagesWithConstraints(
2,
new MachineDefinition(1, 1.24, 0.0, 1, 1),
null, null,
new StageScalingPolicy(1, 1, 3, 1, 1, 60, smap),
ImmutableMap.of("containerSkuID", "sku1")
)
.multiWorkerScalableStageWithConstraints(
.addMultiScalableStagesWithConstraints(
3,
new MachineDefinition(1, 1.24, 0.0, 1, 1),
null, null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public void setup() throws Exception {
ImmutableList.of(1, 2, 3, 4, 5), 100L, 1,
ImmutableList.of(new Parameter("name", "value")),
new SchedulingInfo.Builder().numberOfStages(1)
.singleWorkerStageWithConstraints(new MachineDefinition(1, 10, 10, 10, 2),
.addStageWithConstraints(new MachineDefinition(1, 10, 10, 10, 2),
Lists.newArrayList(), Lists.newArrayList()).build(),
MantisJobDurationType.Perpetual,
1000L,
Expand All @@ -60,7 +60,7 @@ public void setup() throws Exception {
ImmutableList.of(1, 2, 3, 4, 5), 100L, 1,
ImmutableList.of(new Parameter("name", "value")),
new SchedulingInfo.Builder().numberOfStages(1)
.singleWorkerStageWithConstraints(new MachineDefinition(1, 10, 10, 10, 2),
.addStageWithConstraints(new MachineDefinition(1, 10, 10, 10, 2),
Lists.newArrayList(), Lists.newArrayList()).build(),
MantisJobDurationType.Perpetual,
1000L,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ public void testJobScaleUp() throws Exception, InvalidJobException, io.mantisrx.
smap.put(StageScalingPolicy.ScalingReason.DataDrop, new StageScalingPolicy.Strategy(StageScalingPolicy.ScalingReason.DataDrop, 0.0, 2.0, null));
SchedulingInfo sInfo = new SchedulingInfo.Builder()
.numberOfStages(1)
.multiWorkerScalableStageWithConstraints(1,
.addMultiScalableStagesWithConstraints(1,
new MachineDefinition(1.0,1.0,1.0,3),
Lists.newArrayList(),
Lists.newArrayList(),
Expand Down Expand Up @@ -225,7 +225,7 @@ public void testJobScaleDown() throws Exception {
smap.put(StageScalingPolicy.ScalingReason.DataDrop, new StageScalingPolicy.Strategy(StageScalingPolicy.ScalingReason.DataDrop, 0.0, 2.0, null));
SchedulingInfo sInfo = new SchedulingInfo.Builder()
.numberOfStages(1)
.multiWorkerScalableStageWithConstraints(2,
.addMultiScalableStagesWithConstraints(2,
new MachineDefinition(1.0,1.0,1.0,3),
Lists.newArrayList(),
Lists.newArrayList(),
Expand Down Expand Up @@ -281,7 +281,7 @@ public void testJobShutdown() {
smap.put(StageScalingPolicy.ScalingReason.DataDrop, new StageScalingPolicy.Strategy(StageScalingPolicy.ScalingReason.DataDrop, 0.0, 2.0, null));
SchedulingInfo sInfo = new SchedulingInfo.Builder()
.numberOfStages(1)
.multiWorkerScalableStageWithConstraints(1,
.addMultiScalableStagesWithConstraints(1,
new MachineDefinition(1.0,1.0,1.0,3),
Lists.newArrayList(),
Lists.newArrayList(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,8 @@ public class JobClusterTest {
public static final SLA NO_OP_SLA = new SLA(0, 0, null, null);

public static final MachineDefinition DEFAULT_MACHINE_DEFINITION = new MachineDefinition(1, 10, 10, 10, 2);
public static final SchedulingInfo SINGLE_WORKER_SCHED_INFO = new SchedulingInfo.Builder().numberOfStages(1).singleWorkerStageWithConstraints(DEFAULT_MACHINE_DEFINITION, Lists.newArrayList(), Lists.newArrayList()).build();
public static final SchedulingInfo TWO_WORKER_SCHED_INFO = new SchedulingInfo.Builder().numberOfStages(1).multiWorkerStage(2, DEFAULT_MACHINE_DEFINITION).build();
public static final SchedulingInfo SINGLE_WORKER_SCHED_INFO = new SchedulingInfo.Builder().numberOfStages(1).addStageWithConstraints(DEFAULT_MACHINE_DEFINITION, Lists.newArrayList(), Lists.newArrayList()).build();
public static final SchedulingInfo TWO_WORKER_SCHED_INFO = new SchedulingInfo.Builder().numberOfStages(1).addMultiStages(2, DEFAULT_MACHINE_DEFINITION).build();
public static final JobOwner DEFAULT_JOB_OWNER = new JobOwner("Nick", "Mantis", "desc", "[email protected]", "repo");
final LifecycleEventPublisher lifecycleEventPublisher = new LifecycleEventPublisherImpl(new AuditEventSubscriberLoggingImpl(), new StatusEventSubscriberLoggingImpl(), new WorkerEventSubscriberLoggingImpl());
static ActorSystem system;
Expand Down Expand Up @@ -1571,7 +1571,7 @@ public void testJobSubmitWithoutInheritInstance() {
final String jobId2 = clusterName + "-2";
final SchedulingInfo schedulingInfo = new SchedulingInfo.Builder()
.numberOfStages(1)
.multiWorkerStage(3, DEFAULT_MACHINE_DEFINITION)
.addMultiStages(3, DEFAULT_MACHINE_DEFINITION)
.build();
final JobDefinition jobDefn2Workers = createJob(clusterName, MantisJobDurationType.Transient, schedulingInfo);
JobTestHelper.submitJobAndVerifySuccess(probe, clusterName, jobClusterActor, jobDefn2Workers, jobId2);
Expand Down Expand Up @@ -1623,7 +1623,7 @@ public void testJobSubmitWithInheritInstanceFlagsSingleStage() {
final String jobId2 = clusterName + "-2";
final SchedulingInfo schedulingInfo = new SchedulingInfo.Builder()
.numberOfStages(1)
.multiWorkerStage(3, DEFAULT_MACHINE_DEFINITION)
.addMultiStages(3, DEFAULT_MACHINE_DEFINITION)
.build();
final DeploymentStrategy deploymentStrategy = DeploymentStrategy.builder()
.stage(1, StageDeploymentStrategy.builder().inheritInstanceCount(true).build())
Expand Down Expand Up @@ -1664,10 +1664,10 @@ public void testJobSubmitWithInheritInstanceFlagsMultiStage() {
// default job with 3 stage == (2 worker)
final SchedulingInfo schedulingInfo1 = new SchedulingInfo.Builder()
.numberOfStages(4)
.multiWorkerStage(2, DEFAULT_MACHINE_DEFINITION)
.multiWorkerStage(2, DEFAULT_MACHINE_DEFINITION)
.multiWorkerStage(2, DEFAULT_MACHINE_DEFINITION)
.multiWorkerStage(2, DEFAULT_MACHINE_DEFINITION)
.addMultiStages(2, DEFAULT_MACHINE_DEFINITION)
.addMultiStages(2, DEFAULT_MACHINE_DEFINITION)
.addMultiStages(2, DEFAULT_MACHINE_DEFINITION)
.addMultiStages(2, DEFAULT_MACHINE_DEFINITION)
.build();
final JobClusterDefinitionImpl fakeJobCluster =
createFakeJobClusterDefn(clusterName, Lists.newArrayList(), NO_OP_SLA, schedulingInfo1);
Expand All @@ -1689,10 +1689,10 @@ public void testJobSubmitWithInheritInstanceFlagsMultiStage() {
final String jobId2 = clusterName + "-2";
final SchedulingInfo schedulingInfo2 = new SchedulingInfo.Builder()
.numberOfStages(4)
.multiWorkerStage(3, DEFAULT_MACHINE_DEFINITION)
.multiWorkerStage(4, DEFAULT_MACHINE_DEFINITION)
.multiWorkerStage(5, DEFAULT_MACHINE_DEFINITION)
.multiWorkerStage(6, DEFAULT_MACHINE_DEFINITION)
.addMultiStages(3, DEFAULT_MACHINE_DEFINITION)
.addMultiStages(4, DEFAULT_MACHINE_DEFINITION)
.addMultiStages(5, DEFAULT_MACHINE_DEFINITION)
.addMultiStages(6, DEFAULT_MACHINE_DEFINITION)
.build();
final DeploymentStrategy deploymentStrategy = DeploymentStrategy.builder()
.stage(1, StageDeploymentStrategy.builder().inheritInstanceCount(true).build())
Expand Down Expand Up @@ -1742,8 +1742,8 @@ public void testJobSubmitWithInheritInstanceFlagsScaled() {
// default job with 3 stage == (2 worker)
final SchedulingInfo schedulingInfo1 = new SchedulingInfo.Builder()
.numberOfStages(2)
.multiWorkerStage(1, DEFAULT_MACHINE_DEFINITION, true)
.multiWorkerStage(1, DEFAULT_MACHINE_DEFINITION, true)
.addMultiStages(1, DEFAULT_MACHINE_DEFINITION, true)
.addMultiStages(1, DEFAULT_MACHINE_DEFINITION, true)
.build();
final JobClusterDefinitionImpl fakeJobCluster =
createFakeJobClusterDefn(clusterName, Lists.newArrayList(), NO_OP_SLA, schedulingInfo1);
Expand Down Expand Up @@ -1771,8 +1771,8 @@ public void testJobSubmitWithInheritInstanceFlagsScaled() {
final String jobId2 = clusterName + "-2";
final SchedulingInfo schedulingInfo2 = new SchedulingInfo.Builder()
.numberOfStages(2)
.multiWorkerStage(3, DEFAULT_MACHINE_DEFINITION)
.multiWorkerStage(4, DEFAULT_MACHINE_DEFINITION)
.addMultiStages(3, DEFAULT_MACHINE_DEFINITION)
.addMultiStages(4, DEFAULT_MACHINE_DEFINITION)
.build();
final DeploymentStrategy deploymentStrategy = DeploymentStrategy.builder()
.stage(1, StageDeploymentStrategy.builder().inheritInstanceCount(true).build())
Expand Down Expand Up @@ -2416,7 +2416,7 @@ public void testScaleStage() {
smap.put(StageScalingPolicy.ScalingReason.DataDrop, new StageScalingPolicy.Strategy(StageScalingPolicy.ScalingReason.DataDrop, 0.0, 2.0, null));

SchedulingInfo SINGLE_WORKER_SCHED_INFO = new SchedulingInfo.Builder().numberOfStages(1)
.multiWorkerScalableStageWithConstraints(1,DEFAULT_MACHINE_DEFINITION,Lists.newArrayList(),Lists.newArrayList(),new StageScalingPolicy(1,1,10,1,1,1, smap)).build();
.addMultiScalableStagesWithConstraints(1,DEFAULT_MACHINE_DEFINITION,Lists.newArrayList(),Lists.newArrayList(),new StageScalingPolicy(1,1,10,1,1,1, smap)).build();

final JobDefinition jobDefn = createJob(clusterName, 1, MantisJobDurationType.Transient, "USER_TYPE", SINGLE_WORKER_SCHED_INFO, Lists.newArrayList());

Expand Down
Loading