예제 #1
0
  /**
   * Pretty-formatting for duration.
   *
   * @param ms Millisecond to format.
   * @return Formatted presentation.
   */
  private static String formatDuration(long ms) {
    assert ms >= 0;

    if (ms == 0) return "< 1 ms";

    SB sb = new SB();

    long dd = ms / 1440000; // 1440 mins = 60 mins * 24 hours

    if (dd > 0) sb.a(dd).a(dd == 1 ? " day " : " days ");

    ms %= 1440000;

    long hh = ms / 60000;

    if (hh > 0) sb.a(hh).a(hh == 1 ? " hour " : " hours ");

    long min = ms / 60000;

    if (min > 0) sb.a(min).a(min == 1 ? " min " : " mins ");

    ms %= 60000;

    if (ms > 0) sb.a(ms).a(" ms ");

    return sb.toString().trim();
  }
  /**
   * Builds ignite.sh attributes to set up SSH username and password and log directory for started
   * node.
   *
   * @param username SSH user name.
   * @param host Host.
   * @return {@code ignite.sh} script arguments.
   */
  private String buildRemoteLogArguments(String username, String host) {
    assert username != null;
    assert host != null;

    SB sb = new SB();

    sb.a(" -J-D")
        .a(IGNITE_SSH_HOST)
        .a("=\"")
        .a(host)
        .a("\"")
        .a(" -J-D")
        .a(IGNITE_SSH_USER_NAME)
        .a("=\"")
        .a(username)
        .a("\"");

    return sb.toString();
  }