Package org.jobrunr.storage
Class InMemoryStorageProvider
java.lang.Object
org.jobrunr.storage.AbstractStorageProvider
org.jobrunr.storage.InMemoryStorageProvider
- All Implemented Interfaces:
AutoCloseable
,StorageProvider
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.jobrunr.storage.StorageProvider
StorageProvider.StorageProviderInfo
-
Field Summary
Fields inherited from interface org.jobrunr.storage.StorageProvider
BATCH_SIZE
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
announceBackgroundJobServer
(BackgroundJobServerStatus serverStatus) long
Deprecated.int
deleteJobsPermanently
(StateName state, Instant updatedBefore) void
deleteMetadata
(String key) int
Deletes theJob
with the given id and returns the amount of deleted jobs (either 0 or 1).int
Deletes theRecurringJob
with the given id.boolean
exists
(JobDetails jobDetails, StateName... states) getDistinctJobSignatures
(StateName... states) getJobById
(UUID id) Returns theJob
with the given id or throws aJobNotFoundException
if the job does not existgetJobPage
(StateName state, PageRequest pageRequest) getJobs
(StateName state, Instant updatedBefore, PageRequest pageRequest) getJobs
(StateName state, PageRequest pageRequest) Returns the statistics of the jobs (amount enqueued, amount scheduled, ...) Important: in most cases, this results in a intensive query.getMetadata
(String key) getMetadata
(String key, String owner) Returns a listRecurringJobs
.getScheduledJobs
(Instant scheduledBefore, PageRequest pageRequest) void
publishTotalAmountOfSucceededJobs
(int amount) boolean
recurringJobExists
(String recurringJobId, StateName... states) Returns true when aJob
created by theRecurringJob
with the given id exists with one of the given states.boolean
recurringJobsUpdated
(Long recurringJobsUpdatedHash) int
removeTimedOutBackgroundJobServers
(Instant heartbeatOlderThan) Save theJob
and increases the version if saving succeeded.void
saveMetadata
(JobRunrMetadata metadata) saveRecurringJob
(RecurringJob recurringJob) Saves aRecurringJob
to the database.void
setJobMapper
(JobMapper jobMapper) void
setUpStorageProvider
(StorageProviderUtils.DatabaseOptions databaseOptions) This method allows to reinitialize the StorageProvider.boolean
signalBackgroundJobServerAlive
(BackgroundJobServerStatus serverStatus) void
signalBackgroundJobServerStopped
(BackgroundJobServerStatus serverStatus) Methods inherited from class org.jobrunr.storage.AbstractStorageProvider
addJobStorageOnChangeListener, close, getStorageProviderInfo, notifyJobStatsOnChangeListeners, notifyJobStatsOnChangeListenersIf, notifyMetadataChangeListeners, notifyMetadataChangeListeners, removeJobStorageOnChangeListener
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.jobrunr.storage.StorageProvider
getJobById
-
Constructor Details
-
InMemoryStorageProvider
public InMemoryStorageProvider() -
InMemoryStorageProvider
-
-
Method Details
-
setJobMapper
-
setUpStorageProvider
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
-
signalBackgroundJobServerAlive
-
signalBackgroundJobServerStopped
-
getBackgroundJobServers
-
getLongestRunningBackgroundJobServerId
-
removeTimedOutBackgroundJobServers
-
getJobById
Description copied from interface:StorageProvider
Returns theJob
with the given id or throws aJobNotFoundException
if the job does not exist- Parameters:
id
- the id of the Job to fetch- Returns:
- the requested Job
-
saveMetadata
-
getMetadata
-
getMetadata
-
deleteMetadata
-
save
Description copied from interface:StorageProvider
Save theJob
and increases the version if saving succeeded.- Parameters:
job
- the job to save- Returns:
- the same job with an increased version
-
deletePermanently
Description copied from interface:StorageProvider
Deletes theJob
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
Description copied from interface:StorageProvider
- Parameters:
jobs
- the list of jobs to save- Returns:
- the same list of jobs with an increased version
-
getJobs
-
getScheduledJobs
-
getJobs
-
getJobPage
-
deleteJobsPermanently
-
getDistinctJobSignatures
-
exists
-
recurringJobExists
Description copied from interface:StorageProvider
Returns true when aJob
created by theRecurringJob
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 existsstates
- the possible states for the Job (can be empty)- Returns:
- true if a Job exists created by a RecurringJob with the given id.
-
saveRecurringJob
Description copied from interface:StorageProvider
Saves aRecurringJob
to the database. If aRecurringJob
with the same id exists, it will be overwritten- Parameters:
recurringJob
- the RecurringJob to save- Returns:
- the same RecurringJob
-
getRecurringJobs
Description copied from interface:StorageProvider
Returns a listRecurringJobs
.- Returns:
- a list
RecurringJobs
.
-
countRecurringJobs
Deprecated. -
recurringJobsUpdated
-
deleteRecurringJob
Description copied from interface:StorageProvider
Deletes theRecurringJob
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
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 aJobStatsChangeListener
and register it using theStorageProvider.addJobStorageOnChangeListener(StorageProviderChangeListener)
.- Returns:
- the
JobStats
-
publishTotalAmountOfSucceededJobs
public void publishTotalAmountOfSucceededJobs(int amount)
-