Java Code Examples for ucar.nc2.dataset.NetcdfDataset#shutdown()

The following examples show how to use ucar.nc2.dataset.NetcdfDataset#shutdown() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestAggNested.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Test
public void TestCached() throws IOException {
  try {
    NetcdfDataset.initNetcdfFileCache(10, 20, -1);

    String filename = TestDir.cdmUnitTestDir + "ncml/nestedAgg/test.ncml";
    try (NetcdfDataset ncd = NetcdfDataset.acquireDataset(DatasetUrl.findDatasetUrl(filename), true, null)) {
      Variable time = ncd.findVariable("time");
      assertThat(time.getSize()).isEqualTo(19723);
      // System.out.printf(" time array = %s%n", NCdumpW.toString(time.read()));
    }

    FileCacheIF cache = NetcdfDataset.getNetcdfFileCache();
    cache.showCache();
  } finally {
    NetcdfDataset.shutdown();
  }
}
 
Example 2
Source File: TestAggDatasetIsCached.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@AfterClass
public static void cleanupClass() {
  // Undo global changes we made in setupSpec() so that they do not affect subsequent test classes.
  NetcdfDataset.shutdown();
}
 
Example 3
Source File: TestCompositeStationCollectionsWithCaches.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@AfterClass
public static void cleanup() {
  NetcdfDataset.shutdown();
  RandomAccessFile.setGlobalFileCache(null);
}
 
Example 4
Source File: TdsInit.java    From tds with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public void destroy() {
  System.out.printf("TdsInit.destroy() is called%n");

  // prefs
  try {
    store.save();
  } catch (IOException ioe) {
    ioe.printStackTrace();
    startupLog.error("TdsInit: Prefs save failed", ioe);
  }

  // background threads
  if (cdmDiskCacheTimer != null)
    cdmDiskCacheTimer.cancel();
  FileCache.shutdown(); // this handles background threads for all instances of FileCache
  DiskCache2.exit(); // this handles background threads for all instances of DiskCache2
  executor.shutdownNow();

  /*
   * try {
   * catalogWatcher.close();
   * } catch (IOException ioe) {
   * ioe.printStackTrace();
   * startupLog.error("catalogWatcher close failed", ioe);
   * }
   */

  // open file caches
  RandomAccessFile.shutdown();
  NetcdfDataset.shutdown();
  NetcdfDatasets.shutdown();

  // memory caches
  GribCdmIndex.shutdown();
  datasetManager.setDatasetTracker(null); // closes the existing tracker

  collectionUpdater.shutdown();
  startupLog.info("TdsInit shutdown");
  MDC.clear();
}