Package thredds.inventory
Class MFileCollectionManager
- java.lang.Object
-
- thredds.inventory.CollectionAbstract
-
- thredds.inventory.CollectionManagerAbstract
-
- thredds.inventory.MFileCollectionManager
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
,CollectionManager
,MCollection
@ThreadSafe public class MFileCollectionManager extends CollectionManagerAbstract
Manage Collections of MFiles. Used in:- thredds.inventory
- ucar.nc2.ft.fmrc.Fmrc
- ucar.nc2.ncml.Aggregation
- Since:
- Jul 8, 2009
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class thredds.inventory.CollectionAbstract
CollectionAbstract.DateSorter, CollectionAbstract.MyStreamFilter
-
Nested classes/interfaces inherited from interface thredds.inventory.CollectionManager
CollectionManager.ChangeChecker, CollectionManager.TriggerEvent, CollectionManager.TriggerListener
-
-
Field Summary
Fields Modifier and Type Field Description protected CollectionManager.ChangeChecker
changeChecker
protected FeatureCollectionConfig
config
-
Fields inherited from class thredds.inventory.CollectionAbstract
auxInfo, CATALOG, collectionName, dateExtractor, DIR, FILE, GLOB, lastModified, LIST, logger, protoChoice, root, sfilter, startCollection
-
-
Constructor Summary
Constructors Modifier Constructor Description MFileCollectionManager(String name, String spec, Formatter errlog, org.slf4j.Logger logger)
protected
MFileCollectionManager(String name, org.slf4j.Logger logger)
MFileCollectionManager(String name, CollectionConfig mc, CalendarDate startPartition, org.slf4j.Logger logger)
MFileCollectionManager(FeatureCollectionConfig config, Formatter errlog, org.slf4j.Logger logger)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addDirectoryScan(String dirName, String suffix, String regexpPatternString, String subdirsS, String olderS, Object auxInfo)
Add a directory scan to the collectionMController
getController()
Map<String,String>
getFilesRunDateMap()
Iterable<MFile>
getFilesSorted()
Get the current collection of MFile.long
getLastChanged()
Get the last time the collection changedlong
getLastScanned()
Get the last time scannedlong
getOlderThanFilterInMSecs()
boolean
hasDateExtractor()
Does this CollectionManager have the ability to extract a date from the MFile ?protected boolean
hasScans()
boolean
isScanNeeded()
Compute if synchronous scan is needed.static MFileCollectionManager
open(String collectionName, String collectionSpec, String olderThan, Formatter errlog)
static MFileCollectionManager
openWithRecheck(String collectionName, String recheckS)
protected void
reallyScan(Map<String,MFile> map)
boolean
scan(boolean sendEvent)
Scan the collection.void
setChangeChecker(CollectionManager.ChangeChecker strat)
void
setController(MController _controller)
Set the MController used by scan.void
setFiles(Iterable<MFile> files)
void
setFilesAndRunDate(Map<String,String> filesRunDateMap)
String
toString()
-
Methods inherited from class thredds.inventory.CollectionManagerAbstract
addEventListener, close, getFileIterator, getRecheck, isStatic, removeEventListener, scanIfNeeded, setStatic
-
Methods inherited from class thredds.inventory.CollectionAbstract
cleanName, extractDate, getAuxInfo, getCollectionName, getFilenames, getIndexFilename, getLastModified, getLatestFile, getPartitionDate, getProtoIndex, getRoot, makeFileListSorted, parseOlderThanString, putAuxInfo, setDateExtractor, setRoot, setStreamFilter
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface thredds.inventory.MCollection
extractDate, getAuxInfo, getCollectionName, getFilenames, getIndexFilename, getLastModified, getLatestFile, getPartitionDate, getProtoIndex, getRoot, putAuxInfo
-
-
-
-
Field Detail
-
config
protected FeatureCollectionConfig config
-
changeChecker
protected CollectionManager.ChangeChecker changeChecker
-
-
Constructor Detail
-
MFileCollectionManager
public MFileCollectionManager(FeatureCollectionConfig config, Formatter errlog, org.slf4j.Logger logger)
-
MFileCollectionManager
protected MFileCollectionManager(String name, org.slf4j.Logger logger)
-
MFileCollectionManager
public MFileCollectionManager(String name, String spec, Formatter errlog, org.slf4j.Logger logger)
-
MFileCollectionManager
public MFileCollectionManager(String name, CollectionConfig mc, CalendarDate startPartition, org.slf4j.Logger logger)
-
-
Method Detail
-
setController
public void setController(MController _controller)
Set the MController used by scan. Defaults to thredds.filesystem.ControllerOS() if not set.- Parameters:
_controller
- use this MController
-
getController
public MController getController()
-
open
public static MFileCollectionManager open(String collectionName, String collectionSpec, String olderThan, Formatter errlog)
-
openWithRecheck
public static MFileCollectionManager openWithRecheck(String collectionName, String recheckS)
-
addDirectoryScan
public void addDirectoryScan(String dirName, String suffix, String regexpPatternString, String subdirsS, String olderS, Object auxInfo)
Add a directory scan to the collection- Parameters:
dirName
- scan this directorysuffix
- require this suffix (overriddden by regexp), may be nullregexpPatternString
- if present, use this reqular expression to filter files , may be nullsubdirsS
- if "true", descend into subdirectories, may be nullolderS
- udunit time unit - files must be older than this amount of time (now - lastModified > olderTime), may be null // * @param dateFormatString dateFormatMark string, may be nullauxInfo
- attach this object to any MFile found by this scan
-
getOlderThanFilterInMSecs
public long getOlderThanFilterInMSecs()
-
getLastScanned
public long getLastScanned()
Description copied from interface:CollectionManager
Get the last time scanned- Returns:
- msecs since 1970
-
getLastChanged
public long getLastChanged()
Description copied from interface:CollectionManager
Get the last time the collection changed- Returns:
- msecs since 1970
-
hasScans
protected boolean hasScans()
-
isScanNeeded
public boolean isScanNeeded()
Compute if synchronous scan is needed. True if recheck is true and enough time has elapsed.- Returns:
- true if rescan is needed
-
setChangeChecker
public void setChangeChecker(CollectionManager.ChangeChecker strat)
-
scan
public boolean scan(boolean sendEvent) throws IOException
Description copied from interface:CollectionManager
Scan the collection. Files may have been deleted or added since last time. If the MFile already exists in the current list, leave it in the list. If anything changes, send TriggerEvent(TriggerType.update) and return true Get the results from getFiles()- Returns:
- true if anything actually changed.
- Throws:
IOException
- on I/O error
-
getFilesSorted
public Iterable<MFile> getFilesSorted()
Description copied from interface:MCollection
Get the current collection of MFile. if hasDateExtractor() == true, these will be sorted by Date, otherwise by path.- Returns:
- current collection of MFile as an Iterable.
-
hasDateExtractor
public boolean hasDateExtractor()
Description copied from interface:MCollection
Does this CollectionManager have the ability to extract a date from the MFile ?- Specified by:
hasDateExtractor
in interfaceMCollection
- Overrides:
hasDateExtractor
in classCollectionAbstract
- Returns:
- true if CollectionManager has a DateExtractor
-
reallyScan
protected void reallyScan(Map<String,MFile> map) throws IOException
- Throws:
IOException
-
-