Exemple #1
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);
    }
  }