Exemple #1
0
  // Close the environment
  public static void close() throws InterruptedException, ExecutionException {
    if (closed == false && mutable != null && mutable.bdbEnv != null) {
      closed = true;
      try {
        I_ShowActivity activity = new ConsoleActivityViewer();

        activity.setStopButtonVisible(false);

        activity.setProgressInfoLower("1-a/11: Stopping Isa Cache generation.");

        FileOutputStream fos = new FileOutputStream(viewCoordinateMapFile);
        try (ObjectOutputStream oos = new ObjectOutputStream(fos)) {
          oos.writeObject(viewCoordinates);
        }

        activity.setProgressInfoLower("2/11: Starting sync using service.");
        assert conceptDb != null : "conceptDb is null...";
        new Sync().run();
        activity.setProgressInfoLower("3/11: Shutting down sync service.");
        syncService.shutdown();

        activity.setProgressInfoLower("4/11: Awaiting termination of sync service.");
        syncService.awaitTermination(90, TimeUnit.MINUTES);

        activity.setProgressInfoLower("5/11: Starting PositionMapper close.");
        activity.setProgressInfoLower("6/11: Canceling uncommitted changes.");
        BdbCommitManager.cancel();
        activity.setProgressInfoLower("7/11: Starting BdbCommitManager shutdown.");
        BdbCommitManager.shutdown();
        activity.setProgressInfoLower("8/11: Starting LuceneManager close.");
        LuceneManager.close();

        NidDataFromBdb.close();
        activity.setProgressInfoLower("9/11: Starting mutable.bdbEnv.sync().");
        mutable.bdbEnv.sync();
        activity.setProgressInfoLower("10/11: mutable.bdbEnv.sync() finished.");
        uuidsToNidMapDb.close();
        nidCidMapDb.close();
        stampDb.close();
        conceptDb.close();
        propDb.close();
        mutable.bdbEnv.sync();
        mutable.bdbEnv.close();
        stampCache.clear();
        activity.setProgressInfoLower("11/11: Shutdown complete");
      } catch (DatabaseException e) {
        AceLog.getAppLog().alertAndLogException(e);
      } catch (Exception e) {
        AceLog.getAppLog().alertAndLogException(e);
      }
    }
    if (readOnly != null && readOnly.bdbEnv != null) {
      readOnly.bdbEnv.close();
    }
    annotationConcepts = null;
    conceptDb = null;
    mutable = null;
    nidCidMapDb = null;
    pathManager = null;
    propDb = null;
    readOnly = null;
    stampCache = null;
    stampDb = null;
    uuidsToNidMapDb = null;

    ConceptChronicle.reset();
    AceLog.getAppLog().info("bdb close finished.");
  }