public void init() throws javax.servlet.ServletException { super.init(); org.slf4j.Logger logServerStartup = org.slf4j.LoggerFactory.getLogger("serverStartup"); logServerStartup.info( getClass().getName() + " initialization start - " + UsageLog.setupNonRequestContext()); this.ascLimit = ThreddsConfig.getInt("Opendap.ascLimit", ascLimit); this.binLimit = ThreddsConfig.getInt("Opendap.binLimit", binLimit); this.odapVersionString = ThreddsConfig.get("Opendap.serverVersion", odapVersionString); logServerStartup.info( getClass().getName() + " version= " + odapVersionString + " ascLimit = " + ascLimit + " binLimit = " + binLimit); // debugging actions makeDebugActions(); logServerStartup.info( getClass().getName() + " initialization done - " + UsageLog.closingMessageNonRequestContext()); }
void init(TdsContext tdsContext) { // new for 4.2 - feature collection caching String fcCache = ThreddsConfig.get( "FeatureCollection.cacheDirectory", tdsContext.getContentDirectory().getPath() + "/collectionCache/"); try { thredds.inventory.bdb.MetadataManager.setCacheDirectory(fcCache); startupLog.info("CdmInit: FeatureCollection.cacheDirectory= " + fcCache); } catch (Exception e) { startupLog.error("CdmInit: Failed to open FeatureCollection.cacheDirectory= " + fcCache, e); } // new for 4.1 - ehcache object caching String ehConfig = ThreddsConfig.get("ehcache.configFile", tdsContext.getWebinfPath() + "/ehcache.xml"); String ehDirectory = ThreddsConfig.get( "ehcache.directory", tdsContext.getContentDirectory().getPath() + "/ehcache/"); try { cacheManager = thredds.filesystem.ControllerCaching.makeStandardController(ehConfig, ehDirectory); thredds.inventory.DatasetCollectionManager.setController(cacheManager); startupLog.info("CdmInit: ehcache.config= " + ehConfig + " directory= " + ehDirectory); } catch (IOException ioe) { startupLog.error("CdmInit: Cant read ehcache config file " + ehConfig, ioe); } boolean useBytesForDataSize = ThreddsConfig.getBoolean("catalogWriting.useBytesForDataSize", false); InvCatalogFactory10.useBytesForDataSize(useBytesForDataSize); //////////////////////////////////// // AggregationFmrc.setDefinitionDirectory(new File(tdsContext.getRootDirectory(), // fmrcDefinitionDirectory)); FmrcInventoryServlet.setDefinitionDirectory( new File(tdsContext.getRootDirectory(), fmrcDefinitionDirectory)); // NetcdfFileCache : default is allow 200 - 400 open files, cleanup every 10 minutes int min = ThreddsConfig.getInt("NetcdfFileCache.minFiles", 200); int max = ThreddsConfig.getInt("NetcdfFileCache.maxFiles", 400); int secs = ThreddsConfig.getSeconds("NetcdfFileCache.scour", 10 * 60); if (max > 0) { NetcdfDataset.initNetcdfFileCache(min, max, secs); } // HTTP file access : // allow 20 - 40 open datasets, cleanup every 10 minutes min = ThreddsConfig.getInt("HTTPFileCache.minFiles", 25); max = ThreddsConfig.getInt("HTTPFileCache.maxFiles", 40); secs = ThreddsConfig.getSeconds("HTTPFileCache.scour", 10 * 60); if (max > 0) { ServletUtil.setFileCache(new FileCacheRaf(min, max, secs)); } // for backwards compatibility - should be replaced by direct specifying of the IndexExtendMode // turn off Grib extend indexing; indexes are automatically done every 10 minutes externally boolean extendIndex = ThreddsConfig.getBoolean("GribIndexing.setExtendIndex", false); GridServiceProvider.IndexExtendMode mode = extendIndex ? GridServiceProvider.IndexExtendMode.extendwrite : GridServiceProvider.IndexExtendMode.readonly; ucar.nc2.iosp.grid.GridServiceProvider.setIndexFileModeOnOpen(mode); ucar.nc2.iosp.grid.GridServiceProvider.setIndexFileModeOnSync(mode); boolean alwaysUseCache = ThreddsConfig.getBoolean("GribIndexing.alwaysUseCache", false); ucar.nc2.iosp.grid.GridServiceProvider.setIndexAlwaysInCache(alwaysUseCache); // optimization: netcdf-3 files can only grow, not have metadata changes ucar.nc2.NetcdfFile.setProperty("syncExtendOnly", "true"); // persist joinNew aggregations. default every 24 hours, delete stuff older than 90 days String dir = ThreddsConfig.get( "AggregationCache.dir", new File(tdsContext.getContentDirectory().getPath(), "cacheAged").getPath()); int scourSecs = ThreddsConfig.getSeconds("AggregationCache.scour", 24 * 60 * 60); int maxAgeSecs = ThreddsConfig.getSeconds("AggregationCache.maxAge", 90 * 24 * 60 * 60); aggCache = new DiskCache2(dir, false, maxAgeSecs / 60, scourSecs / 60); Aggregation.setPersistenceCache(aggCache); // how to choose the typical dataset ? String typicalDataset = ThreddsConfig.get("Aggregation.typicalDataset", "penultimate"); Aggregation.setTypicalDatasetMode(typicalDataset); // Nj22 disk cache dir = ThreddsConfig.get( "DiskCache.dir", new File(tdsContext.getContentDirectory(), "cache").getPath()); boolean alwaysUse = ThreddsConfig.getBoolean("DiskCache.alwaysUse", false); scourSecs = ThreddsConfig.getSeconds("DiskCache.scour", 60 * 60); long maxSize = ThreddsConfig.getBytes("DiskCache.maxSize", (long) 1000 * 1000 * 1000); DiskCache.setRootDirectory(dir); DiskCache.setCachePolicy(alwaysUse); Calendar c = Calendar.getInstance(); // contains current startup time c.add(Calendar.SECOND, scourSecs / 2); // starting in half the scour time timer = new Timer(); timer.scheduleAtFixedRate(new CacheScourTask(maxSize), c.getTime(), (long) 1000 * scourSecs); startupLog.info("CdmInit complete"); }