Search in sources :

Example 1 with GWTMonitoredService

use of org.opennms.features.poller.remote.gwt.client.GWTMonitoredService in project opennms by OpenNMS.

the class DefaultLocationDataService method getApplicationInfo.

/**
 * {@inheritDoc}
 */
@Transactional
@Override
public ApplicationInfo getApplicationInfo(final OnmsApplication app, final StatusDetails status) {
    waitForGeocoding("getApplicationInfo");
    if (app == null) {
        LOG.warn("no application specified");
        return null;
    }
    final Set<GWTMonitoredService> services = new TreeSet<GWTMonitoredService>();
    final Set<String> locationNames = new TreeSet<String>();
    for (final OnmsMonitoredService service : m_monitoredServiceDao.findByApplication(app)) {
        services.add(transformMonitoredService(service));
    }
    for (final OnmsLocationMonitor mon : m_locationDao.findByApplication(app)) {
        locationNames.add(mon.getLocation());
    }
    final ApplicationInfo applicationInfo = new ApplicationInfo(app.getId(), app.getName(), services, locationNames, status);
    LOG.debug("getApplicationInfo({}) returning {}", app.getName(), applicationInfo);
    return applicationInfo;
}
Also used : TreeSet(java.util.TreeSet) ApplicationInfo(org.opennms.features.poller.remote.gwt.client.ApplicationInfo) GWTMonitoredService(org.opennms.features.poller.remote.gwt.client.GWTMonitoredService) OnmsLocationMonitor(org.opennms.netmgt.model.OnmsLocationMonitor) OnmsMonitoredService(org.opennms.netmgt.model.OnmsMonitoredService) Transactional(org.springframework.transaction.annotation.Transactional)

Example 2 with GWTMonitoredService

use of org.opennms.features.poller.remote.gwt.client.GWTMonitoredService in project opennms by OpenNMS.

the class DefaultLocationDataService method getStatusDetailsForApplication.

/**
 * {@inheritDoc}
 */
@Transactional
@Override
public StatusDetails getStatusDetailsForApplication(final OnmsApplication app) {
    waitForGeocoding("getStatusDetailsForApplication");
    List<GWTLocationSpecificStatus> statuses = new ArrayList<GWTLocationSpecificStatus>();
    final Date to = new Date();
    final Date from = new Date(to.getTime() - AVAILABILITY_MS);
    final Collection<OnmsMonitoredService> services = m_monitoredServiceDao.findByApplication(app);
    final Set<GWTLocationMonitor> monitors = new LinkedHashSet<GWTLocationMonitor>();
    final Set<GWTMonitoredService> gwtServices = new LinkedHashSet<GWTMonitoredService>(services.size());
    for (final OnmsMonitoredService service : services) {
        gwtServices.add(transformMonitoredService(service));
    }
    for (OnmsLocationSpecificStatus status : m_locationDao.getStatusChangesForApplicationBetween(to, from, app.getName())) {
        monitors.add(transformLocationMonitor(status.getLocationMonitor()));
        statuses.add(transformLocationSpecificStatus(status));
    }
    StatusDetails statusDetails = new AppStatusDetailsComputer(from, to, monitors, gwtServices, statuses).compute();
    LOG.warn("getStatusDetailsForApplication({}) returning {}", app.getName(), statusDetails);
    return statusDetails;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) OnmsLocationSpecificStatus(org.opennms.netmgt.model.OnmsLocationSpecificStatus) ArrayList(java.util.ArrayList) GWTLocationMonitor(org.opennms.features.poller.remote.gwt.client.GWTLocationMonitor) GWTMonitoredService(org.opennms.features.poller.remote.gwt.client.GWTMonitoredService) Date(java.util.Date) OnmsMonitoredService(org.opennms.netmgt.model.OnmsMonitoredService) AppStatusDetailsComputer(org.opennms.features.poller.remote.gwt.client.AppStatusDetailsComputer) GWTLocationSpecificStatus(org.opennms.features.poller.remote.gwt.client.GWTLocationSpecificStatus) StatusDetails(org.opennms.features.poller.remote.gwt.client.StatusDetails) Transactional(org.springframework.transaction.annotation.Transactional)

Example 3 with GWTMonitoredService

use of org.opennms.features.poller.remote.gwt.client.GWTMonitoredService in project opennms by OpenNMS.

the class DefaultLocationDataService method transformApplication.

private static ApplicationInfo transformApplication(final Collection<OnmsMonitoredService> services, final OnmsApplication application) {
    final ApplicationInfo app = new ApplicationInfo();
    app.setId(application.getId());
    app.setName(application.getName());
    final Set<GWTMonitoredService> s = new TreeSet<GWTMonitoredService>();
    final Set<String> locations = new TreeSet<String>();
    for (final OnmsMonitoredService service : services) {
        for (final OnmsApplication oa : service.getApplications()) {
            locations.add(oa.getName());
        }
        s.add(transformMonitoredService(service));
    }
    app.setServices(s);
    app.setLocations(locations);
    return app;
}
Also used : TreeSet(java.util.TreeSet) ApplicationInfo(org.opennms.features.poller.remote.gwt.client.ApplicationInfo) OnmsApplication(org.opennms.netmgt.model.OnmsApplication) GWTMonitoredService(org.opennms.features.poller.remote.gwt.client.GWTMonitoredService) OnmsMonitoredService(org.opennms.netmgt.model.OnmsMonitoredService)

Example 4 with GWTMonitoredService

use of org.opennms.features.poller.remote.gwt.client.GWTMonitoredService in project opennms by OpenNMS.

the class DefaultLocationDataService method transformMonitoredService.

private static GWTMonitoredService transformMonitoredService(final OnmsMonitoredService monitoredService) {
    final GWTMonitoredService service = new GWTMonitoredService();
    service.setId(monitoredService.getId());
    final OnmsIpInterface ipi = monitoredService.getIpInterface();
    if (ipi != null) {
        service.setIpInterfaceId(ipi.getId());
        if (ipi.getNode() != null) {
            service.setNodeId(ipi.getNode().getId());
        }
        service.setIpAddress(str(ipi.getIpAddress()));
        service.setHostname(ipi.getIpHostName());
        final OnmsSnmpInterface snmpi = ipi.getSnmpInterface();
        if (snmpi != null) {
            service.setIfIndex(snmpi.getIfIndex());
        }
    }
    service.setServiceName(monitoredService.getServiceName());
    return service;
}
Also used : OnmsIpInterface(org.opennms.netmgt.model.OnmsIpInterface) OnmsSnmpInterface(org.opennms.netmgt.model.OnmsSnmpInterface) GWTMonitoredService(org.opennms.features.poller.remote.gwt.client.GWTMonitoredService)

Example 5 with GWTMonitoredService

use of org.opennms.features.poller.remote.gwt.client.GWTMonitoredService in project opennms by OpenNMS.

the class DefaultLocationDataService method getStatusDetailsForApplicationOld.

/**
 * <p>getStatusDetailsForApplicationOld</p>
 *
 * @param app a {@link org.opennms.netmgt.model.OnmsApplication} object.
 * @return a {@link org.opennms.features.poller.remote.gwt.client.StatusDetails} object.
 */
@Transactional
public StatusDetails getStatusDetailsForApplicationOld(final OnmsApplication app) {
    waitForGeocoding("getStatusDetailsForApplication");
    List<GWTLocationSpecificStatus> statuses = new ArrayList<GWTLocationSpecificStatus>();
    final Date to = new Date();
    final Date from = new Date(to.getTime() - AVAILABILITY_MS);
    final Collection<OnmsMonitoredService> services = m_monitoredServiceDao.findByApplication(app);
    final List<GWTLocationMonitor> monitors = new ArrayList<GWTLocationMonitor>();
    final Set<GWTMonitoredService> gwtServices = new LinkedHashSet<GWTMonitoredService>(services.size());
    for (final OnmsMonitoredService service : services) {
        gwtServices.add(transformMonitoredService(service));
    }
    for (final OnmsLocationMonitor monitor : m_locationDao.findByApplication(app)) {
        monitors.add(transformLocationMonitor(monitor));
        for (final OnmsLocationSpecificStatus locationSpecificStatus : m_locationDao.getStatusChangesForLocationBetween(from, to, monitor.getLocation())) {
            if (services.contains(locationSpecificStatus.getMonitoredService())) {
                statuses.add(transformLocationSpecificStatus(locationSpecificStatus));
            }
        }
    }
    StatusDetails statusDetails = new AppStatusDetailsComputer(from, to, monitors, gwtServices, statuses).compute();
    LOG.warn("getStatusDetailsForApplication({}) returning {}", app.getName(), statusDetails);
    return statusDetails;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) OnmsLocationSpecificStatus(org.opennms.netmgt.model.OnmsLocationSpecificStatus) ArrayList(java.util.ArrayList) GWTLocationMonitor(org.opennms.features.poller.remote.gwt.client.GWTLocationMonitor) GWTMonitoredService(org.opennms.features.poller.remote.gwt.client.GWTMonitoredService) Date(java.util.Date) OnmsMonitoredService(org.opennms.netmgt.model.OnmsMonitoredService) AppStatusDetailsComputer(org.opennms.features.poller.remote.gwt.client.AppStatusDetailsComputer) GWTLocationSpecificStatus(org.opennms.features.poller.remote.gwt.client.GWTLocationSpecificStatus) StatusDetails(org.opennms.features.poller.remote.gwt.client.StatusDetails) OnmsLocationMonitor(org.opennms.netmgt.model.OnmsLocationMonitor) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

GWTMonitoredService (org.opennms.features.poller.remote.gwt.client.GWTMonitoredService)5 OnmsMonitoredService (org.opennms.netmgt.model.OnmsMonitoredService)4 Transactional (org.springframework.transaction.annotation.Transactional)3 ArrayList (java.util.ArrayList)2 Date (java.util.Date)2 LinkedHashSet (java.util.LinkedHashSet)2 TreeSet (java.util.TreeSet)2 AppStatusDetailsComputer (org.opennms.features.poller.remote.gwt.client.AppStatusDetailsComputer)2 ApplicationInfo (org.opennms.features.poller.remote.gwt.client.ApplicationInfo)2 GWTLocationMonitor (org.opennms.features.poller.remote.gwt.client.GWTLocationMonitor)2 GWTLocationSpecificStatus (org.opennms.features.poller.remote.gwt.client.GWTLocationSpecificStatus)2 StatusDetails (org.opennms.features.poller.remote.gwt.client.StatusDetails)2 OnmsLocationMonitor (org.opennms.netmgt.model.OnmsLocationMonitor)2 OnmsLocationSpecificStatus (org.opennms.netmgt.model.OnmsLocationSpecificStatus)2 OnmsApplication (org.opennms.netmgt.model.OnmsApplication)1 OnmsIpInterface (org.opennms.netmgt.model.OnmsIpInterface)1 OnmsSnmpInterface (org.opennms.netmgt.model.OnmsSnmpInterface)1