use of org.thoughtcrime.securesms.jobmanager.persistence.FullSpec in project Signal-Android by WhisperSystems.
the class JobController method buildFullSpec.
@WorkerThread
@NonNull
private FullSpec buildFullSpec(@NonNull Job job, @NonNull Collection<String> dependsOn) {
job.setRunAttempt(0);
JobSpec jobSpec = new JobSpec(job.getId(), job.getFactoryKey(), job.getParameters().getQueue(), System.currentTimeMillis(), job.getNextRunAttemptTime(), job.getRunAttempt(), job.getParameters().getMaxAttempts(), job.getParameters().getLifespan(), dataSerializer.serialize(job.serialize()), null, false, job.getParameters().isMemoryOnly());
List<ConstraintSpec> constraintSpecs = Stream.of(job.getParameters().getConstraintKeys()).map(key -> new ConstraintSpec(jobSpec.getId(), key, jobSpec.isMemoryOnly())).toList();
List<DependencySpec> dependencySpecs = Stream.of(dependsOn).map(depends -> {
JobSpec dependsOnJobSpec = jobStorage.getJobSpec(depends);
boolean memoryOnly = job.getParameters().isMemoryOnly() || (dependsOnJobSpec != null && dependsOnJobSpec.isMemoryOnly());
return new DependencySpec(job.getId(), depends, memoryOnly);
}).toList();
return new FullSpec(jobSpec, constraintSpecs, dependencySpecs);
}
use of org.thoughtcrime.securesms.jobmanager.persistence.FullSpec in project Signal-Android by WhisperSystems.
the class FastJobStorageTest method getPendingJobsWithNoDependenciesInCreatedOrder_singleEligibleJob.
@Test
public void getPendingJobsWithNoDependenciesInCreatedOrder_singleEligibleJob() {
FullSpec fullSpec = new FullSpec(new JobSpec("1", "f1", "q", 0, 0, 0, 0, -1, EMPTY_DATA, null, false, false), Collections.emptyList(), Collections.emptyList());
FastJobStorage subject = new FastJobStorage(fixedDataDatabase(Collections.singletonList(fullSpec)));
subject.init();
assertEquals(1, subject.getPendingJobsWithNoDependenciesInCreatedOrder(10).size());
}
use of org.thoughtcrime.securesms.jobmanager.persistence.FullSpec in project Signal-Android by WhisperSystems.
the class FastJobStorageTest method getPendingJobsWithNoDependenciesInCreatedOrder_multipleEligibleJobs.
@Test
public void getPendingJobsWithNoDependenciesInCreatedOrder_multipleEligibleJobs() {
FullSpec fullSpec1 = new FullSpec(new JobSpec("1", "f1", null, 0, 0, 0, 0, -1, EMPTY_DATA, null, false, false), Collections.emptyList(), Collections.emptyList());
FullSpec fullSpec2 = new FullSpec(new JobSpec("2", "f2", null, 0, 0, 0, 0, -1, EMPTY_DATA, null, false, false), Collections.emptyList(), Collections.emptyList());
FastJobStorage subject = new FastJobStorage(fixedDataDatabase(Arrays.asList(fullSpec1, fullSpec2)));
subject.init();
assertEquals(2, subject.getPendingJobsWithNoDependenciesInCreatedOrder(10).size());
}
use of org.thoughtcrime.securesms.jobmanager.persistence.FullSpec in project Signal-Android by WhisperSystems.
the class FastJobStorageTest method getPendingJobsWithNoDependenciesInCreatedOrder_firstItemInQueue.
@Test
public void getPendingJobsWithNoDependenciesInCreatedOrder_firstItemInQueue() {
FullSpec fullSpec1 = new FullSpec(new JobSpec("1", "f1", "q", 0, 0, 0, 0, -1, EMPTY_DATA, null, false, false), Collections.emptyList(), Collections.emptyList());
FullSpec fullSpec2 = new FullSpec(new JobSpec("2", "f2", "q", 0, 0, 0, 0, -1, EMPTY_DATA, null, false, false), Collections.emptyList(), Collections.emptyList());
FastJobStorage subject = new FastJobStorage(fixedDataDatabase(Arrays.asList(fullSpec1, fullSpec2)));
subject.init();
List<JobSpec> jobs = subject.getPendingJobsWithNoDependenciesInCreatedOrder(10);
assertEquals(1, jobs.size());
assertEquals("1", jobs.get(0).getId());
}
use of org.thoughtcrime.securesms.jobmanager.persistence.FullSpec in project Signal-Android by WhisperSystems.
the class FastJobStorageTest method getPendingJobsWithNoDependenciesInCreatedOrder_noneWhenEarlierItemInQueueInRunning.
@Test
public void getPendingJobsWithNoDependenciesInCreatedOrder_noneWhenEarlierItemInQueueInRunning() {
FullSpec fullSpec1 = new FullSpec(new JobSpec("1", "f1", "q", 0, 0, 0, 0, -1, EMPTY_DATA, null, true, false), Collections.emptyList(), Collections.emptyList());
FullSpec fullSpec2 = new FullSpec(new JobSpec("2", "f2", "q", 0, 0, 0, 0, -1, EMPTY_DATA, null, false, false), Collections.emptyList(), Collections.emptyList());
FastJobStorage subject = new FastJobStorage(fixedDataDatabase(Arrays.asList(fullSpec1, fullSpec2)));
subject.init();
assertEquals(0, subject.getPendingJobsWithNoDependenciesInCreatedOrder(1).size());
}
Aggregations