use of io.mantisrx.server.master.domain.JobId in project mantis by Netflix.
the class WorkerRegistryV2Test method testIsWorkerValid.
@Test
public void testIsWorkerValid() {
JobId jId = new JobId("testIsWorkerValid", 1);
WorkerRegistryV2 workerRegistryV2 = new WorkerRegistryV2();
initRegistryWithWorkers(workerRegistryV2, "testIsWorkerValid-1", 5);
for (int i = 0; i < 5; i++) {
assertTrue(workerRegistryV2.isWorkerValid(new WorkerId(jId.getId(), i, i + 5)));
}
}
use of io.mantisrx.server.master.domain.JobId in project mantis by Netflix.
the class WorkerRegistryV2Test method testJobCompleteCleanup.
@Test
public void testJobCompleteCleanup() {
WorkerRegistryV2 workerRegistryV2 = new WorkerRegistryV2();
JobId jobId = new JobId("testJobCompleteCleanup", 1);
initRegistryWithWorkers(workerRegistryV2, "testJobCompleteCleanup-1", 5);
assertEquals(5, workerRegistryV2.getNumRunningWorkers());
workerRegistryV2.process(new LifecycleEventsProto.JobStatusEvent(INFO, "job shutdown", jobId, JobState.Failed));
assertEquals(0, workerRegistryV2.getNumRunningWorkers());
}
use of io.mantisrx.server.master.domain.JobId in project mantis by Netflix.
the class WorkerRegistryV2Test method testJobScaleDown.
@Test
public void testJobScaleDown() throws Exception {
WorkerRegistryV2 workerRegistryV2 = new WorkerRegistryV2();
LifecycleEventPublisher eventPublisher = new LifecycleEventPublisherImpl(new AuditEventSubscriberLoggingImpl(), new StatusEventSubscriberLoggingImpl(), new DummyWorkerEventSubscriberImpl(workerRegistryV2));
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));
SchedulingInfo sInfo = new SchedulingInfo.Builder().numberOfStages(1).multiWorkerScalableStageWithConstraints(2, new MachineDefinition(1.0, 1.0, 1.0, 3), Lists.newArrayList(), Lists.newArrayList(), new StageScalingPolicy(1, 0, 10, 1, 1, 0, smap)).build();
String clusterName = "testJobScaleDown";
MantisScheduler schedulerMock = mock(MantisScheduler.class);
MantisJobStore jobStoreMock = mock(MantisJobStore.class);
ActorRef jobActor = JobTestHelper.submitSingleStageScalableJob(system, probe, clusterName, sInfo, schedulerMock, jobStoreMock, eventPublisher);
assertEquals(3, workerRegistryV2.getNumRunningWorkers());
// send scale down request
jobActor.tell(new JobClusterManagerProto.ScaleStageRequest(clusterName + "-1", 1, 1, "", ""), probe.getRef());
JobClusterManagerProto.ScaleStageResponse scaleResp = probe.expectMsgClass(JobClusterManagerProto.ScaleStageResponse.class);
System.out.println("ScaleDownResp " + scaleResp.message);
assertEquals(SUCCESS, scaleResp.responseCode);
assertEquals(1, scaleResp.getActualNumWorkers());
jobActor.tell(new JobClusterManagerProto.GetJobDetailsRequest("user", new JobId(clusterName, 1)), probe.getRef());
JobClusterManagerProto.GetJobDetailsResponse resp = probe.expectMsgClass(JobClusterManagerProto.GetJobDetailsResponse.class);
Map<Integer, ? extends IMantisStageMetadata> stageMetadata = resp.getJobMetadata().get().getStageMetadata();
assertEquals(1, stageMetadata.get(1).getAllWorkers().size());
int cnt = 0;
for (int i = 0; i < 50; i++) {
cnt++;
if (workerRegistryV2.getNumRunningWorkers() == 2) {
break;
}
}
assertTrue(cnt < 50);
// assertEquals(2, WorkerRegistryV2.INSTANCE.getNumRunningWorkers());
}
use of io.mantisrx.server.master.domain.JobId in project mantis by Netflix.
the class WorkerRegistryV2Test method initRegistryWithWorkers.
private void initRegistryWithWorkers(WorkerRegistryV2 workerRegistryV2, String jobId, int noOfWorkers) {
LifecycleEventPublisher eventPublisher = new LifecycleEventPublisherImpl(new AuditEventSubscriberLoggingImpl(), new StatusEventSubscriberLoggingImpl(), new NoOpWorkerEventSubscriberImpl());
JobId jId = JobId.fromId(jobId).get();
List<IMantisWorkerMetadata> workerMetadataList = new ArrayList<>();
for (int i = 0; i < noOfWorkers; i++) {
JobWorker jb = new JobWorker.Builder().withAcceptedAt(i).withJobId(jId).withSlaveID("slaveId-" + i).withState(WorkerState.Launched).withWorkerIndex(i).withWorkerNumber(i + 5).withStageNum(1).withNumberOfPorts(1 + MANTIS_SYSTEM_ALLOCATED_NUM_PORTS).withLifecycleEventsPublisher(eventPublisher).build();
workerMetadataList.add(jb.getMetadata());
}
LifecycleEventsProto.WorkerListChangedEvent workerListChangedEvent = new LifecycleEventsProto.WorkerListChangedEvent(new WorkerInfoListHolder(jId, workerMetadataList));
workerRegistryV2.process(workerListChangedEvent);
}
use of io.mantisrx.server.master.domain.JobId in project mantis by Netflix.
the class WorkerRegistryV2Test method testJobScaleUp.
@Test
public void testJobScaleUp() throws Exception, InvalidJobException, io.mantisrx.runtime.command.InvalidJobException {
WorkerRegistryV2 workerRegistryV2 = new WorkerRegistryV2();
LifecycleEventPublisher eventPublisher = new LifecycleEventPublisherImpl(new AuditEventSubscriberLoggingImpl(), new StatusEventSubscriberLoggingImpl(), new DummyWorkerEventSubscriberImpl(workerRegistryV2));
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));
SchedulingInfo sInfo = new SchedulingInfo.Builder().numberOfStages(1).multiWorkerScalableStageWithConstraints(1, new MachineDefinition(1.0, 1.0, 1.0, 3), Lists.newArrayList(), Lists.newArrayList(), new StageScalingPolicy(1, 0, 10, 1, 1, 0, smap)).build();
String clusterName = "testJobScaleUp";
MantisScheduler schedulerMock = mock(MantisScheduler.class);
MantisJobStore jobStoreMock = mock(MantisJobStore.class);
ActorRef jobActor = JobTestHelper.submitSingleStageScalableJob(system, probe, clusterName, sInfo, schedulerMock, jobStoreMock, eventPublisher);
assertEquals(2, workerRegistryV2.getNumRunningWorkers());
// send scale up request
jobActor.tell(new JobClusterManagerProto.ScaleStageRequest(clusterName + "-1", 1, 2, "", ""), probe.getRef());
JobClusterManagerProto.ScaleStageResponse scaleResp = probe.expectMsgClass(JobClusterManagerProto.ScaleStageResponse.class);
System.out.println("ScaleupResp " + scaleResp.message);
assertEquals(SUCCESS, scaleResp.responseCode);
assertEquals(2, scaleResp.getActualNumWorkers());
JobTestHelper.sendLaunchedInitiatedStartedEventsToWorker(probe, jobActor, clusterName + "-1", 0, new WorkerId(clusterName + "-1", 1, 3));
jobActor.tell(new JobClusterManagerProto.GetJobDetailsRequest("user", new JobId(clusterName, 1)), probe.getRef());
JobClusterManagerProto.GetJobDetailsResponse resp = probe.expectMsgClass(JobClusterManagerProto.GetJobDetailsResponse.class);
Map<Integer, ? extends IMantisStageMetadata> stageMetadata = resp.getJobMetadata().get().getStageMetadata();
assertEquals(2, stageMetadata.get(1).getAllWorkers().size());
int cnt = 0;
for (int i = 0; i < 50; i++) {
cnt++;
if (workerRegistryV2.getNumRunningWorkers() == 3) {
break;
}
}
assertTrue(cnt < 50);
}
Aggregations