use of com.netflix.titus.api.jobmanager.model.job.Job in project titus-control-plane by Netflix.
the class DefaultLoadBalancerJobValidator method validateJobId.
@Override
public void validateJobId(String jobId) throws LoadBalancerException, JobManagerException {
// Job must exist
Job job = v3JobOperations.getJob(jobId).orElseThrow(() -> JobManagerException.v3JobNotFound(jobId));
// Job must be active
JobState state = job.getStatus().getState();
if (state != JobState.Accepted) {
throw JobManagerException.unexpectedJobState(job, JobState.Accepted);
}
// Must be a service job
JobDescriptor.JobDescriptorExt extensions = job.getJobDescriptor().getExtensions();
if (!(extensions instanceof ServiceJobExt)) {
throw JobManagerException.notServiceJob(jobId);
}
// Job should have less than max current load balancer associations
int maxLoadBalancers = loadBalancerValidationConfiguration.getMaxLoadBalancersPerJob();
int numLoadBalancers = loadBalancerStore.getNumLoadBalancersForJob(jobId);
if (numLoadBalancers > maxLoadBalancers) {
throw LoadBalancerException.jobMaxLoadBalancers(jobId, numLoadBalancers, maxLoadBalancers);
}
}
use of com.netflix.titus.api.jobmanager.model.job.Job in project titus-control-plane by Netflix.
the class GrpcJobReplicatorEventStreamTest method testCacheTaskRemove.
@Test
public void testCacheTaskRemove() {
Pair<Job, List<Task>> pair = jobServiceStub.createJobAndTasks(SERVICE_JOB);
List<Task> tasks = pair.getRight();
Task task = tasks.get(0);
newConnectVerifier().assertNext(next -> assertThat(next.getSnapshot().getTasks().get(0).getStatus().getState()).isEqualTo(TaskState.Accepted)).then(() -> jobServiceStub.moveTaskToState(task, TaskState.Finished)).assertNext(next -> assertThat(next.getSnapshot().getTaskMap()).hasSize(tasks.size() - 1)).thenCancel().verify();
}
use of com.netflix.titus.api.jobmanager.model.job.Job in project titus-control-plane by Netflix.
the class GrpcJobReplicatorEventStreamTest method testCacheTaskUpdate.
@Test
public void testCacheTaskUpdate() {
Pair<Job, List<Task>> pair = jobServiceStub.createJobAndTasks(BATCH_JOB);
Task task = pair.getRight().get(0);
newConnectVerifier().assertNext(next -> assertThat(next.getSnapshot().getTasks().get(0).getStatus().getState()).isEqualTo(TaskState.Accepted)).then(() -> jobServiceStub.moveTaskToState(task, TaskState.Launched)).assertNext(next -> assertThat(next.getSnapshot().getTasks().get(0).getStatus().getState()).isEqualTo(TaskState.Launched)).thenCancel().verify();
}
use of com.netflix.titus.api.jobmanager.model.job.Job in project titus-control-plane by Netflix.
the class GrpcJobReplicatorEventStreamTest method testCacheJobUpdate.
@Test
public void testCacheJobUpdate() {
Job job = jobServiceStub.createJob(SERVICE_JOB);
newConnectVerifier().assertNext(next -> assertThat(next.getSnapshot().getJobs().get(0).getStatus().getState()).isEqualTo(JobState.Accepted)).then(() -> jobServiceStub.moveJobToKillInitiatedState(job)).assertNext(next -> assertThat(next.getSnapshot().getJobs().get(0).getStatus().getState()).isEqualTo(JobState.KillInitiated)).thenCancel().verify();
}
use of com.netflix.titus.api.jobmanager.model.job.Job in project titus-control-plane by Netflix.
the class GrpcJobReplicatorEventStreamTest method testCacheJobRemove.
@Test
public void testCacheJobRemove() {
Job job = jobServiceStub.createJob(SERVICE_JOB);
jobServiceStub.moveJobToKillInitiatedState(job);
newConnectVerifier().assertNext(next -> assertThat(next.getSnapshot().getJobs().get(0).getStatus().getState()).isEqualTo(JobState.KillInitiated)).then(() -> jobServiceStub.finishJob(job)).assertNext(next -> assertThat(next.getSnapshot().getJobs()).isEmpty()).thenCancel().verify();
}
Aggregations