コード例 #1
0
 def init(self, cfg=None):
     """ This method will be called twice, once with a cfg parameter
         and once without """
     if cfg is None:
         HttpServlet.init(self)
     else:
         HttpServlet.init(self, cfg)
     # These are the things we only do once
     if WMS.timer is None:
         WMS.timer = Timer(1) # timer is a daemon
         # Load the Log4j configuration file
         file = self.getInitParameter("log4j-init-file")
         if file is not None:
             prefix = self.getServletContext().getRealPath("/")
             PropertyConfigurator.configure(prefix + file)
         WMS.logger.debug("Initialized logging system")
         # Initialize the cache of datasets
         DatasetCache.init()
         WMS.logger.debug("Initialized DatasetCache")
         # Start a timer that will clear the cache at regular intervals
         # so that NcML aggregations are reloaded
         # TODO: get the interval value from a config file
         intervalInMs = int(60 * 1000) # Runs once a minute
         WMS.cacheWiper = CacheWiper()
         WMS.timer.scheduleAtFixedRate(WMS.cacheWiper, intervalInMs, intervalInMs)
         WMS.logger.debug("Initialized NetcdfDatasetCache refresher")
         WMS.logger.debug("ncWMS Servlet initialized")
コード例 #2
0
def getVariableMetadata(location):
    """ returns a dictionary of VariableMetadata objects.  The keys
        in the dictionary are the unique ids of the variables and
        the values are VariableMetadata objects
        location = location of dataset (full file path, OPeNDAP URL etc) """
    # Get the dataset from the cache
    return DatasetCache.getVariableMetadata(location)
コード例 #3
0
 def destroy(self):
     DatasetCache.exit()
     if WMS.timer is not None:
         WMS.timer.cancel()
     WMS.logger.debug("ncWMS Servlet destroyed")
コード例 #4
0
 def run(self):
     DatasetCache.clear()
     self.timeLastRan = time.time()
     self.logger.debug("Cleared cache")