Esempio n. 1
0
    @Override
    public void run() {
      try {
        activity.setIndeterminate(false);
        activity.setValue(0);
        activity.setMaximum(9);
        setProperty(G_VERSION, Long.toString(gVersion.incrementAndGet()));
        activity.setProgressInfoLower("Writing uuidDb... ");
        activity.setValue(1);
        activity.setProgressInfoLower("Writing uuidsToNidMapDb... ");
        uuidsToNidMapDb.sync();
        activity.setValue(2);
        nidCidMapDb.sync();
        activity.setValue(3);
        activity.setProgressInfoLower("Writing statusAtPositionDb... ");
        stampDb.sync();
        activity.setValue(4);
        activity.setProgressInfoLower("Writing conceptDb... ");
        conceptDb.sync();
        activity.setValue(5);
        activity.setValue(6);
        activity.setProgressInfoLower("Writing propDb... ");
        propDb.sync();
        activity.setProgressInfoLower("Writing mutable environment... ");
        activity.setValue(7);
        mutable.bdbEnv.sync();
        activity.setProgressInfoLower("Writing readonly environment... ");
        activity.setValue(8);
        if (readOnly.bdbEnv.getConfig().getReadOnly() == false) {
          readOnly.bdbEnv.sync();
        }
        activity.setValue(9);
        long endTime = System.currentTimeMillis();

        long elapsed = endTime - startTime;
        String elapsedStr = TimeHelper.getElapsedTimeString(elapsed);

        activity.setProgressInfoUpper("Database sync complete.");
        activity.setProgressInfoLower("Elapsed: " + elapsedStr);
        activity.complete();
      } catch (DatabaseException | IOException e) {
        AceLog.getAppLog().alertAndLogException(e);
      } catch (ComputationCanceled e) {
        // Nothing to do
      }
    }
Esempio n. 2
0
 public static void setProperty(String key, String value) throws IOException {
   propDb.setProperty(key, value);
 }
Esempio n. 3
0
 public static String getProperty(String key) throws IOException {
   return propDb.getProperty(key);
 }
Esempio n. 4
0
 public static Map<String, String> getProperties() throws IOException {
   return propDb.getProperties();
 }
Esempio n. 5
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.");
  }