Class InMemoryStorageProvider

java.lang.Object
org.jobrunr.storage.AbstractStorageProvider
org.jobrunr.storage.InMemoryStorageProvider
All Implemented Interfaces:
AutoCloseable, StorageProvider

public class InMemoryStorageProvider extends AbstractStorageProvider
  • Constructor Details

    • InMemoryStorageProvider

      public InMemoryStorageProvider()
    • InMemoryStorageProvider

      public InMemoryStorageProvider(RateLimiter rateLimiter)
  • Method Details

    • setJobMapper

      public void setJobMapper(JobMapper jobMapper)
    • setUpStorageProvider

      public void setUpStorageProvider(StorageProviderUtils.DatabaseOptions databaseOptions)
      Description copied from interface: StorageProvider
      This method allows to reinitialize the StorageProvider. It can be used if you are using Flyway or Liquibase to setup your database manually.

      By default, this method is automatically called on construction of the StorageProvider

      Parameters:
      databaseOptions - defines whether to set up the StorageProvider or validate whether the StorageProvider is set up correctly.
    • announceBackgroundJobServer

      public void announceBackgroundJobServer(BackgroundJobServerStatus serverStatus)
    • signalBackgroundJobServerAlive

      public boolean signalBackgroundJobServerAlive(BackgroundJobServerStatus serverStatus)
    • signalBackgroundJobServerStopped

      public void signalBackgroundJobServerStopped(BackgroundJobServerStatus serverStatus)
    • getBackgroundJobServers

      public List<BackgroundJobServerStatus> getBackgroundJobServers()
    • getLongestRunningBackgroundJobServerId

      public UUID getLongestRunningBackgroundJobServerId()
    • removeTimedOutBackgroundJobServers

      public int removeTimedOutBackgroundJobServers(Instant heartbeatOlderThan)
    • getJobById

      public Job getJobById(UUID id)
      Description copied from interface: StorageProvider
      Returns the Job with the given id or throws a JobNotFoundException if the job does not exist
      Parameters:
      id - the id of the Job to fetch
      Returns:
      the requested Job
    • saveMetadata

      public void saveMetadata(JobRunrMetadata metadata)
    • getMetadata

      public List<JobRunrMetadata> getMetadata(String key)
    • getMetadata

      public JobRunrMetadata getMetadata(String key, String owner)
    • deleteMetadata

      public void deleteMetadata(String key)
    • save

      public Job save(Job job)
      Description copied from interface: StorageProvider
      Save the Job and increases the version if saving succeeded.
      Parameters:
      job - the job to save
      Returns:
      the same job with an increased version
    • deletePermanently

      public int deletePermanently(UUID id)
      Description copied from interface: StorageProvider
      Deletes the Job with the given id and returns the amount of deleted jobs (either 0 or 1).
      Parameters:
      id - the id of the Job to delete
      Returns:
      1 if the job with the given id was deleted, 0 otherwise
    • save

      public List<Job> save(List<Job> jobs)
      Description copied from interface: StorageProvider
      Saves a list of Jobs and increases the version of each successfully saved Job.
      Parameters:
      jobs - the list of jobs to save
      Returns:
      the same list of jobs with an increased version
    • getJobs

      public List<Job> getJobs(StateName state, Instant updatedBefore, PageRequest pageRequest)
    • getScheduledJobs

      public List<Job> getScheduledJobs(Instant scheduledBefore, PageRequest pageRequest)
    • getJobs

      public List<Job> getJobs(StateName state, PageRequest pageRequest)
    • getJobPage

      public Page<Job> getJobPage(StateName state, PageRequest pageRequest)
    • deleteJobsPermanently

      public int deleteJobsPermanently(StateName state, Instant updatedBefore)
    • getDistinctJobSignatures

      public Set<String> getDistinctJobSignatures(StateName... states)
    • exists

      public boolean exists(JobDetails jobDetails, StateName... states)
    • recurringJobExists

      public boolean recurringJobExists(String recurringJobId, StateName... states)
      Description copied from interface: StorageProvider
      Returns true when a Job created by the RecurringJob with the given id exists with one of the given states.
      Parameters:
      recurringJobId - the id of the RecurringJob for which the check whether a Job exists
      states - the possible states for the Job (can be empty)
      Returns:
      true if a Job exists created by a RecurringJob with the given id.
    • saveRecurringJob

      public RecurringJob saveRecurringJob(RecurringJob recurringJob)
      Description copied from interface: StorageProvider
      Saves a RecurringJob to the database. If a RecurringJob with the same id exists, it will be overwritten
      Parameters:
      recurringJob - the RecurringJob to save
      Returns:
      the same RecurringJob
    • getRecurringJobs

      public RecurringJobsResult getRecurringJobs()
      Description copied from interface: StorageProvider
      Returns a list RecurringJobs.
      Returns:
      a list RecurringJobs.
    • countRecurringJobs

      @Deprecated public long countRecurringJobs()
      Deprecated.
    • recurringJobsUpdated

      public boolean recurringJobsUpdated(Long recurringJobsUpdatedHash)
    • deleteRecurringJob

      public int deleteRecurringJob(String id)
      Description copied from interface: StorageProvider
      Deletes the RecurringJob with the given id.
      Parameters:
      id - the id of the RecurringJob to delete
      Returns:
      1 if the RecurringJob with the given id was deleted, 0 otherwise
    • getJobStats

      public JobStats getJobStats()
      Description copied from interface: StorageProvider
      Returns the statistics of the jobs (amount enqueued, amount scheduled, ...) Important: in most cases, this results in a intensive query. JobRunr is designed to not call this method too often to limit database CPU utilization. If you need access to this info, please use a JobStatsChangeListener and register it using the StorageProvider.addJobStorageOnChangeListener(StorageProviderChangeListener).
      Returns:
      the JobStats
    • publishTotalAmountOfSucceededJobs

      public void publishTotalAmountOfSucceededJobs(int amount)