use of com.netflix.titus.api.jobmanager.store.JobStore in project titus-control-plane by Netflix.
the class CassandraJobStoreTest method doRetrieveJob.
private <E extends JobDescriptor.JobDescriptorExt> void doRetrieveJob(Job<E> job) {
JobStore store = getJobStore();
store.storeJob(job).await();
store.init().await();
Pair<List<Job<?>>, Integer> jobsAndErrors = store.retrieveJobs().toBlocking().first();
checkRetrievedJob(job, jobsAndErrors.getLeft().get(0));
}
use of com.netflix.titus.api.jobmanager.store.JobStore in project titus-control-plane by Netflix.
the class CassandraJobStoreTest method testDeleteTask.
@Test
public void testDeleteTask() {
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 task = createTaskObject(job);
store.storeTask(task).await();
Task retrievedTask = store.retrieveTask(task.getId()).toBlocking().first();
checkRetrievedTask(task, retrievedTask);
store.deleteTask(task).await();
Pair<List<Task>, Integer> tasks = store.retrieveTasksForJob(job.getId()).toBlocking().first();
assertThat(tasks.getLeft()).isEmpty();
}
use of com.netflix.titus.api.jobmanager.store.JobStore in project titus-control-plane by Netflix.
the class CassandraJobStoreTest method testStoreTask.
@Test
public void testStoreTask() {
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 task = createTaskObject(job);
store.storeTask(task).await();
Task retrievedTask = store.retrieveTask(task.getId()).toBlocking().first();
checkRetrievedTask(task, retrievedTask);
}
use of com.netflix.titus.api.jobmanager.store.JobStore in project titus-control-plane by Netflix.
the class CassandraJobStoreTest method testRetrieveTasksForJob.
@Test
public void testRetrieveTasksForJob() {
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 task = createTaskObject(job);
store.storeTask(task).await();
Pair<List<Task>, Integer> tasks = store.retrieveTasksForJob(job.getId()).toBlocking().first();
checkRetrievedTask(task, tasks.getLeft().get(0));
// Check that archive access does not return anything.
Task archivedTask = store.retrieveArchivedTasksForJob(job.getId()).toBlocking().firstOrDefault(null);
assertThat(archivedTask).isNull();
}
use of com.netflix.titus.api.jobmanager.store.JobStore in project titus-control-plane by Netflix.
the class CassandraJobStoreTest method testActiveJobIdDistribution.
/**
* Create enough jobs to evenly be bucketed across multiple rows. Delete 1 job per bucket. Add back enough jobs to fill
* in the deleted jobs plus an extra bucket worth as a new bucket was created when reaching the max of all the original buckets.
*/
@Test
public void testActiveJobIdDistribution() {
int numberOfJobsToCreate = 100;
int numberOfBuckets = numberOfJobsToCreate / MAX_BUCKET_SIZE;
Session session = cassandraCqlUnit.getSession();
JobStore store = getJobStore(session);
store.init().await();
List<Job<?>> createdJobs = new ArrayList<>();
List<Completable> completables = new ArrayList<>();
for (int i = 0; i < numberOfJobsToCreate; i++) {
Job<BatchJobExt> job = createBatchJobObject();
createdJobs.add(job);
completables.add(store.storeJob(job));
}
Completable.merge(Observable.from(completables), MAX_CONCURRENCY).await();
Pair<List<Job<?>>, Integer> retrievedJobsAndErrors = store.retrieveJobs().toBlocking().first();
assertThat(retrievedJobsAndErrors.getLeft()).hasSize(numberOfJobsToCreate);
assertItemsPerBucket(session, numberOfBuckets, MAX_BUCKET_SIZE);
int j = 0;
int jobsRemoved = 0;
completables = new ArrayList<>();
while (j < numberOfJobsToCreate) {
Job<?> jobToRemove = createdJobs.get(j);
completables.add(store.deleteJob(jobToRemove));
j += MAX_BUCKET_SIZE;
jobsRemoved++;
}
Completable.merge(Observable.from(completables), MAX_CONCURRENCY).await();
assertItemsPerBucket(session, numberOfBuckets, MAX_BUCKET_SIZE - 1);
completables = new ArrayList<>();
for (int i = 0; i < jobsRemoved + MAX_BUCKET_SIZE; i++) {
Job<BatchJobExt> job = createBatchJobObject();
completables.add(store.storeJob(job));
}
Completable.merge(Observable.from(completables), MAX_CONCURRENCY).await();
retrievedJobsAndErrors = store.retrieveJobs().toBlocking().first();
assertThat(retrievedJobsAndErrors.getLeft()).hasSize(numberOfJobsToCreate + MAX_BUCKET_SIZE);
assertItemsPerBucket(session, numberOfBuckets + 1, MAX_BUCKET_SIZE);
}
Aggregations