Exemplo n.º 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);
      }
    }
  }
Exemplo n.º 2
0
  public static void setup(String dbRoot, boolean staticPublish) {

    System.out.println("setup dbRoot: " + dbRoot);
    stampCache = new ConcurrentHashMap<>();
    try {
      closed = false;
      syncService =
          Executors.newFixedThreadPool(1, new NamedThreadFactory(dbdThreadGroup, "Sync service"));

      BdbCommitManager.reset();
      NidDataFromBdb.resetExecutorPool();
      BdbPathManager.reset();

      for (@SuppressWarnings("unused") OFFSETS o : OFFSETS.values()) {
        // ensure all OFFSETS are initialized prior to multi-threading.
      }
      bdbDirectory = new File(dbRoot);
      System.out.println("absolute dbRoot: " + bdbDirectory.getAbsolutePath());
      viewCoordinateMapFile = new File(bdbDirectory, "viewCoordinates.oos");
      bdbDirectory.mkdirs();
      LuceneManager.setLuceneRootDir(bdbDirectory);

      mutable = new Bdb(false, new File(bdbDirectory, "mutable"));
      File readOnlyDir = new File(bdbDirectory, "read-only");
      boolean readOnlyExists = readOnlyDir.exists();
      readOnly = new Bdb(readOnlyExists, readOnlyDir);
      if (Looker.lookup(TtkEnvironment.class).useFxWorkers()) {

        Platform.runLater(
            new Runnable() {
              @Override
              public void run() {
                try {

                  startupWithFx();

                } catch (InterruptedException | ExecutionException ex) {
                  Logger.getLogger(Bdb.class.getName()).log(Level.SEVERE, null, ex);
                }
              }
            });
      } else {
        startupNoFx();
      }

    } catch (IOException | DatabaseException | IllegalArgumentException e) {
      throw new RuntimeException(e);
    } catch (InterruptedException ex) {
      Logger.getLogger(Bdb.class.getName()).log(Level.SEVERE, null, ex);
    } catch (ExecutionException ex) {
      Logger.getLogger(Bdb.class.getName()).log(Level.SEVERE, null, ex);
    }
  }