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 StorageProvider
StorageProvider.StorageProviderInfo -
Field Summary
Fields inherited from interface StorageProvider
BATCH_SIZE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidannounceBackgroundJobServer(BackgroundJobServerStatus serverStatus) voidclear()voidclose()longCounts all the jobs matching the givenStateName.intdeleteJobsPermanently(StateName state, Instant updatedBefore) voiddeleteMetadata(String name) voiddeleteMetadata(String name, String owner) intDeletes theJobwith the given id and returns the amount of deleted jobs (either 0 or 1).intDeletes theRecurringJobwith the given id.getCarbonAwareJobList(Instant deadlineBefore, AmountRequest amountRequest) Returns all carbon aware jobs with a deadline before the givenInstant.getDistinctJobSignatures(StateName... states) getJobById(UUID id) Returns theJobwith the given id or throws aJobNotFoundExceptionif the job does not existgetJobList(StateName state, Instant updatedBefore, AmountRequest amountRequest) getJobList(StateName state, AmountRequest amountRequest) Returns all the jobs matching the givenStateNameandAmountRequest.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) getRecurringJobLatestScheduledInstant(String recurringJobId, StateName... states) Returns the scheduled instant of the lastJob, in one of the given states, created by theRecurringJobwith the given recurringJobId.Returns a listRecurringJobs.getScheduledJobs(Instant scheduledBefore, AmountRequest amountRequest) voidpublishTotalAmountOfSucceededJobs(int amount) booleanrecurringJobsUpdated(Long recurringJobsUpdatedHash) intremoveTimedOutBackgroundJobServers(Instant heartbeatOlderThan) Save theJoband increases the version if saving succeeded.voidsaveMetadata(JobRunrMetadata metadata) saveRecurringJob(RecurringJob recurringJob) Saves aRecurringJobto the database.voidsetJobMapper(JobMapper jobMapper) voidsetUpStorageProvider(StorageProviderUtils.DatabaseOptions databaseOptions) This method allows to reinitialize the StorageProvider.booleansignalBackgroundJobServerAlive(BackgroundJobServerStatus serverStatus) voidsignalBackgroundJobServerStopped(BackgroundJobServerStatus serverStatus) Methods inherited from class AbstractStorageProvider
addJobStorageOnChangeListener, getStorageProviderInfo, notifyJobStatsOnChangeListeners, notifyJobStatsOnChangeListenersIf, notifyMetadataChangeListeners, notifyMetadataChangeListenersIf, notifyMetadataChangeListenersOnCurrentThread, removeJobStorageOnChangeListener, validatePollInterval, validateRecurringJobIntervalModifier and TypeMethodDescriptionvoidAllows to listen for changes related tojobs.protected voidprotected voidnotifyJobStatsOnChangeListenersIf(boolean mustNotify) protected voidprotected voidnotifyMetadataChangeListenersIf(boolean mustNotify) protected voidvoidRemove the given listener that listens for changes toJobsfinal voidvalidatePollInterval(Duration pollInterval) final voidvalidateRecurringJobInterval(Duration durationBetweenRecurringJobInstances) Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface StorageProvider
getJobById, getJobs, getJobsToProcess, getScheduledJobsModifier and TypeMethodDescriptiondefault JobgetJobById(JobId jobId) Returns theJobwith the given id or throws aJobNotFoundExceptionif the job does not existgetJobs(StateName state, PageRequest pageRequest) getJobsToProcess(BackgroundJobServer backgroundJobServer, AmountRequest amountRequest) getScheduledJobs(Instant scheduledBefore, PageRequest pageRequest)
-
Constructor Details
-
InMemoryStorageProvider
public InMemoryStorageProvider() -
InMemoryStorageProvider
-
-
Method Details
-
setJobMapper
-
setUpStorageProvider
Description copied from interface:StorageProviderThis 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:StorageProviderReturns theJobwith the given id or throws aJobNotFoundExceptionif the job does not exist- Parameters:
id- the id of the Job to fetch- Returns:
- the requested Job
-
countJobs
Description copied from interface:StorageProviderCounts all the jobs matching the givenStateName. -
saveMetadata
-
getMetadata
-
getMetadata
-
deleteMetadata
-
deleteMetadata
-
save
Description copied from interface:StorageProviderSave theJoband 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:StorageProviderDeletes theJobwith 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
-
deleteJobsPermanently
-
getDistinctJobSignatures
-
getRecurringJobLatestScheduledInstant
Description copied from interface:StorageProviderReturns the scheduled instant of the lastJob, in one of the given states, created by theRecurringJobwith the given recurringJobId. -
saveRecurringJob
Description copied from interface:StorageProviderSaves aRecurringJobto the database. If aRecurringJobwith the same id exists, it will be overwritten- Parameters:
recurringJob- the RecurringJob to save- Returns:
- the same RecurringJob
-
getRecurringJobs
Description copied from interface:StorageProviderReturns a listRecurringJobs.- Returns:
- a list
RecurringJobs.
-
recurringJobsUpdated
-
deleteRecurringJob
Description copied from interface:StorageProviderDeletes theRecurringJobwith 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:StorageProviderReturns 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 aJobStatsChangeListenerand register it using theStorageProvider.addJobStorageOnChangeListener(StorageProviderChangeListener).- Returns:
- the
JobStats
-
publishTotalAmountOfSucceededJobs
public void publishTotalAmountOfSucceededJobs(int amount) -
clear
public void clear() -
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceStorageProvider- Overrides:
closein classAbstractStorageProvider
-