@Test public void updateAllJobsToBePending_writesToDatabase() { JobDatabase database = noopDatabase(); FastJobStorage subject = new FastJobStorage(database, new DirectExecutor()); subject.updateAllJobsToBePending(); verify(database).updateAllJobsToBePending(); }
@Override public synchronized void updateAllJobsToBePending() { serialExecutor.execute(() -> { jobDatabase.updateAllJobsToBePending(); }); ListIterator<JobSpec> iter = jobs.listIterator(); while (iter.hasNext()) { JobSpec existing = iter.next(); JobSpec updated = new JobSpec(existing.getId(), existing.getFactoryKey(), existing.getQueueKey(), existing.getCreateTime(), existing.getNextRunAttemptTime(), existing.getRunAttempt(), existing.getMaxAttempts(), existing.getMaxBackoff(), existing.getLifespan(), existing.getMaxInstances(), existing.getSerializedData(), existing.getSerializedInputData(), false, existing.isMemoryOnly()); iter.set(updated); } }
FastJobStorage implements JobStorage { @Override public synchronized void updateAllJobsToBePending() { serialExecutor.execute(() -> { jobDatabase.updateAllJobsToBePending(); }); ListIterator<JobSpec> iter = jobs.listIterator(); while (iter.hasNext()) { JobSpec existing = iter.next(); JobSpec updated = new JobSpec(existing.getId(), existing.getFactoryKey(), existing.getQueueKey(), existing.getCreateTime(), existing.getNextRunAttemptTime(), existing.getRunAttempt(), existing.getMaxAttempts(), existing.getMaxBackoff(), existing.getLifespan(), existing.getMaxInstances(), existing.getSerializedData(), existing.getSerializedInputData(), false, existing.isMemoryOnly()); iter.set(updated); } } }
FastJobStorage implements JobStorage { @Override public synchronized void updateAllJobsToBePending() { serialExecutor.execute(() -> { jobDatabase.updateAllJobsToBePending(); }); ListIterator<JobSpec> iter = jobs.listIterator(); while (iter.hasNext()) { JobSpec existing = iter.next(); JobSpec updated = new JobSpec(existing.getId(), existing.getFactoryKey(), existing.getQueueKey(), existing.getCreateTime(), existing.getNextRunAttemptTime(), existing.getRunAttempt(), existing.getMaxAttempts(), existing.getMaxBackoff(), existing.getLifespan(), existing.getMaxInstances(), existing.getSerializedData(), existing.getSerializedInputData(), false, existing.isMemoryOnly()); iter.set(updated); } } FastJobStorage(@NonNull JobDatabase jobDatabase, @NonNull Executor serialExecutor); }
FastJobStorage implements JobStorage { @Override public synchronized void updateAllJobsToBePending() { serialExecutor.execute(() -> { jobDatabase.updateAllJobsToBePending(); }); ListIterator<JobSpec> iter = jobs.listIterator(); while (iter.hasNext()) { JobSpec existing = iter.next(); JobSpec updated = new JobSpec(existing.getId(), existing.getFactoryKey(), existing.getQueueKey(), existing.getCreateTime(), existing.getNextRunAttemptTime(), existing.getRunAttempt(), existing.getMaxAttempts(), existing.getMaxBackoff(), existing.getLifespan(), existing.getMaxInstances(), existing.getSerializedData(), existing.getSerializedInputData(), false, existing.isMemoryOnly()); iter.set(updated); } } FastJobStorage(@NonNull JobDatabase jobDatabase, @NonNull Executor serialExecutor); @Override synchronized void init(); @Override synchronized void flush(); @Override synchronized void insertJobs(@NonNull List<FullSpec> fullSpecs); @Override synchronized @Nullable JobSpec getJobSpec(@NonNull String id); @Override synchronized @NonNull List<JobSpec> getAllJobSpecs(); @Override synchronized @NonNull List<JobSpec> getPendingJobsWithNoDependenciesInCreatedOrder(long currentTime); @Override synchronized @NonNull List<JobSpec> getJobsInQueue(@NonNull String queue); @Override synchronized int getJobInstanceCount(@NonNull String factoryKey); @Override synchronized void updateJobRunningState(@NonNull String id, boolean isRunning); @Override synchronized void updateJobAfterRetry(@NonNull String id, boolean isRunning, int runAttempt, long nextRunAttemptTime, @NonNull String serializedData); @Override synchronized void updateAllJobsToBePending(); @Override void updateJobs(@NonNull List<JobSpec> jobSpecs); @Override synchronized void deleteJob(@NonNull String jobId); @Override synchronized void deleteJobs(@NonNull List<String> jobIds); @Override synchronized @NonNull List<ConstraintSpec> getConstraintSpecs(@NonNull String jobId); @Override synchronized @NonNull List<ConstraintSpec> getAllConstraintSpecs(); @Override synchronized @NonNull List<DependencySpec> getDependencySpecsThatDependOnJob(@NonNull String jobSpecId); @Override @NonNull List<DependencySpec> getAllDependencySpecs(); }
FastJobStorage implements JobStorage { @Override public synchronized void updateAllJobsToBePending() { serialExecutor.execute(() -> { jobDatabase.updateAllJobsToBePending(); }); ListIterator<JobSpec> iter = jobs.listIterator(); while (iter.hasNext()) { JobSpec existing = iter.next(); JobSpec updated = new JobSpec(existing.getId(), existing.getFactoryKey(), existing.getQueueKey(), existing.getCreateTime(), existing.getNextRunAttemptTime(), existing.getRunAttempt(), existing.getMaxAttempts(), existing.getMaxBackoff(), existing.getLifespan(), existing.getMaxInstances(), existing.getSerializedData(), existing.getSerializedInputData(), false, existing.isMemoryOnly()); iter.set(updated); } } FastJobStorage(@NonNull JobDatabase jobDatabase, @NonNull Executor serialExecutor); @Override synchronized void init(); @Override synchronized void flush(); @Override synchronized void insertJobs(@NonNull List<FullSpec> fullSpecs); @Override synchronized @Nullable JobSpec getJobSpec(@NonNull String id); @Override synchronized @NonNull List<JobSpec> getAllJobSpecs(); @Override synchronized @NonNull List<JobSpec> getPendingJobsWithNoDependenciesInCreatedOrder(long currentTime); @Override synchronized @NonNull List<JobSpec> getJobsInQueue(@NonNull String queue); @Override synchronized int getJobInstanceCount(@NonNull String factoryKey); @Override synchronized void updateJobRunningState(@NonNull String id, boolean isRunning); @Override synchronized void updateJobAfterRetry(@NonNull String id, boolean isRunning, int runAttempt, long nextRunAttemptTime, @NonNull String serializedData); @Override synchronized void updateAllJobsToBePending(); @Override void updateJobs(@NonNull List<JobSpec> jobSpecs); @Override synchronized void deleteJob(@NonNull String jobId); @Override synchronized void deleteJobs(@NonNull List<String> jobIds); @Override synchronized @NonNull List<ConstraintSpec> getConstraintSpecs(@NonNull String jobId); @Override synchronized @NonNull List<ConstraintSpec> getAllConstraintSpecs(); @Override synchronized @NonNull List<DependencySpec> getDependencySpecsThatDependOnJob(@NonNull String jobSpecId); @Override @NonNull List<DependencySpec> getAllDependencySpecs();  }