Esempio n. 1
0
  void run(String... args) throws ToolFailureException {
    Args arguments = Args.withFlags(RECOVERY, PROP_OWNER).parse(args);
    String storeDir = determineStoreDirectory(arguments);
    Config tuningConfiguration = readTuningConfiguration(storeDir, arguments);

    attemptRecoveryOrCheckStateOfLogicalLogs(arguments, storeDir);

    StringLogger logger = StringLogger.SYSTEM;
    try {
      consistencyCheckService.runFullConsistencyCheck(
          storeDir, tuningConfiguration, ProgressMonitorFactory.textual(System.err), logger);
    } catch (ConsistencyCheckIncompleteException e) {
      throw new ToolFailureException("Check aborted due to exception", e);
    } finally {
      logger.flush();
    }
  }
  private static void run(Configuration configuration) throws Exception {
    if (configuration.get(generate_graph)) {
      DataGenerator.run(configuration);
    }
    // ensure that the store is recovered
    new GraphDatabaseFactory()
        .newEmbeddedDatabase(configuration.get(DataGenerator.store_dir))
        .shutdown();

    // run the consistency check
    ProgressMonitorFactory progress;
    if (configuration.get(DataGenerator.report_progress)) {
      progress = ProgressMonitorFactory.textual(System.out);
    } else {
      progress = ProgressMonitorFactory.NONE;
    }
    if (configuration.get(wait_before_check)) {
      System.out.println("Press return to start the checker...");
      System.in.read();
    }

    Config tuningConfiguration = buildTuningConfiguration(configuration);
    fileSystem = new DefaultFileSystemAbstraction();
    ConfiguringPageCacheFactory pageCacheFactory =
        new ConfiguringPageCacheFactory(fileSystem, tuningConfiguration, PageCacheTracer.NULL);
    pageCache = pageCacheFactory.getOrCreatePageCache();
    DirectStoreAccess directStoreAccess =
        createScannableStores(configuration.get(DataGenerator.store_dir), tuningConfiguration);

    JsonReportWriter reportWriter = new JsonReportWriter(configuration, tuningConfiguration);
    TimingProgress progressMonitor = new TimingProgress(new TimeLogger(reportWriter), progress);

    try {
      configuration
          .get(checker_version)
          .run(progressMonitor, directStoreAccess, tuningConfiguration);
    } finally {
      directStoreAccess.close();
      pageCache.close();
    }
  }