Exemplo n.º 1
0
  public static String getUTCTimeZoneOffset() {

    Calendar calendar = Calendar.getInstance();

    TimeZone timeZone = TimeZone.getTimeZone(calendar.getTimeZone().getID());
    int offsetInMS = timeZone.getRawOffset();

    return offsetInMS >= 0
        ? "+" + DurationFormatUtils.formatDuration(offsetInMS, "HH:mm")
        : DurationFormatUtils.formatDuration(offsetInMS, "HH:mm");
  }
Exemplo n.º 2
0
  //    @Scheduled(cron="0 0 19 * * ?") // это 3 по Москве, так как время сервера в EST, таблица
  // соответствия
  // http://www.worldtimebuddy.com/?qm=1&lid=5,703448,524901&h=5&date=2014-12-28&sln=19-20
  public void update() throws IOException {
    long start = System.currentTimeMillis();

    termService.reload();
    updateCacheSearchResult();

    long end = System.currentTimeMillis();
    final String duration = DurationFormatUtils.formatDuration(end - start, "HH:mm:ss");
    eventPublisher.publishEvent(new SimplePushEvent("Кеш обновлён за " + duration));
  }
Exemplo n.º 3
0
 protected static String formatDurration(long diff) {
   if (diff < 60 * 1000L) {
     // less than 1 minute
     if (diff <= 1) return diff + " millisecond";
     else if (diff < 1000L) return diff + " milliseconds";
     else if (diff < 2000L) return ((double) diff / 1000.0) + " second";
     else return ((double) diff / 1000.0) + " seconds";
   } else {
     return org.apache.commons.lang.time.DurationFormatUtils.formatDurationWords(diff, true, true);
   }
 }
Exemplo n.º 4
0
  @Override
  protected void runOneIteration() {
    log.debug("Reaping agents");
    final List<String> agents = masterModel.listHosts();
    for (final String agent : agents) {
      try {
        final HostStatus hostStatus = masterModel.getHostStatus(agent);
        if (hostStatus == null || hostStatus.getStatus() != HostStatus.Status.DOWN) {
          // Host not found or host not DOWN -- nothing to do, move on to the next host
          continue;
        }

        final AgentInfo agentInfo = hostStatus.getAgentInfo();
        if (agentInfo == null) {
          continue;
        }

        final long downSince = agentInfo.getStartTime() + agentInfo.getUptime();
        final long downDurationMillis = clock.now().getMillis() - downSince;

        if (downDurationMillis >= timeoutMillis) {
          try {
            log.info(
                "Reaping dead agent '{}' (DOWN for {} hours)",
                agent,
                DurationFormatUtils.formatDurationHMS(downDurationMillis));
            masterModel.deregisterHost(agent);
          } catch (Exception e) {
            log.warn("Failed to reap agent '{}'", agent, e);
          }
        }
      } catch (Exception e) {
        log.warn("Failed to determine if agent '{}' should be reaped", agent, e);
      }
    }
  }
 @Override
 public String apply(@Nonnull Timestamp timestamp) {
   return DurationFormatUtils.formatDuration(timestamp.elapsedMillis, elapsedTimeFormat);
 }
Exemplo n.º 6
0
 // TotalDuration: time that took migration including retries (can be identical to Duration)
 public String getTotalDuration() {
   return DurationFormatUtils.formatDurationWords(
       new Date().getTime() - getParameters().getTotalMigrationTime().getTime(), true, true);
 }
 /**
  * @return the uptime of the server, as a human-readable string : "42 days 7 hours 3 minutes 34
  *     seconds"
  */
 public String getUptime() {
   return uptimeInMillis != null
       ? DurationFormatUtils.formatDurationWords(uptimeInMillis, true, true)
       : null;
 }