Search in sources :

Example 1 with Duration

use of com.sun.enterprise.universal.Duration in project Payara by payara.

the class DomainRootImpl method getUptimeMillis.

public Object[] getUptimeMillis() {
    final ServerEnvironmentImpl env = InjectedValues.getInstance().getServerEnvironment();
    final long elapsed = System.currentTimeMillis() - env.getStartupContext().getCreationTime();
    final Duration duration = new Duration(elapsed);
    return new Object[] { elapsed, duration.toString() };
}
Also used : ServerEnvironmentImpl(org.glassfish.server.ServerEnvironmentImpl) Duration(com.sun.enterprise.universal.Duration)

Example 2 with Duration

use of com.sun.enterprise.universal.Duration in project Payara by payara.

the class UptimeCommand method execute.

public void execute(AdminCommandContext context) {
    final ActionReport report = context.getActionReport();
    long totalTime_ms = getUptime();
    String totalTime_mss = "" + totalTime_ms;
    Duration duration = new Duration(totalTime_ms);
    duration.setTerse();
    report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
    String message;
    if (milliseconds)
        message = totalTime_mss;
    else
        message = localStrings.getLocalString("uptime.output.terse", "Uptime: {0}", duration);
    report.setMessage(message);
    report.getTopMessagePart().addProperty("milliseconds", totalTime_mss);
}
Also used : Duration(com.sun.enterprise.universal.Duration) ActionReport(org.glassfish.api.ActionReport)

Aggregations

Duration (com.sun.enterprise.universal.Duration)2 ActionReport (org.glassfish.api.ActionReport)1 ServerEnvironmentImpl (org.glassfish.server.ServerEnvironmentImpl)1