Search in sources :

Example 6 with JobStore

use of com.netflix.titus.api.jobmanager.store.JobStore in project titus-control-plane by Netflix.

the class CassandraJobStoreTest method testRetrieveArchivedTask.

private void testRetrieveArchivedTask(boolean archive) {
    JobStore store = getJobStore();
    Job<BatchJobExt> job = createFinishedBatchJobObject();
    store.init().await();
    store.storeJob(job).await();
    Pair<List<Job<?>>, Integer> jobsAndErrors = store.retrieveJobs().toBlocking().first();
    checkRetrievedJob(job, jobsAndErrors.getLeft().get(0));
    Task task = createFinishedTaskObject(job);
    store.storeTask(task).await();
    if (archive) {
        store.deleteTask(task).await();
    }
    Task archivedTask = store.retrieveArchivedTask(task.getId()).toBlocking().first();
    checkRetrievedTask(task, archivedTask);
}
Also used : BatchJobTask(com.netflix.titus.api.jobmanager.model.job.BatchJobTask) Task(com.netflix.titus.api.jobmanager.model.job.Task) ServiceJobTask(com.netflix.titus.api.jobmanager.model.job.ServiceJobTask) BatchJobExt(com.netflix.titus.api.jobmanager.model.job.ext.BatchJobExt) JobStore(com.netflix.titus.api.jobmanager.store.JobStore) ArrayList(java.util.ArrayList) List(java.util.List)

Example 7 with JobStore

use of com.netflix.titus.api.jobmanager.store.JobStore in project titus-control-plane by Netflix.

the class CassandraJobStoreTest method testMoveTask.

@Test
public void testMoveTask() {
    JobStore store = getJobStore();
    store.init().await();
    Job<ServiceJobExt> jobFrom = createServiceJobObject();
    store.storeJob(jobFrom).await();
    Job<ServiceJobExt> jobTo = createServiceJobObject();
    store.storeJob(jobTo).await();
    Task task = createServiceTaskObject(jobFrom);
    store.storeTask(task).await();
    Job<ServiceJobExt> updatedFromJob = JobFunctions.incrementJobSize(jobFrom, -1);
    Job<ServiceJobExt> updatedToJob = JobFunctions.incrementJobSize(jobTo, 1);
    Task updatedTask = task.toBuilder().withJobId(updatedToJob.getId()).build();
    store.moveTask(updatedFromJob, updatedToJob, updatedTask).await();
    // Load jobFrom from store
    Job<?> jobFromLoaded = store.retrieveJob(jobFrom.getId()).toBlocking().first();
    assertThat(JobFunctions.getJobDesiredSize(jobFromLoaded)).isEqualTo(0);
    Pair<List<Task>, Integer> jobFromTasksLoaded = store.retrieveTasksForJob(jobFrom.getId()).toBlocking().first();
    assertThat(jobFromTasksLoaded.getLeft()).hasSize(0);
    // Load jobTo from store
    Job<?> jobToLoaded = store.retrieveJob(jobTo.getId()).toBlocking().first();
    assertThat(JobFunctions.getJobDesiredSize(jobToLoaded)).isEqualTo(2);
    Pair<List<Task>, Integer> jobToTasksLoaded = store.retrieveTasksForJob(jobTo.getId()).toBlocking().first();
    assertThat(jobToTasksLoaded.getLeft()).hasSize(1);
    jobToTasksLoaded.getLeft().forEach(t -> assertThat(t.getJobId()).isEqualTo(jobTo.getId()));
}
Also used : BatchJobTask(com.netflix.titus.api.jobmanager.model.job.BatchJobTask) Task(com.netflix.titus.api.jobmanager.model.job.Task) ServiceJobTask(com.netflix.titus.api.jobmanager.model.job.ServiceJobTask) ServiceJobExt(com.netflix.titus.api.jobmanager.model.job.ext.ServiceJobExt) JobStore(com.netflix.titus.api.jobmanager.store.JobStore) ArrayList(java.util.ArrayList) List(java.util.List) Test(org.junit.Test) IntegrationNotParallelizableTest(com.netflix.titus.testkit.junit.category.IntegrationNotParallelizableTest)

Example 8 with JobStore

use of com.netflix.titus.api.jobmanager.store.JobStore in project titus-control-plane by Netflix.

the class CassandraJobStoreTest method testRetrieveArchivedTasksForJob.

private void testRetrieveArchivedTasksForJob(boolean archive) {
    JobStore store = getJobStore();
    Job<BatchJobExt> job = createFinishedBatchJobObject();
    store.init().await();
    store.storeJob(job).await();
    Pair<List<Job<?>>, Integer> jobsAndErrors = store.retrieveJobs().toBlocking().first();
    checkRetrievedJob(job, jobsAndErrors.getLeft().get(0));
    Task task = createFinishedTaskObject(job);
    store.storeTask(task).await();
    if (archive) {
        store.deleteTask(task).await();
    }
    Task archivedTask = store.retrieveArchivedTasksForJob(job.getId()).toBlocking().first();
    checkRetrievedTask(task, archivedTask);
}
Also used : BatchJobTask(com.netflix.titus.api.jobmanager.model.job.BatchJobTask) Task(com.netflix.titus.api.jobmanager.model.job.Task) ServiceJobTask(com.netflix.titus.api.jobmanager.model.job.ServiceJobTask) BatchJobExt(com.netflix.titus.api.jobmanager.model.job.ext.BatchJobExt) JobStore(com.netflix.titus.api.jobmanager.store.JobStore) ArrayList(java.util.ArrayList) List(java.util.List)

Example 9 with JobStore

use of com.netflix.titus.api.jobmanager.store.JobStore in project titus-control-plane by Netflix.

the class CassandraJobStoreTest method testReplaceTask.

@Test
public void testReplaceTask() {
    JobStore store = getJobStore();
    Job<BatchJobExt> job = createBatchJobObject();
    store.init().await();
    store.storeJob(job).await();
    Pair<List<Job<?>>, Integer> jobsAndErrors = store.retrieveJobs().toBlocking().first();
    checkRetrievedJob(job, jobsAndErrors.getLeft().get(0));
    Task firstTask = createTaskObject(job);
    store.storeTask(firstTask).await();
    Task retrievedTask = store.retrieveTask(firstTask.getId()).toBlocking().first();
    checkRetrievedTask(firstTask, retrievedTask);
    Task secondTask = createTaskObject(job);
    store.replaceTask(firstTask, secondTask).await();
    Pair<List<Task>, Integer> tasks = store.retrieveTasksForJob(job.getId()).toBlocking().first();
    assertThat(tasks.getLeft()).hasSize(1);
    assertThat(tasks.getRight()).isEqualTo(0);
    checkRetrievedTask(secondTask, tasks.getLeft().get(0));
}
Also used : BatchJobTask(com.netflix.titus.api.jobmanager.model.job.BatchJobTask) Task(com.netflix.titus.api.jobmanager.model.job.Task) ServiceJobTask(com.netflix.titus.api.jobmanager.model.job.ServiceJobTask) BatchJobExt(com.netflix.titus.api.jobmanager.model.job.ext.BatchJobExt) JobStore(com.netflix.titus.api.jobmanager.store.JobStore) ArrayList(java.util.ArrayList) List(java.util.List) Test(org.junit.Test) IntegrationNotParallelizableTest(com.netflix.titus.testkit.junit.category.IntegrationNotParallelizableTest)

Example 10 with JobStore

use of com.netflix.titus.api.jobmanager.store.JobStore in project titus-control-plane by Netflix.

the class CassandraJobStoreTest method testRetrieveJobs.

@Test
public void testRetrieveJobs() {
    Session session = cassandraCqlUnit.getSession();
    JobStore bootstrappingStore = getJobStore(session);
    Job<BatchJobExt> job = createBatchJobObject();
    bootstrappingStore.storeJob(job).await();
    JobStore store = getJobStore(session);
    store.init().await();
    Pair<List<Job<?>>, Integer> jobsAndErrors = store.retrieveJobs().toBlocking().first();
    assertThat(jobsAndErrors.getLeft()).hasSize(1);
    assertThat(jobsAndErrors.getRight()).isEqualTo(0);
    checkRetrievedJob(job, jobsAndErrors.getLeft().get(0));
    // Check that archive access does not return anything.
    try {
        store.retrieveArchivedJob(job.getId()).toBlocking().first();
        fail("Should not return active job");
    } catch (JobStoreException e) {
        assertThat(e.getErrorCode()).isEqualTo(JobStoreException.ErrorCode.JOB_DOES_NOT_EXIST);
    }
}
Also used : JobStoreException(com.netflix.titus.api.jobmanager.store.JobStoreException) BatchJobExt(com.netflix.titus.api.jobmanager.model.job.ext.BatchJobExt) JobStore(com.netflix.titus.api.jobmanager.store.JobStore) ArrayList(java.util.ArrayList) List(java.util.List) Session(com.datastax.driver.core.Session) Test(org.junit.Test) IntegrationNotParallelizableTest(com.netflix.titus.testkit.junit.category.IntegrationNotParallelizableTest)

Aggregations

JobStore (com.netflix.titus.api.jobmanager.store.JobStore)25 List (java.util.List)24 ArrayList (java.util.ArrayList)23 BatchJobExt (com.netflix.titus.api.jobmanager.model.job.ext.BatchJobExt)18 Task (com.netflix.titus.api.jobmanager.model.job.Task)17 IntegrationNotParallelizableTest (com.netflix.titus.testkit.junit.category.IntegrationNotParallelizableTest)14 Test (org.junit.Test)14 BatchJobTask (com.netflix.titus.api.jobmanager.model.job.BatchJobTask)13 ServiceJobTask (com.netflix.titus.api.jobmanager.model.job.ServiceJobTask)11 Job (com.netflix.titus.api.jobmanager.model.job.Job)8 TitusRuntime (com.netflix.titus.common.runtime.TitusRuntime)6 TaskState (com.netflix.titus.api.jobmanager.model.job.TaskState)5 TaskStatus (com.netflix.titus.api.jobmanager.model.job.TaskStatus)5 EntityHolder (com.netflix.titus.common.framework.reconciler.EntityHolder)5 ReconciliationEngine (com.netflix.titus.common.framework.reconciler.ReconciliationEngine)5 JobServiceRuntime (com.netflix.titus.master.jobmanager.service.JobServiceRuntime)5 VersionSupplier (com.netflix.titus.master.jobmanager.service.VersionSupplier)5 JobFunctions (com.netflix.titus.api.jobmanager.model.job.JobFunctions)4 JobState (com.netflix.titus.api.jobmanager.model.job.JobState)4 ServiceJobExt (com.netflix.titus.api.jobmanager.model.job.ext.ServiceJobExt)4