All Downloads are FREE. Search and download functionalities are using the official Maven repository.

de.otto.edison.status.indicator.CachedApplicationStatusAggregator Maven / Gradle / Ivy

There is a newer version: 0.82.2
Show newest version
package de.otto.edison.status.indicator;

import de.otto.edison.status.domain.*;

import javax.annotation.PostConstruct;
import java.util.List;

import static de.otto.edison.status.domain.ApplicationStatus.applicationStatus;
import static java.util.stream.Collectors.toList;

/**
 * A caching ApplicationStatusAggregator.
 *
 * @author Guido Steinacker
 * @since 13.02.15
 */
public class CachedApplicationStatusAggregator implements ApplicationStatusAggregator {

    private volatile ApplicationStatus cachedStatus;

    private final ApplicationInfo applicationInfo;
    private final SystemInfo systemInfo;
    private final VersionInfo versionInfo;
    private final TeamInfo teamInfo;
    private final List indicators;
    private final List serviceSpecs;

    public CachedApplicationStatusAggregator(final ApplicationInfo applicationInfo,
                                             final SystemInfo systemInfo,
                                             final VersionInfo versionInfo,
                                             final TeamInfo teamInfo,
                                             final List indicators,
                                             final List serviceSpecs) {
        this.applicationInfo = applicationInfo;
        this.systemInfo = systemInfo;
        this.versionInfo = versionInfo;
        this.teamInfo = teamInfo;
        this.indicators = indicators;
        this.serviceSpecs = serviceSpecs;
    }

    @PostConstruct
    public void postConstruct() {
        update();
    }

    @Override
    public ApplicationStatus aggregatedStatus() {
        return cachedStatus;
    }

    @Override
    public void update() {
        this.cachedStatus = applicationStatus(applicationInfo, systemInfo, versionInfo, teamInfo, getStatusDetails(indicators), serviceSpecs);
    }

    private static List getStatusDetails(final List indicators) {
        return indicators
                    .stream()
                    .flatMap(i->i.statusDetails().stream())
                    .collect(toList());
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy