use of com.netflix.titus.api.jobmanager.model.job.ext.BatchJobExt in project titus-control-plane by Netflix.
the class CachedBatchJobTest method initialSnapshot.
/**
* Create a snapshot with a single job and size == taskCount. Create up to tasksCreated tasks, leaving
* the remaining slots empty.
*/
private Triple<PCollectionJobSnapshot, Map<Integer, Task>, Map<Integer, Task>> initialSnapshot(int taskCount, int tasksCreated) {
Pair<Job<BatchJobExt>, PMap<String, Task>> jobAndTasks = newBatchJobWithTasks(0, taskCount);
Job<BatchJobExt> job = jobAndTasks.getLeft();
Map<Integer, Task> tasksByIndex = new HashMap<>();
Map<String, Task> tasks = new HashMap<>(jobAndTasks.getRight());
Map<Integer, Task> skipped = new HashMap<>();
Iterator<Task> it = tasks.values().iterator();
while (it.hasNext()) {
Task task = it.next();
int index = CachedBatchJob.indexOf(task, taskCount, titusRuntime);
if (index >= tasksCreated) {
it.remove();
skipped.put(index, task);
} else {
tasksByIndex.put(index, task);
}
}
PCollectionJobSnapshot snapshot = PCollectionJobSnapshot.newInstance("test", Collections.singletonMap(job.getId(), job), Collections.singletonMap(job.getId(), tasks), false, false, error -> {
throw new IllegalStateException(error);
}, titusRuntime);
return Triple.of(snapshot, tasksByIndex, skipped);
}
use of com.netflix.titus.api.jobmanager.model.job.ext.BatchJobExt in project titus-control-plane by Netflix.
the class CassandraJobStoreTest method testRetrieveArchivedJob.
private void testRetrieveArchivedJob(boolean archive) {
JobStore store = getJobStore();
Job<BatchJobExt> job = createFinishedBatchJobObject();
store.init().await();
store.storeJob(job).await();
if (archive) {
store.deleteJob(job).await();
}
Job archivedJob = store.retrieveArchivedJob(job.getId()).toBlocking().first();
checkRetrievedJob(job, archivedJob);
}
use of com.netflix.titus.api.jobmanager.model.job.ext.BatchJobExt in project titus-control-plane by Netflix.
the class CassandraJobStoreTest method testRetrieveArchivedTaskCountForJob.
@Test
public void testRetrieveArchivedTaskCountForJob() {
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();
store.deleteTask(task).await();
Long count = store.retrieveArchivedTaskCountForJob(job.getId()).toBlocking().first();
assertThat(count).isEqualTo(1);
}
use of com.netflix.titus.api.jobmanager.model.job.ext.BatchJobExt in project titus-control-plane by Netflix.
the class CassandraJobStoreTest method testDeleteArchivedTask.
@Test
public void testDeleteArchivedTask() {
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();
store.deleteTask(task).await();
Long count = store.retrieveArchivedTaskCountForJob(job.getId()).toBlocking().first();
assertThat(count).isEqualTo(1);
store.deleteArchivedTask(job.getId(), task.getId()).await();
Long count2 = store.retrieveArchivedTaskCountForJob(job.getId()).toBlocking().first();
assertThat(count2).isEqualTo(0);
}
use of com.netflix.titus.api.jobmanager.model.job.ext.BatchJobExt in project titus-control-plane by Netflix.
the class CassandraJobStoreTest method testStoreJob.
@Test
public void testStoreJob() {
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));
}
Aggregations