Search in sources :

Example 1 with UpdateJobClusterWorkerMigrationStrategyResponse

use of io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.UpdateJobClusterWorkerMigrationStrategyResponse in project mantis by Netflix.

the class JobClusterActor method onJobClusterUpdateWorkerMigrationConfig.

// TODO validate the migration config json
@Override
public void onJobClusterUpdateWorkerMigrationConfig(UpdateJobClusterWorkerMigrationStrategyRequest req) {
    if (logger.isTraceEnabled()) {
        logger.trace("Entering JobClusterActor:onJobClusterUpdateWorkerMigrationConfig {}", req);
    }
    ActorRef sender = getSender();
    try {
        JobClusterDefinitionImpl updatedDefn = new JobClusterDefinitionImpl.Builder().from(jobClusterMetadata.getJobClusterDefinition()).withMigrationConfig(req.getMigrationConfig()).build();
        IJobClusterMetadata jobCluster = new JobClusterMetadataImpl.Builder().withIsDisabled(jobClusterMetadata.isDisabled()).withLastJobCount(jobClusterMetadata.getLastJobCount()).withJobClusterDefinition(updatedDefn).build();
        updateAndSaveJobCluster(jobCluster);
        sender.tell(new UpdateJobClusterWorkerMigrationStrategyResponse(req.requestId, SUCCESS, name + " worker migration config updated"), getSelf());
        eventPublisher.publishAuditEvent(new LifecycleEventsProto.AuditEvent(LifecycleEventsProto.AuditEvent.AuditEventType.JOB_CLUSTER_UPDATE, jobClusterMetadata.getJobClusterDefinition().getName(), name + " worker migration config update"));
    } catch (Exception e) {
        logger.error("job cluster migration config not updated ", e);
        sender.tell(new UpdateJobClusterWorkerMigrationStrategyResponse(req.requestId, SERVER_ERROR, name + " Job cluster worker migration config updation failed " + e.getMessage()), getSelf());
    }
    if (logger.isTraceEnabled()) {
        logger.trace("Exit JobClusterActor:onJobClusterUpdateWorkerMigrationConfig {}", req);
    }
}
Also used : UpdateJobClusterWorkerMigrationStrategyResponse(io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.UpdateJobClusterWorkerMigrationStrategyResponse) ActorRef(akka.actor.ActorRef) JobClusterDefinitionImpl(io.mantisrx.server.master.domain.JobClusterDefinitionImpl) LifecycleEventsProto(io.mantisrx.master.events.LifecycleEventsProto) TriggerNotFoundException(com.netflix.fenzo.triggers.exceptions.TriggerNotFoundException) SchedulerException(com.netflix.fenzo.triggers.exceptions.SchedulerException) JobClusterAlreadyExistsException(io.mantisrx.server.master.persistence.exceptions.JobClusterAlreadyExistsException)

Example 2 with UpdateJobClusterWorkerMigrationStrategyResponse

use of io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.UpdateJobClusterWorkerMigrationStrategyResponse in project mantis by Netflix.

the class JobClustersManagerActor method onJobClusterUpdateWorkerMigrationConfig.

@Override
public void onJobClusterUpdateWorkerMigrationConfig(UpdateJobClusterWorkerMigrationStrategyRequest request) {
    Optional<JobClusterInfo> jobClusterInfo = jobClusterInfoManager.getJobClusterInfo(request.getClusterName());
    ActorRef sender = getSender();
    if (jobClusterInfo.isPresent()) {
        jobClusterInfo.get().jobClusterActor.forward(request, getContext());
    } else {
        sender.tell(new UpdateJobClusterWorkerMigrationStrategyResponse(request.requestId, CLIENT_ERROR_NOT_FOUND, "JobCluster " + request.getClusterName() + " doesn't exist"), getSelf());
    }
}
Also used : UpdateJobClusterWorkerMigrationStrategyResponse(io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.UpdateJobClusterWorkerMigrationStrategyResponse) ActorRef(akka.actor.ActorRef)

Example 3 with UpdateJobClusterWorkerMigrationStrategyResponse

use of io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.UpdateJobClusterWorkerMigrationStrategyResponse in project mantis by Netflix.

the class JobClusterTest method testJobClusterMigrationConfigUpdate.

@Test
public void testJobClusterMigrationConfigUpdate() throws Exception {
    TestKit probe = new TestKit(system);
    String clusterName = "testJobClusterMigrationConfigUpdate";
    MantisScheduler schedulerMock = mock(MantisScheduler.class);
    MantisJobStore jobStoreMock = mock(MantisJobStore.class);
    final JobClusterDefinitionImpl fakeJobCluster = createFakeJobClusterDefn(clusterName);
    ActorRef jobClusterActor = system.actorOf(props(clusterName, jobStoreMock, schedulerMock, eventPublisher));
    jobClusterActor.tell(new JobClusterProto.InitializeJobClusterRequest(fakeJobCluster, user, probe.getRef()), probe.getRef());
    JobClusterProto.InitializeJobClusterResponse createResp = probe.expectMsgClass(JobClusterProto.InitializeJobClusterResponse.class);
    assertEquals(SUCCESS, createResp.responseCode);
    WorkerMigrationConfig newConfig = new WorkerMigrationConfig(MigrationStrategyEnum.ONE_WORKER, "{'name':'value'}");
    UpdateJobClusterWorkerMigrationStrategyRequest updateMigrationConfigReq = new UpdateJobClusterWorkerMigrationStrategyRequest(clusterName, newConfig, "user");
    jobClusterActor.tell(updateMigrationConfigReq, probe.getRef());
    UpdateJobClusterWorkerMigrationStrategyResponse resp = probe.expectMsgClass(UpdateJobClusterWorkerMigrationStrategyResponse.class);
    assertEquals(SUCCESS, resp.responseCode);
    assertEquals(jobClusterActor, probe.getLastSender());
    jobClusterActor.tell(new GetJobClusterRequest(clusterName), probe.getRef());
    GetJobClusterResponse resp3 = probe.expectMsgClass(GetJobClusterResponse.class);
    assertEquals(SUCCESS, resp3.responseCode);
    assertTrue(resp3.getJobCluster() != null);
    System.out.println("Job cluster " + resp3.getJobCluster());
    assertEquals(clusterName, resp3.getJobCluster().get().getName());
    System.out.println("Updated job cluster " + resp3.getJobCluster());
    assertEquals(MigrationStrategyEnum.ONE_WORKER, resp3.getJobCluster().get().getMigrationConfig().getStrategy());
    verify(jobStoreMock, times(1)).updateJobCluster(any());
    verify(jobStoreMock, times(1)).createJobCluster(any());
}
Also used : JobClusterProto(io.mantisrx.master.jobcluster.proto.JobClusterProto) GetJobClusterResponse(io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.GetJobClusterResponse) UpdateJobClusterWorkerMigrationStrategyResponse(io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.UpdateJobClusterWorkerMigrationStrategyResponse) ActorRef(akka.actor.ActorRef) MantisScheduler(io.mantisrx.server.master.scheduler.MantisScheduler) WorkerMigrationConfig(io.mantisrx.runtime.WorkerMigrationConfig) TestKit(akka.testkit.javadsl.TestKit) Matchers.anyString(org.mockito.Matchers.anyString) MantisJobStore(io.mantisrx.server.master.persistence.MantisJobStore) UpdateJobClusterWorkerMigrationStrategyRequest(io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.UpdateJobClusterWorkerMigrationStrategyRequest) GetJobClusterRequest(io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.GetJobClusterRequest) Test(org.junit.Test)

Aggregations

ActorRef (akka.actor.ActorRef)3 UpdateJobClusterWorkerMigrationStrategyResponse (io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.UpdateJobClusterWorkerMigrationStrategyResponse)3 TestKit (akka.testkit.javadsl.TestKit)1 SchedulerException (com.netflix.fenzo.triggers.exceptions.SchedulerException)1 TriggerNotFoundException (com.netflix.fenzo.triggers.exceptions.TriggerNotFoundException)1 LifecycleEventsProto (io.mantisrx.master.events.LifecycleEventsProto)1 GetJobClusterRequest (io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.GetJobClusterRequest)1 GetJobClusterResponse (io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.GetJobClusterResponse)1 UpdateJobClusterWorkerMigrationStrategyRequest (io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.UpdateJobClusterWorkerMigrationStrategyRequest)1 JobClusterProto (io.mantisrx.master.jobcluster.proto.JobClusterProto)1 WorkerMigrationConfig (io.mantisrx.runtime.WorkerMigrationConfig)1 JobClusterDefinitionImpl (io.mantisrx.server.master.domain.JobClusterDefinitionImpl)1 MantisJobStore (io.mantisrx.server.master.persistence.MantisJobStore)1 JobClusterAlreadyExistsException (io.mantisrx.server.master.persistence.exceptions.JobClusterAlreadyExistsException)1 MantisScheduler (io.mantisrx.server.master.scheduler.MantisScheduler)1 Test (org.junit.Test)1 Matchers.anyString (org.mockito.Matchers.anyString)1