Search in sources :

Example 1 with JobId

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)));
    }
}
Also used : WorkerId(io.mantisrx.server.core.domain.WorkerId) JobId(io.mantisrx.server.master.domain.JobId) Test(org.junit.Test)

Example 2 with JobId

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());
}
Also used : JobId(io.mantisrx.server.master.domain.JobId) Test(org.junit.Test)

Example 3 with JobId

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());
}
Also used : ActorRef(akka.actor.ActorRef) MantisScheduler(io.mantisrx.server.master.scheduler.MantisScheduler) JobId(io.mantisrx.server.master.domain.JobId) JobClusterManagerProto(io.mantisrx.master.jobcluster.proto.JobClusterManagerProto) SchedulingInfo(io.mantisrx.runtime.descriptor.SchedulingInfo) MachineDefinition(io.mantisrx.runtime.MachineDefinition) StageScalingPolicy(io.mantisrx.runtime.descriptor.StageScalingPolicy) MantisJobStore(io.mantisrx.server.master.persistence.MantisJobStore) Test(org.junit.Test)

Example 4 with JobId

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);
}
Also used : WorkerInfoListHolder(io.mantisrx.master.jobcluster.WorkerInfoListHolder) JobWorker(io.mantisrx.master.jobcluster.job.worker.JobWorker) IMantisWorkerMetadata(io.mantisrx.master.jobcluster.job.worker.IMantisWorkerMetadata) JobId(io.mantisrx.server.master.domain.JobId)

Example 5 with JobId

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);
}
Also used : ActorRef(akka.actor.ActorRef) MantisScheduler(io.mantisrx.server.master.scheduler.MantisScheduler) JobId(io.mantisrx.server.master.domain.JobId) JobClusterManagerProto(io.mantisrx.master.jobcluster.proto.JobClusterManagerProto) SchedulingInfo(io.mantisrx.runtime.descriptor.SchedulingInfo) MachineDefinition(io.mantisrx.runtime.MachineDefinition) WorkerId(io.mantisrx.server.core.domain.WorkerId) StageScalingPolicy(io.mantisrx.runtime.descriptor.StageScalingPolicy) MantisJobStore(io.mantisrx.server.master.persistence.MantisJobStore) Test(org.junit.Test)

Aggregations

JobId (io.mantisrx.server.master.domain.JobId)64 Test (org.junit.Test)43 ActorRef (akka.actor.ActorRef)27 JobClusterManagerProto (io.mantisrx.master.jobcluster.proto.JobClusterManagerProto)25 MantisJobStore (io.mantisrx.server.master.persistence.MantisJobStore)23 JobDefinition (io.mantisrx.server.master.domain.JobDefinition)21 MantisScheduler (io.mantisrx.server.master.scheduler.MantisScheduler)21 JobInfo (io.mantisrx.master.jobcluster.JobClusterActor.JobInfo)17 IJobClusterDefinition (io.mantisrx.server.master.domain.IJobClusterDefinition)17 IOException (java.io.IOException)17 GetJobDetailsResponse (io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.GetJobDetailsResponse)15 TestKit (akka.testkit.javadsl.TestKit)12 WorkerId (io.mantisrx.server.core.domain.WorkerId)12 ArrayList (java.util.ArrayList)12 Label (io.mantisrx.common.Label)10 JobProto (io.mantisrx.master.jobcluster.proto.JobProto)10 SchedulingInfo (io.mantisrx.runtime.descriptor.SchedulingInfo)10 SLA (io.mantisrx.server.master.domain.SLA)10 JobManager (io.mantisrx.master.jobcluster.JobClusterActor.JobManager)9 MachineDefinition (io.mantisrx.runtime.MachineDefinition)9