Search in sources :

Example 1 with NodeInfo

use of password.pwm.svc.cluster.NodeInfo in project pwm by pwm-project.

the class AppDashboardData method makeNodeData.

private static List<NodeData> makeNodeData(final PwmApplication pwmApplication, final Locale locale) {
    if (pwmApplication.getClusterService().status() != PwmService.STATUS.OPEN) {
        return Collections.emptyList();
    }
    final String notApplicable = Display.getLocalizedMessage(locale, Display.Value_NotApplicable, pwmApplication.getConfig());
    final List<NodeData> nodeData = new ArrayList<>();
    try {
        for (final NodeInfo nodeInfo : pwmApplication.getClusterService().nodes()) {
            final String uptime = nodeInfo.getStartupTime() == null ? notApplicable : TimeDuration.fromCurrent(nodeInfo.getStartupTime()).asLongString(locale);
            nodeData.add(new NodeData(nodeInfo.getInstanceID(), uptime, JavaHelper.toIsoDate(nodeInfo.getLastSeen()), nodeInfo.getNodeState(), nodeInfo.isConfigMatch()));
        }
    } catch (PwmUnrecoverableException e) {
        LOGGER.trace("error building AppDashboardData node-state: " + e.getMessage());
    }
    return Collections.unmodifiableList(nodeData);
}
Also used : NodeInfo(password.pwm.svc.cluster.NodeInfo) ArrayList(java.util.ArrayList) PwmUnrecoverableException(password.pwm.error.PwmUnrecoverableException)

Aggregations

ArrayList (java.util.ArrayList)1 PwmUnrecoverableException (password.pwm.error.PwmUnrecoverableException)1 NodeInfo (password.pwm.svc.cluster.NodeInfo)1