Class AbstractStorageProvider
java.lang.Object
org.jobrunr.storage.AbstractStorageProvider
- All Implemented Interfaces:
AutoCloseable, StorageProvider
- Direct Known Subclasses:
DefaultSqlStorageProvider, InMemoryStorageProvider, MongoDBStorageProvider
public abstract class AbstractStorageProvider
extends Object
implements StorageProvider, AutoCloseable
-
Nested Class Summary
Nested classes/interfaces inherited from interface StorageProvider
StorageProvider.StorageProviderInfo -
Field Summary
Fields inherited from interface StorageProvider
BATCH_SIZE -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractStorageProvider(RateLimiter changeListenerNotificationRateLimit) -
Method Summary
Modifier and TypeMethodDescriptionvoidAllows to listen for changes related tojobs.voidclose()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
announceBackgroundJobServer, countJobs, deleteJobsPermanently, deleteMetadata, deleteMetadata, deletePermanently, deleteRecurringJob, getBackgroundJobServers, getCarbonAwareJobList, getDistinctJobSignatures, getJobById, getJobById, getJobList, getJobList, getJobs, getJobStats, getJobsToProcess, getLongestRunningBackgroundJobServerId, getMetadata, getMetadata, getRecurringJobLatestScheduledInstant, getRecurringJobs, getScheduledJobs, getScheduledJobs, publishTotalAmountOfSucceededJobs, recurringJobsUpdated, removeTimedOutBackgroundJobServers, save, save, saveMetadata, saveRecurringJob, setJobMapper, setUpStorageProvider, signalBackgroundJobServerAlive, signalBackgroundJobServerStoppedModifier and TypeMethodDescriptionvoidannounceBackgroundJobServer(BackgroundJobServerStatus serverStatus) 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 existdefault JobgetJobById(JobId jobId) 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.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.getJobsToProcess(BackgroundJobServer backgroundJobServer, AmountRequest amountRequest) getMetadata(String name) getMetadata(String name, 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) getScheduledJobs(Instant scheduledBefore, PageRequest pageRequest) 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)
-
Constructor Details
-
AbstractStorageProvider
-
-
Method Details
-
getStorageProviderInfo
- Specified by:
getStorageProviderInfoin interfaceStorageProvider
-
addJobStorageOnChangeListener
Description copied from interface:StorageProviderAllows to listen for changes related tojobs.- Specified by:
addJobStorageOnChangeListenerin interfaceStorageProvider- Parameters:
listener- the listener to notify if there are any changes.- See Also:
-
removeJobStorageOnChangeListener
Description copied from interface:StorageProviderRemove the given listener that listens for changes toJobs- Specified by:
removeJobStorageOnChangeListenerin interfaceStorageProvider- Parameters:
listener- the listener to remove
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceStorageProvider
-
validatePollInterval
- Specified by:
validatePollIntervalin interfaceStorageProvider
-
validateRecurringJobInterval
- Specified by:
validateRecurringJobIntervalin interfaceStorageProvider
-
notifyJobStatsOnChangeListenersIf
protected void notifyJobStatsOnChangeListenersIf(boolean mustNotify) -
notifyJobStatsOnChangeListeners
protected void notifyJobStatsOnChangeListeners() -
notifyMetadataChangeListenersIf
protected void notifyMetadataChangeListenersIf(boolean mustNotify) -
notifyMetadataChangeListeners
protected void notifyMetadataChangeListeners() -
notifyMetadataChangeListenersOnCurrentThread
protected void notifyMetadataChangeListenersOnCurrentThread()
-