コード例 #1
0
  public Map<String, Object> shortReportMap() {
    Map<String, Object> data = new LinkedHashMap<String, Object>();
    data.put("serialNumber", serialNumber);
    CrawlURI c = currentCuri;
    if (c != null) {
      data.put("currentURI", c.toString());
      data.put("currentProcessor", currentProcessorName);
      data.put("fetchAttempts", c.getFetchAttempts());
    } else {
      data.put("currentURI", null);
    }

    long now = System.currentTimeMillis();
    long time = 0;
    if (lastFinishTime > lastStartTime) {
      data.put("status", "WAITING");
      time = now - lastFinishTime;
    } else if (lastStartTime > 0) {
      data.put("status", "ACTIVE");
      time = now - lastStartTime;
    }
    data.put("currentStatusElapsedMilliseconds", time);
    data.put("currentStatusElapsedPretty", ArchiveUtils.formatMillisecondsToConventional(time));
    data.put("step", step);
    return data;
  }
コード例 #2
0
  /**
   * Compiles and returns a report on its status.
   *
   * @param name Report name.
   * @param pw Where to print.
   */
  public void reportTo(String name, PrintWriter pw) {
    // name is ignored for now: only one kind of report

    pw.print("[");
    pw.println(getName());

    // Make a local copy of the currentCuri reference in case it gets
    // nulled while we're using it.  We're doing this because
    // alternative is synchronizing and we don't want to do this --
    // it causes hang ups as controller waits on a lock for this thread,
    // something it gets easily enough on old threading model but something
    // it can wait interminably for on NPTL threading model.
    // See [ 994946 ] Pause/Terminate ignored on 2.6 kernel 1.5 JVM.
    CrawlURI c = currentCuri;
    if (c != null) {
      pw.print(" ");
      c.shortReportLineTo(pw);
      pw.print("    ");
      pw.print(c.getFetchAttempts());
      pw.print(" attempts");
      pw.println();
      pw.print("    ");
      pw.print("in processor: ");
      pw.print(currentProcessorName);
    } else {
      pw.print(" -no CrawlURI- ");
    }
    pw.println();

    long now = System.currentTimeMillis();
    long time = 0;

    pw.print("    ");
    if (lastFinishTime > lastStartTime) {
      // That means we finished something after we last started something
      // or in other words we are not working on anything.
      pw.print("WAITING for ");
      time = now - lastFinishTime;
    } else if (lastStartTime > 0) {
      // We are working on something
      pw.print("ACTIVE for ");
      time = now - lastStartTime;
    }
    pw.print(ArchiveUtils.formatMillisecondsToConventional(time));
    pw.println();

    pw.print("    ");
    pw.print("step: ");
    pw.print(step);
    pw.print(" for ");
    pw.print(
        ArchiveUtils.formatMillisecondsToConventional(System.currentTimeMillis() - atStepSince));
    pw.println();

    reportThread(this, pw);
    pw.print("]");
    pw.println();

    pw.flush();
  }
コード例 #3
0
  /** @param w PrintWriter to write to. */
  public void shortReportLineTo(PrintWriter w) {
    w.print("#");
    w.print(this.serialNumber);

    // Make a local copy of the currentCuri reference in case it gets
    // nulled while we're using it.  We're doing this because
    // alternative is synchronizing and we don't want to do this --
    // it causes hang ups as controller waits on a lock for this thread,
    // something it gets easily enough on old threading model but something
    // it can wait interminably for on NPTL threading model.
    // See [ 994946 ] Pause/Terminate ignored on 2.6 kernel 1.5 JVM.
    CrawlURI c = currentCuri;
    if (c != null) {
      w.print(" ");
      w.print(currentProcessorName);
      w.print(" ");
      w.print(c.toString());
      w.print(" (");
      w.print(c.getFetchAttempts());
      w.print(") ");
    } else {
      w.print(" [no CrawlURI] ");
    }

    long now = System.currentTimeMillis();
    long time = 0;

    if (lastFinishTime > lastStartTime) {
      // That means we finished something after we last started something
      // or in other words we are not working on anything.
      w.print("WAITING for ");
      time = now - lastFinishTime;
    } else if (lastStartTime > 0) {
      // We are working on something
      w.print("ACTIVE for ");
      time = now - lastStartTime;
    }
    w.print(ArchiveUtils.formatMillisecondsToConventional(time));
    w.print(" at ");
    w.print(step);
    w.print(" for ");
    w.print(ArchiveUtils.formatMillisecondsToConventional(now - atStepSince));
    w.print("\n");
    w.flush();
  }