Пример #1
0
  protected String getExplanation(Lifecycle state) {
    Duration serviceFailedStabilizationDelay = getConfig(ENTITY_FAILED_STABILIZATION_DELAY);
    Duration serviceRecoveredStabilizationDelay = getConfig(ENTITY_RECOVERED_STABILIZATION_DELAY);

    return String.format(
        "location=%s; status=%s; lastPublished=%s; timeNow=%s; "
            + "currentFailurePeriod=%s; currentRecoveryPeriod=%s",
        entity.getLocations(),
        (state != null ? state : "<unreported>"),
        lastPublished,
        Time.makeDateString(System.currentTimeMillis()),
        (currentFailureStartTime != null ? getTimeStringSince(currentFailureStartTime) : "<none>")
            + " (stabilization "
            + Time.makeTimeStringRounded(serviceFailedStabilizationDelay)
            + ")",
        (currentRecoveryStartTime != null ? getTimeStringSince(currentRecoveryStartTime) : "<none>")
            + " (stabilization "
            + Time.makeTimeStringRounded(serviceRecoveredStabilizationDelay)
            + ")");
  }
Пример #2
0
 private String getTimeStringSince(Long time) {
   return time == null ? null : Time.makeTimeStringRounded(System.currentTimeMillis() - time);
 }