Interface CollectionManager
-
- All Superinterfaces:
AutoCloseable
,Closeable
,MCollection
- All Known Implementing Classes:
CollectionManagerAbstract
,CollectionManagerCatalog
,MFileCollectionManager
public interface CollectionManager extends MCollection
Manages a dynamic collection of MFile objects. You must call scan() first. This is the older stuff used by FMRC. GRIB uses lighter weight MCollection. An MFile must have the property thatNetcdfDatasets.open(MFile.getPath, ...);
should work.A CollectionManager implements the
element. collection element
A collection element defines the collection of datasets.
<collection spec="/data/ldm/pub/native/satellite/3.9/WEST-CONUS_4km/WEST-CONUS_4km_3.9_#yyyyMMdd_HHmm#.gini$" name="WEST-CONUS_4km" olderThan="1 min" olderThan="15 min" />
The XML Schema:<xsd:complexType name="collectionType"> 1) <xsd:attribute name="spec" type="xsd:string" use="required"/> 2) <xsd:attribute name="name" type="xsd:token"/> 3) <xsd:attribute name="olderThan" type="xsd:string" /> 5) <xsd:attribute name="dateFormatMark" type="xsd:string"/> 6) <xsd:attribute name="timePartition" type="xsd:string"/> </xsd:complexType>
where
- spec: collection specification string (required).
- name: collection name must be unique in all of your TDS catalogs. This is used for external triggers and as an easy to read identifier for indexing, logging and debugging. If missing, the spec string is used (not a good idea in the context of the TDS).
- olderThan (optional): Only files whose lastModified date is older than this are included. This excludes files that are in the process of being written. However, it only applies to newly found files, that is, once a file is in the collection it is not removed because it got updated.
- dateFormatMark (optional): the collection specification string can only extract dates from the file name, as opposed to the file path, which includes all of the parent directory names. Use the dateFormatMark in order to extract the date from the full path. Use this OR a date extrator in the specification string, but not both.
- timePartition (optional):: experimental, not complete yet.
- Since:
- Jan 19, 2010
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
CollectionManager.ChangeChecker
static class
CollectionManager.TriggerEvent
static interface
CollectionManager.TriggerListener
A TriggerEvent.proto is sent if protoDataset.change = "cron" has been specified A TriggerEvent.update is sent if a scan has happened and a change in the list of MFiles has occurred, or an MFile has been updated
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
addEventListener(CollectionManager.TriggerListener l)
Register to get Trigger eventslong
getLastChanged()
Get the last time the collection changedlong
getLastScanned()
Get the last time scannedTimeDuration
getRecheck()
Get how often to rescanboolean
isScanNeeded()
Compute whether rescan is needed, based on getRecheck(), and the LastScanned value.boolean
isStatic()
static means doesnt need to be monitored for changes; can be externally triggered, or read in at startup.void
removeEventListener(CollectionManager.TriggerListener l)
boolean
scan(boolean sendEvent)
Scan the collection.boolean
scanIfNeeded()
If isScanNeeded(), do a scan.-
Methods inherited from interface thredds.inventory.MCollection
close, extractDate, getAuxInfo, getCollectionName, getFileIterator, getFilenames, getFilesSorted, getIndexFilename, getLastModified, getLatestFile, getPartitionDate, getProtoIndex, getRoot, hasDateExtractor, putAuxInfo
-
-
-
-
Method Detail
-
isStatic
boolean isStatic()
static means doesnt need to be monitored for changes; can be externally triggered, or read in at startup. true if no recheckAfter and no update.rescan- Returns:
- if static
-
getLastScanned
long getLastScanned()
Get the last time scanned- Returns:
- msecs since 1970
-
getLastChanged
long getLastChanged()
Get the last time the collection changed- Returns:
- msecs since 1970
-
getRecheck
TimeDuration getRecheck()
Get how often to rescan- Returns:
- time duration of rescan period, or null if none.
-
isScanNeeded
boolean isScanNeeded()
Compute whether rescan is needed, based on getRecheck(), and the LastScanned value.- Returns:
- true if rescan is needed.
-
scanIfNeeded
boolean scanIfNeeded() throws IOException
If isScanNeeded(), do a scan. Do not send an event.- Returns:
- true if scan was done, and anything changed.
- Throws:
IOException
- on io error
-
scan
boolean scan(boolean sendEvent) throws IOException
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
-
addEventListener
void addEventListener(CollectionManager.TriggerListener l)
Register to get Trigger events- Parameters:
l
- listener
-
removeEventListener
void removeEventListener(CollectionManager.TriggerListener l)
-
-