Class JobSchedulerStoreImpl
java.lang.Object
org.apache.activemq.util.ServiceSupport
org.apache.activemq.broker.LockableServiceSupport
org.apache.activemq.store.kahadb.AbstractKahaDBStore
org.apache.activemq.store.kahadb.scheduler.JobSchedulerStoreImpl
- All Implemented Interfaces:
BrokerServiceAware,Lockable,JobSchedulerStore,org.apache.activemq.Service
-
Field Summary
Fields inherited from class org.apache.activemq.store.kahadb.AbstractKahaDBStore
archiveCorruptedIndex, archiveDataLogs, checkForCorruptJournalFiles, checkpointInterval, checkpointLock, checkpointThread, checkpointThreadLock, checksumJournalFiles, cleanupInterval, deleteAllJobs, directory, directoryArchive, enableIndexDiskSyncs, enableIndexPageCaching, enableIndexRecoveryFile, enableIndexWriteAsync, enableJournalDiskSyncs, failIfDatabaseIsLocked, forceRecoverIndex, ignoreMissingJournalfiles, indexCacheSize, indexLFUEvictionFactor, indexLock, indexWriteBatchSize, journal, journalMaxFileLength, journalMaxWriteBatchSize, journalSize, LOG_SLOW_ACCESS_TIME, opened, pageFile, PROPERTY_LOG_SLOW_ACCESS_TIME, purgeStoreOnStartup, useIndexLFRUEvictionFields inherited from class org.apache.activemq.broker.LockableServiceSupport
brokerService, clockDaemon -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidcheckpointUpdate(Transaction tx, boolean cleanup) Perform the checkpoint update operation.protected voiddecrementJournalCount(Transaction tx, HashMap<Integer, Integer> decrementsByFileIds) Removes multiple references for the Journal log file indicated in the given Location map.protected voiddecrementJournalCount(Transaction tx, Location location) Removes one reference for the Journal log file indicated in the given Location value.protected voiddoRecover(JournalCommand<?> data, Location location, Location inDoubtlocation) Called during index recovery to rebuild the index from the last known good location.protected FilegetJobScheduler(String name) Gets the directory where the legacy Scheduler Store files will be archived if the broker is started and an existing Job Scheduler Store from an old version is detected.protected Stringprotected ByteSequencegetPayload(Location location) Retrieve the scheduled Job's byte blob from the journal.protected voidincrementJournalCount(Transaction tx, Location location) Adds a reference for the journal log file pointed to by the given Location value.voidload()Loads the store from disk.protected voidprocess(JournalCommand<?> data, Location location) Called during recovery to allow the store to rebuild from scratch.protected voidprocessLocation(Location location) voidvoidprotected voidreferenceRemovedLocation(Transaction tx, Location location, List<Integer> removedJobsFileId) Updates the Job removal tracking index with the location of a remove command and the original JobLocation entry.protected voidreferenceRemovedLocation(Transaction tx, Location location, org.apache.activemq.store.kahadb.scheduler.JobLocation removedJob) Updates the Job removal tracking index with the location of a remove command and the original JobLocation entry.booleanremoveJobScheduler(String name) voidsetLegacyStoreArchiveDirectory(File directory) Sets the directory where the legacy scheduler store files are archived before an update attempt is made.toString()voidunload()Unload the state of the Store to disk and shuts down all resources assigned to this KahaDB store implementation.voidvoidMethods inherited from class org.apache.activemq.store.kahadb.AbstractKahaDBStore
checkpointCleanup, checkpointUpdate, createDefaultLocker, createJournal, createPageFile, doStart, doStop, getCheckpointInterval, getCleanupInterval, getCleanupOnStop, getDirectory, getDirectoryArchive, getIndexCacheSize, getIndexLFUEvictionFactor, getIndexWriteBatchSize, getJournal, getJournalMaxFileLength, getJournalMaxWriteBatchSize, getPageFile, init, isArchiveCorruptedIndex, isArchiveDataLogs, isCheckForCorruptJournalFiles, isChecksumJournalFiles, isDeleteAllJobs, isEnableIndexDiskSyncs, isEnableIndexPageCaching, isEnableIndexRecoveryFile, isEnableIndexWriteAsync, isEnableJournalDiskSyncs, isFailIfDatabaseIsLocked, isForceRecoverIndex, isIgnoreMissingJournalfiles, isPurgeStoreOnStartup, isUseIndexLFRUEviction, load, setArchiveCorruptedIndex, setArchiveDataLogs, setCheckForCorruptJournalFiles, setCheckpointInterval, setChecksumJournalFiles, setCleanupInterval, setCleanupOnStop, setDeleteAllJobs, setDirectory, setDirectoryArchive, setEnableIndexDiskSyncs, setEnableIndexPageCaching, setEnableIndexRecoveryFile, setEnableIndexWriteAsync, setEnableJournalDiskSyncs, setFailIfDatabaseIsLocked, setForceRecoverIndex, setIgnoreMissingJournalfiles, setIndexCacheSize, setIndexLFUEvictionFactor, setIndexWriteBatchSize, setJournalMaxFileLength, setJournalMaxWriteBatchSize, setPurgeStoreOnStartup, setUseIndexLFRUEviction, size, startCheckpoint, store, store, store, store, store, toByteSequenceMethods inherited from class org.apache.activemq.broker.LockableServiceSupport
getBrokerService, getLocker, getLockKeepAlivePeriod, getScheduledThreadPoolExecutor, isStopOnError, isUseLock, keepLockAlive, postStop, preStart, setBrokerService, setLocker, setLockKeepAlivePeriod, setScheduledThreadPoolExecutor, setStopOnError, setUseLock, stopBrokerMethods inherited from class org.apache.activemq.util.ServiceSupport
addServiceListener, dispose, isStarted, isStopped, isStopping, removeServiceListener, start, stopMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.activemq.broker.scheduler.JobSchedulerStore
getDirectory, setDirectory, sizeMethods inherited from interface org.apache.activemq.Service
start, stop
-
Constructor Details
-
JobSchedulerStoreImpl
public JobSchedulerStoreImpl()
-
-
Method Details
-
getJobScheduler
- Specified by:
getJobSchedulerin interfaceJobSchedulerStore- Throws:
Exception
-
removeJobScheduler
- Specified by:
removeJobSchedulerin interfaceJobSchedulerStore- Throws:
Exception
-
setLegacyStoreArchiveDirectory
Sets the directory where the legacy scheduler store files are archived before an update attempt is made. Both the legacy index files and the journal files are moved to this folder prior to an upgrade attempt.- Parameters:
directory- The directory to move the legacy Scheduler Store files to.
-
getLegacyStoreArchiveDirectory
Gets the directory where the legacy Scheduler Store files will be archived if the broker is started and an existing Job Scheduler Store from an old version is detected.- Returns:
- the directory where scheduler store legacy files are archived on upgrade.
-
load
Description copied from class:AbstractKahaDBStoreLoads the store from disk. Based on configuration this method can either load an existing store or it can purge an existing store and start in a clean state.- Specified by:
loadin classAbstractKahaDBStore- Throws:
IOException- if an error occurs during the load.
-
unload
Description copied from class:AbstractKahaDBStoreUnload the state of the Store to disk and shuts down all resources assigned to this KahaDB store implementation.- Specified by:
unloadin classAbstractKahaDBStore- Throws:
IOException- if an error occurs during the store unload.
-
checkpointUpdate
Description copied from class:AbstractKahaDBStorePerform the checkpoint update operation. If the cleanup flag is true then the operation should also purge any unused Journal log files. This method must always be called with the checkpoint and index write locks held.- Specified by:
checkpointUpdatein classAbstractKahaDBStore- Parameters:
tx- The TX under which to perform the checkpoint update.cleanup- Should the checkpoint also do unused Journal file cleanup.- Throws:
IOException- if an error occurs while performing the checkpoint.
-
incrementJournalCount
Adds a reference for the journal log file pointed to by the given Location value. To prevent log files in the journal that still contain valid data that needs to be kept in order to allow for recovery the logs must have active references. Each Job scheduler should ensure that the logs are accurately referenced.- Parameters:
tx- The TX under which the update is to be performed.location- The location value to update the reference count of.- Throws:
IOException- if an error occurs while updating the journal references table.
-
decrementJournalCount
Removes one reference for the Journal log file indicated in the given Location value. The references are used to track which log files cannot be GC'd. When the reference count on a log file reaches zero the file id is removed from the tracker and the log will be removed on the next check point update.- Parameters:
tx- The TX under which the update is to be performed.location- The location value to update the reference count of.- Throws:
IOException- if an error occurs while updating the journal references table.
-
decrementJournalCount
protected void decrementJournalCount(Transaction tx, HashMap<Integer, Integer> decrementsByFileIds) throws IOExceptionRemoves multiple references for the Journal log file indicated in the given Location map. The references are used to track which log files cannot be GC'd. When the reference count on a log file reaches zero the file id is removed from the tracker and the log will be removed on the next check point update.- Parameters:
tx- The TX under which the update is to be performed.decrementsByFileIds- Map indicating how many decrements per fileId.- Throws:
IOException- if an error occurs while updating the journal references table.
-
referenceRemovedLocation
protected void referenceRemovedLocation(Transaction tx, Location location, org.apache.activemq.store.kahadb.scheduler.JobLocation removedJob) throws IOException Updates the Job removal tracking index with the location of a remove command and the original JobLocation entry. The JobLocation holds the locations in the logs where the add and update commands for a job stored. The log file containing the remove command can only be discarded after both the add and latest update log files have also been discarded.- Parameters:
tx- The TX under which the update is to be performed.location- The location value to reference a remove command.removedJob- The original JobLocation instance that holds the add and update locations- Throws:
IOException- if an error occurs while updating the remove location tracker.
-
referenceRemovedLocation
protected void referenceRemovedLocation(Transaction tx, Location location, List<Integer> removedJobsFileId) throws IOException Updates the Job removal tracking index with the location of a remove command and the original JobLocation entry. The JobLocation holds the locations in the logs where the add and update commands for a job stored. The log file containing the remove command can only be discarded after both the add and latest update log files have also been discarded.- Parameters:
tx- The TX under which the update is to be performed.location- The location value to reference a remove command.removedJobsFileId- List of the original JobLocation instances that holds the add and update locations- Throws:
IOException- if an error occurs while updating the remove location tracker.
-
getPayload
Retrieve the scheduled Job's byte blob from the journal.- Parameters:
location- The location of the KahaAddScheduledJobCommand that originated the Job.- Returns:
- a ByteSequence containing the payload of the scheduled Job.
- Throws:
IOException- if an error occurs while reading the payload value.
-
readLockIndex
public void readLockIndex() -
readUnlockIndex
public void readUnlockIndex() -
writeLockIndex
public void writeLockIndex() -
writeUnlockIndex
public void writeUnlockIndex() -
toString
-
getPageFileName
- Specified by:
getPageFileNamein classAbstractKahaDBStore- Returns:
- the name to give this store's PageFile instance.
-
getDefaultDataDirectory
- Specified by:
getDefaultDataDirectoryin classAbstractKahaDBStore- Returns:
- the location of the data directory if no set by configuration.
-
doRecover
protected void doRecover(JournalCommand<?> data, Location location, Location inDoubtlocation) throws IOException Called during index recovery to rebuild the index from the last known good location. For entries that occur before the last known good position we just ignore then and move on.- Parameters:
data- the command read from the Journal which should be used to update the index.location- the location in the index where the command was read.inDoubtlocation- the location in the index known to be the last time the index was valid.- Throws:
IOException- if an error occurs while recovering the index.
-
process
Called during recovery to allow the store to rebuild from scratch.- Specified by:
processin classAbstractKahaDBStore- Parameters:
data- The command to process, which was read from the Journal.location- The location of the command in the Journal.- Throws:
IOException- if an error occurs during command processing.
-
processLocation
-