Package org.dlese.dpc.oai.harvester
Class ScheduledHarvestManager
java.lang.Object
org.dlese.dpc.oai.harvester.ScheduledHarvestManager
Runs, logs and manages ScheduledHarvests.
- Version:
- $Id: ScheduledHarvestManager.java,v 1.23.2.3 2013/05/27 04:05:39 jweather Exp $
- Author:
- John Weatherley
-
Constructor Summary
ConstructorsConstructorDescriptionScheduledHarvestManager(SimpleDataStore dataStore, File initialHarvestDir, SimpleLuceneIndex harvestLogIndex, int timeOutMilliseconds) Constructor for the ScheduledHarvestManager -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds a ScheduledHarvest to this manager or replaces an existing one with the same ID.booleancontainsScheduledHarvest(Long shUid) Determines whether the given ScheduledHarvest ID is in this manager.booleanDetermine whether the given ScheduledHarvest value is in this manager.static StringReturn a string for the current time and date, sutiable for display in log files and output to standout:Gets the harvestDir attribute of the ScheduledHarvestManager objectstatic DategetHarvestStartDate(String startTimeString) Gets the date and time to begin the harvest by parsing a String in 24 hour time format such as 12:24 or 23:15.getScheduledHarvest(Long shUid) Gets the scheduledHarvest, or null if none exists.Gets all scheduledHarvests in this this manager.voidharvestNow(Long shUid, boolean harvestAll, boolean harvestAllIfNoDeletedRecord) Harvests the given ScheduledHarvest immediately, if not already running.booleanDetermines wheter the given ScheduledHarvest is currently running.booleanDetermines whether a given ScheduledHarvest is already running.voidoneTimeHarvest(ScheduledHarvest sh, Date from, Date until, File harvestDir, boolean harvestAllIfNoDeletedRecord) Performs a one-time only harvest in the background.voidRemoves log entries showing entrytype status inprogress and replaces them with an error message indicateing that the given harvest was terminated by a server shut-down or crash.voidremoveScheduledHarvest(Long shUid, boolean deletefiles) Removes the given ScheduledHarvest.static voidsetDebug(boolean db) Sets the debug attribute objectvoidsetHarvestDir(File harvestDir) Sets the harvestDir attribute of the ScheduledHarvestManager objectvoidStops all running harvests gracefully.voidstopTimerThread(Long shUid) Stops the timer
-
Constructor Details
-
ScheduledHarvestManager
public ScheduledHarvestManager(SimpleDataStore dataStore, File initialHarvestDir, SimpleLuceneIndex harvestLogIndex, int timeOutMilliseconds) Constructor for the ScheduledHarvestManager- Parameters:
dataStore- The data store that will hold persistent data for this manager.initialHarvestDir- The initial directory where harvested files will be saved.harvestLogIndex- The harvest log index used to log harvests.timeOutMilliseconds- Number of milliseconds the harvester will wait for a response from the data provider before timing out
-
-
Method Details
-
removeInProgresstLogEntries
public void removeInProgresstLogEntries()Removes log entries showing entrytype status inprogress and replaces them with an error message indicateing that the given harvest was terminated by a server shut-down or crash. This method should only be called once upon server initialization. -
setHarvestDir
Sets the harvestDir attribute of the ScheduledHarvestManager object- Parameters:
harvestDir- The new harvestDir value
-
getHarvestDir
Gets the harvestDir attribute of the ScheduledHarvestManager object- Returns:
- The harvestDir value
-
isRunning
Determines wheter the given ScheduledHarvest is currently running.- Parameters:
shUid- ScheduledHarvest ID.- Returns:
- True if running.
-
getScheduledHarvests
Gets all scheduledHarvests in this this manager.- Returns:
- The scheduledHarvests
-
getScheduledHarvest
Gets the scheduledHarvest, or null if none exists.- Parameters:
shUid- The ID of the item to retrieve.- Returns:
- The scheduledHarvest value
-
addScheduledHarvest
Adds a ScheduledHarvest to this manager or replaces an existing one with the same ID.- Parameters:
sh- The ScheduledHarvest to add.
-
removeScheduledHarvest
Removes the given ScheduledHarvest.- Parameters:
shUid- ScheduledHarvest ID to removedeletefiles- Description of the Parameter
-
containsScheduledHarvest
Determines whether the given ScheduledHarvest ID is in this manager.- Parameters:
shUid- ScheduledHarvest ID- Returns:
- True if the given ScheduledHarvest ID exists in this manager.
-
containsValue
Determine whether the given ScheduledHarvest value is in this manager.- Parameters:
sh- ScheduledHarvest- Returns:
- True if the ScheduledHarvest exists in this manager, else false.
-
harvestNow
Harvests the given ScheduledHarvest immediately, if not already running.- Parameters:
shUid- Uid of the ScheduledHarvest.harvestAll- True to havest all records, false to havest only records changed since the previous harvest.harvestAllIfNoDeletedRecord- True to harvest all records from scratch if deleted records are not supported
-
isRunningOneTimeHarvest
Determines whether a given ScheduledHarvest is already running.- Parameters:
sh- The ScheduledHarvest- Returns:
- True if already running, else false.
-
oneTimeHarvest
public void oneTimeHarvest(ScheduledHarvest sh, Date from, Date until, File harvestDir, boolean harvestAllIfNoDeletedRecord) Performs a one-time only harvest in the background.- Parameters:
sh- A ScheduledHarvest with appropriate settings.from- From Dateuntil- Until DateharvestDir- Directory where harvested records will be saved.harvestAllIfNoDeletedRecord- True to harvest all records from scratch if deleted records are not supported
-
stopAllHarvests
public void stopAllHarvests()Stops all running harvests gracefully. -
stopTimerThread
Stops the timer- Parameters:
shUid- The uid of the ScheduledHarvest.
-
getHarvestStartDate
Gets the date and time to begin the harvest by parsing a String in 24 hour time format such as 12:24 or 23:15.- Parameters:
startTimeString- The hour and minute in 24 hour time, for example 23:15- Returns:
- The Date the harvest will begin
- Throws:
ParseException- If unable to parse
-
getDateStamp
Return a string for the current time and date, sutiable for display in log files and output to standout:- Returns:
- The dateStamp value
-
setDebug
public static void setDebug(boolean db) Sets the debug attribute object- Parameters:
db- The new debug value
-