Пример #1
0
  private static void finishSetup() {
    setupLatch.countDown();
    if (setupLatch.getCount() == 0) {
      try {
        BdbTerminologyStore ts = new BdbTerminologyStore();
        if (P.s == null) {
          Ts.set(ts);
          FxTs.set(ts);
          P.s = ts;
        }
        Looker.add(ts, UUID.randomUUID(), "Embedded BdbTerminologyStore");
        Looker.add(
            new TtkConceptChronicleConverter(),
            UUID.randomUUID(),
            "TtkConceptChronicle to ConceptChronicleDTO converter");
        ConceptChronicle.reset();

        ReferenceConcepts.reset();
        String versionString = getProperty(G_VERSION);
        if (versionString != null) {
          gVersion.set(Long.parseLong(versionString));
        }
        if (viewCoordinateMapFile.exists()) {
          FileInputStream fis = new FileInputStream(viewCoordinateMapFile);
          try (ObjectInputStream ois = new ObjectInputStream(fis)) {
            try {
              viewCoordinates = (ConcurrentHashMap<UUID, ViewCoordinate>) ois.readObject();
            } catch (IOException | ClassNotFoundException ex) {
              Logger.getLogger(Bdb.class.getName()).log(Level.SEVERE, null, ex);
            }
          }
        }
        pathManager = BdbPathManager.get();
        Looker.lookup(TermstoreLatch.class).openLatch();

        AceLog.getAppLog()
            .info(
                "mutable maxMem: " + Bdb.mutable.bdbEnv.getConfig().getConfigParam("je.maxMemory"));
        AceLog.getAppLog()
            .info("mutable shared cache: " + Bdb.mutable.bdbEnv.getConfig().getSharedCache());
        AceLog.getAppLog()
            .info(
                "readOnly maxMem: "
                    + Bdb.readOnly.bdbEnv.getConfig().getConfigParam("je.maxMemory"));
        AceLog.getAppLog()
            .info("readOnly shared cache: " + Bdb.readOnly.bdbEnv.getConfig().getSharedCache());

      } catch (IOException ex) {
        Logger.getLogger(Bdb.class.getName()).log(Level.SEVERE, null, ex);
      }
    }
  }
Пример #2
0
 public static UUID getPrimUuidForComponent(int nid) throws IOException {
   int cNid = Bdb.getConceptNid(nid);
   assert cNid != Integer.MAX_VALUE : "No cNid for nid: " + nid;
   ConceptChronicle c = ConceptChronicle.get(cNid);
   ComponentChronicleBI<?> component = c.getComponent(nid);
   if (component != null) {
     return component.getPrimordialUuid();
   }
   String warning = "Can't find component: " + nid + " in concept: " + c.toLongString();
   AceLog.getAppLog().warning(warning);
   return null;
 }
Пример #3
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
      }
    }
Пример #4
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.");
  }