示例#1
0
  public static Map<String, Long> getCounters() {
    Map<String, Long> map = new HashMap<String, Long>();

    map.put("docCount", new Long(_docCount.get()));
    map.put("orphanCount", new Long(_orphanCount.get()));
    map.put("oplogCount", new Long(_oplogCount.get()));
    map.put("oplogReads", new Long(_oplogReads.get()));

    if (_ts > 0) {
      long secs = ((System.currentTimeMillis() - _ts) / 1000);
      if (secs == 0) {
        secs = 1;
      }

      if (DocWriter.get_running()) {
        map.put("docsPerSec", map.get("docCount") / secs);
        map.put("orphansPerSec", map.get("orphanCount") / secs);
        _lastDocPerSec = map.get("docsPerSec");
        _lastOrphanPerSec = map.get("orphansPerSec");
      } else {
        map.put("docsPerSec", _lastDocPerSec);
        map.put("orphansPerSec", _lastOrphanPerSec);
      }

      map.put("oplogsPerSec", map.get("oplogCount") / secs);

    } else {
      map.put("docsPerSec", new Long(0));
      map.put("orphansPerSec", new Long(0));
      map.put("oplogsPerSec", new Long(0));
      map.put("oplogReads", new Long(0));

      if (map.get("docCount") > 0) _ts = System.currentTimeMillis();
    }

    return map;
  }
示例#2
0
  private void runCompiler() {
    if (!shouldRunCompiler()) {
      System.exit(-1);
    }

    Instant start = Instant.now();
    config.getOutputStream().println("Generating documentation...");

    int result = 0;
    try {
      result = doRun();
    } catch (FlagUsageException e) {
      System.err.println(e.getMessage());
      System.exit(-1);
    } catch (Throwable t) {
      t.printStackTrace(System.err);
      System.exit(-2);
    }

    if (result != 0) {
      System.exit(result);
    }

    DocWriter writer =
        new DocWriter(
            config.getOutput(),
            Iterables.concat(config.getSources(), config.getModules()),
            config.getSrcPrefix(),
            config.getReadme(),
            config.getCustomPages(),
            typeRegistry,
            config.getTypeFilter(),
            new Linker(
                config.getOutput(),
                config.getSrcPrefix(),
                config.getModulePrefix(),
                config.getTypeFilter(),
                typeRegistry),
            new CommentParser(config.useMarkdown()));
    try {
      writer.generateDocs();
      if (config.isZipOutput()) {
        config.getOutput().getFileSystem().close();
      }
    } catch (IOException e) {
      e.printStackTrace(System.err);
      System.exit(-3);
    }

    Instant stop = Instant.now();
    String output =
        new PeriodFormatterBuilder()
            .appendHours()
            .appendSuffix("h") // I hope not...
            .appendSeparator(" ")
            .appendMinutes()
            .appendSuffix("m")
            .appendSeparator(" ")
            .appendSecondsWithOptionalMillis()
            .appendSuffix("s")
            .toFormatter()
            .print(new Period(start, stop));

    config.getOutputStream().println("Finished in " + output);
  }