ucar.nc2.ncml
Class Aggregation

java.lang.Object
  extended by ucar.nc2.ncml.Aggregation
Direct Known Subclasses:
AggregationOuterDimension, AggregationTiled, AggregationUnion

public abstract class Aggregation
extends Object

Superclass for NcML Aggregation. An Aggregation acts as a ProxyReader for VariableDS. That, is it must implement:

   public Array read(Variable mainv);
   public Array read(Variable mainv, Section section);
 

Author:
caron

Nested Class Summary
 class Aggregation.Dataset
          Encapsolates a NetcdfFile that is a component of the aggregation.
protected  class Aggregation.DatasetProxyReader
           
protected static class Aggregation.Type
           
protected static class Aggregation.TypicalDataset
           
 
Field Summary
protected  boolean cacheDirty
           
protected  DatasetCollectionManager datasetManager
           
protected  List<Aggregation.Dataset> datasets
           
protected  String dateFormatMark
           
protected  DateFormatter dateFormatter
           
protected static boolean debug
           
protected static boolean debugConvert
           
protected static boolean debugDateParse
           
protected static boolean debugOpenFile
           
protected static boolean debugProxy
           
protected static boolean debugRead
           
protected static boolean debugSyncDetail
           
protected  String dimName
           
protected static DiskCache2 diskCache2
           
protected static Executor executor
           
protected  List<Aggregation.Dataset> explicitDatasets
           
protected  boolean isDate
           
protected static org.slf4j.Logger logger
           
protected  NetcdfDataset ncDataset
           
protected  Object spiObject
           
protected  Aggregation.Type type
           
protected static Aggregation.TypicalDataset typicalDatasetMode
           
 
Constructor Summary
protected Aggregation(NetcdfDataset ncd, String dimName, Aggregation.Type type, String recheckS)
          Create an Aggregation for the given NetcdfDataset.
 
Method Summary
 void addCollection(String spec, String olderThan)
           
 void addDataset(Aggregation.Dataset nested)
           
 void addDatasetScan(org.jdom.Element crawlableDatasetElement, String dirName, String suffix, String regexpPatternString, String dateFormatMark, Set<NetcdfDataset.Enhance> enhanceMode, String subdirs, String olderThan)
          Add a dataset scan
 void addExplicitDataset(String cacheName, String location, String id, String ncoordS, String coordValueS, String sectionSpec, FileFactory reader)
          Add a nested dataset, specified by an explicit netcdf element.
protected abstract  void buildNetcdfDataset(CancelTask cancelTask)
          Call this to build the dataset objects in the NetcdfDataset
 void close()
           
protected  void closeDatasets()
           
protected  Variable findVariable(NetcdfFile ncfile, Variable mainV)
           
 void finish(CancelTask cancelTask)
           
 List<Aggregation.Dataset> getDatasets()
           
 void getDetailInfo(Formatter f)
           
 String getDimensionName()
          Get dimension name to join on
 String getFileTypeDescription()
           
 String getFileTypeId()
           
protected  String getLocation()
           
 Aggregation.Type getType()
          Get type of aggregation
protected  Aggregation.Dataset getTypicalDataset()
          Open one of the nested datasets as a template for the aggregation dataset.
protected  Aggregation.Dataset makeDataset(MFile dset)
           
protected  Aggregation.Dataset makeDataset(String cacheName, String location, String id, String ncoordS, String coordValueS, String sectionSpec, EnumSet<NetcdfDataset.Enhance> enhance, FileFactory reader)
          Dataset factory, so subclasses can override
protected  void makeDatasets(CancelTask cancelTask)
          Make the list of Datasets, from explicit and scans.
protected  void persistRead()
          read info from the persistent XML file, if it exists; overridden in AggregationExisting
 void persistWrite()
          Allow information to be make persistent.
protected abstract  void rebuildDataset()
          Call this when rescan has found changed datasets
protected  void setDatasetAcquireProxy(Aggregation.Dataset typicalDataset, NetcdfDataset newds)
           
static void setExecutor(Executor exec)
           
 void setModifications(org.jdom.Element ncmlMods)
           
static void setPersistenceCache(DiskCache2 dc)
           
static void setTypicalDatasetMode(String mode)
           
 boolean sync()
           
 boolean syncExtend()
          Check to see if its time to rescan directory, and if so, rescan and extend dataset if needed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

typicalDatasetMode

protected static Aggregation.TypicalDataset typicalDatasetMode

logger

protected static org.slf4j.Logger logger

diskCache2

protected static DiskCache2 diskCache2

executor

protected static Executor executor

debug

protected static boolean debug

debugOpenFile

protected static boolean debugOpenFile

debugSyncDetail

protected static boolean debugSyncDetail

debugProxy

protected static boolean debugProxy

debugRead

protected static boolean debugRead

debugDateParse

protected static boolean debugDateParse

debugConvert

protected static boolean debugConvert

ncDataset

protected NetcdfDataset ncDataset

type

protected Aggregation.Type type

spiObject

protected Object spiObject

explicitDatasets

protected List<Aggregation.Dataset> explicitDatasets

datasets

protected List<Aggregation.Dataset> datasets

datasetManager

protected DatasetCollectionManager datasetManager

cacheDirty

protected boolean cacheDirty

dimName

protected String dimName

dateFormatMark

protected String dateFormatMark

isDate

protected boolean isDate

dateFormatter

protected DateFormatter dateFormatter
Constructor Detail

Aggregation

protected Aggregation(NetcdfDataset ncd,
                      String dimName,
                      Aggregation.Type type,
                      String recheckS)
Create an Aggregation for the given NetcdfDataset. The following addXXXX methods are called, then finish(), before the object is ready for use.

Parameters:
ncd - Aggregation belongs to this NetcdfDataset
dimName - the aggregation dimension name
type - the Aggregation.Type
recheckS - how often to check if files have changes
Method Detail

setPersistenceCache

public static void setPersistenceCache(DiskCache2 dc)

setExecutor

public static void setExecutor(Executor exec)

setTypicalDatasetMode

public static void setTypicalDatasetMode(String mode)

addExplicitDataset

public void addExplicitDataset(String cacheName,
                               String location,
                               String id,
                               String ncoordS,
                               String coordValueS,
                               String sectionSpec,
                               FileFactory reader)
Add a nested dataset, specified by an explicit netcdf element. enhance is handled by the reader, so its always false here.

Parameters:
cacheName - a unique name to use for caching
location - attribute "location" on the netcdf element
id - attribute "id" on the netcdf element
ncoordS - attribute "ncoords" on the netcdf element
coordValueS - attribute "coordValue" on the netcdf element
sectionSpec - attribute "section" on the netcdf element
reader - factory for reading this netcdf dataset

addDataset

public void addDataset(Aggregation.Dataset nested)

addDatasetScan

public void addDatasetScan(org.jdom.Element crawlableDatasetElement,
                           String dirName,
                           String suffix,
                           String regexpPatternString,
                           String dateFormatMark,
                           Set<NetcdfDataset.Enhance> enhanceMode,
                           String subdirs,
                           String olderThan)
Add a dataset scan

Parameters:
crawlableDatasetElement - defines a CrawlableDataset, or null
dirName - scan this directory
suffix - filter on this suffix (may be null)
regexpPatternString - include if full name matches this regular expression (may be null)
dateFormatMark - create dates from the filename (may be null)
enhanceMode - how should files be enhanced
subdirs - equals "false" if should not descend into subdirectories
olderThan - files must be older than this time (now - lastModified >= olderThan); must be a time unit, may ne bull

addCollection

public void addCollection(String spec,
                          String olderThan)
                   throws IOException
Throws:
IOException

setModifications

public void setModifications(org.jdom.Element ncmlMods)

getType

public Aggregation.Type getType()
Get type of aggregation

Returns:
type of aggregation

getDimensionName

public String getDimensionName()
Get dimension name to join on

Returns:
dimension name or null if type union/tiled

getLocation

protected String getLocation()

close

public void close()
           throws IOException
Throws:
IOException

syncExtend

public boolean syncExtend()
                   throws IOException
Check to see if its time to rescan directory, and if so, rescan and extend dataset if needed. Note that this just calls sync(), so structural metadata may be modified (!!)

Returns:
true if directory was rescanned and dataset may have been updated
Throws:
IOException - on io error

sync

public boolean sync()
             throws IOException
Throws:
IOException

getFileTypeId

public String getFileTypeId()

getFileTypeDescription

public String getFileTypeDescription()

buildNetcdfDataset

protected abstract void buildNetcdfDataset(CancelTask cancelTask)
                                    throws IOException
Call this to build the dataset objects in the NetcdfDataset

Parameters:
cancelTask - maybe cancel
Throws:
IOException - on read error

rebuildDataset

protected abstract void rebuildDataset()
                                throws IOException
Call this when rescan has found changed datasets

Throws:
IOException - on read error

persistWrite

public void persistWrite()
                  throws IOException
Allow information to be make persistent. Overridden in AggregationExisting

Throws:
IOException - on error

persistRead

protected void persistRead()
read info from the persistent XML file, if it exists; overridden in AggregationExisting


closeDatasets

protected void closeDatasets()
                      throws IOException
Throws:
IOException

getDetailInfo

public void getDetailInfo(Formatter f)

finish

public void finish(CancelTask cancelTask)
            throws IOException
Throws:
IOException

getDatasets

public List<Aggregation.Dataset> getDatasets()

makeDatasets

protected void makeDatasets(CancelTask cancelTask)
                     throws IOException
Make the list of Datasets, from explicit and scans.

Parameters:
cancelTask - user can cancel
Throws:
IOException - on i/o error

getTypicalDataset

protected Aggregation.Dataset getTypicalDataset()
                                         throws IOException
Open one of the nested datasets as a template for the aggregation dataset.

Returns:
a typical Dataset
Throws:
FileNotFoundException - if there are no datasets
IOException

makeDataset

protected Aggregation.Dataset makeDataset(String cacheName,
                                          String location,
                                          String id,
                                          String ncoordS,
                                          String coordValueS,
                                          String sectionSpec,
                                          EnumSet<NetcdfDataset.Enhance> enhance,
                                          FileFactory reader)
Dataset factory, so subclasses can override

Parameters:
cacheName - a unique name to use for caching
location - attribute "location" on the netcdf element
id - attribute "id" on the netcdf element
ncoordS - attribute "ncoords" on the netcdf element
coordValueS - attribute "coordValue" on the netcdf element
sectionSpec - attribute "sectionSpec" on the netcdf element
enhance - open dataset in enhance mode NOT USED
reader - factory for reading this netcdf dataset
Returns:
a Aggregation.Dataset

makeDataset

protected Aggregation.Dataset makeDataset(MFile dset)

setDatasetAcquireProxy

protected void setDatasetAcquireProxy(Aggregation.Dataset typicalDataset,
                                      NetcdfDataset newds)
                               throws IOException
Throws:
IOException

findVariable

protected Variable findVariable(NetcdfFile ncfile,
                                Variable mainV)


Copyright © 1999-2011 UCAR/Unidata. All Rights Reserved.