Search in sources :

Example 6 with ApplicationInfo

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

the class LocationDataServiceIT method testApplicationInfo.

@Test
public void testApplicationInfo() throws Exception {
    m_pollerBackEnd.reportResult(m_rduMonitor1.getId(), m_localhostHttpService.getId(), getAvailable(new Date(now() - hours(3))));
    m_pollerBackEnd.reportResult(m_rduMonitor1.getId(), m_localhostHttpService.getId(), getDown(new Date(now() - hours(2))));
    m_pollerBackEnd.reportResult(m_rduMonitor1.getId(), m_localhostHttpService.getId(), getAvailable(new Date(now() - hours(1))));
    m_pollerBackEnd.reportResult(m_rduMonitor1.getId(), m_googleHttpService.getId(), getDown(new Date(now() - hours(4))));
    ApplicationInfo ai = m_locationDataService.getApplicationInfo("TestApp1");
    assertEquals("TestApp1", ai.getName());
    assertEquals(Status.DOWN, ai.getStatusDetails().getStatus());
}
Also used : ApplicationInfo(org.opennms.features.poller.remote.gwt.client.ApplicationInfo) Date(java.util.Date) Test(org.junit.Test)

Example 7 with ApplicationInfo

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

the class DefaultLocationDataService method getApplicationInfo.

/**
     * <p>getApplicationInfo</p>
     *
     * @param app a {@link org.opennms.netmgt.model.OnmsApplication} object.
     * @return a {@link org.opennms.features.poller.remote.gwt.client.ApplicationInfo} object.
     */
@Transactional
@Override
public ApplicationInfo getApplicationInfo(final OnmsApplication app) {
    waitForGeocoding("getApplicationInfo");
    ApplicationInfo info = null;
    if (app == null) {
        LOG.warn("no application specified");
    } else {
        info = getApplicationInfo(app, getStatusDetailsForApplication(app));
    }
    return info;
}
Also used : ApplicationInfo(org.opennms.features.poller.remote.gwt.client.ApplicationInfo) Transactional(org.springframework.transaction.annotation.Transactional)

Example 8 with ApplicationInfo

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

the class DefaultLocationDataService method getLocationDetails.

/**
     * <p>getLocationDetails</p>
     *
     * @param def a {@link org.opennms.netmgt.model.OnmsMonitoringLocationDefinition} object.
     * @return a {@link org.opennms.features.poller.remote.gwt.client.location.LocationDetails} object.
     */
@Transactional
@Override
public LocationDetails getLocationDetails(final OnmsMonitoringLocation def) {
    waitForGeocoding("getLocationDetails");
    final LocationDetails ld = new LocationDetails();
    final DefaultLocationDataService.MonitorStatusTracker mst = new DefaultLocationDataService.MonitorStatusTracker(def.getLocationName());
    final DefaultLocationDataService.ApplicationStatusTracker ast = new DefaultLocationDataService.ApplicationStatusTracker(def.getLocationName());
    final List<GWTLocationMonitor> monitors = new ArrayList<GWTLocationMonitor>();
    for (OnmsLocationMonitor mon : m_locationDao.findByLocationDefinition(def)) {
        monitors.add(transformLocationMonitor(mon));
    }
    final Set<ApplicationInfo> applications = new HashSet<ApplicationInfo>();
    for (final OnmsApplication application : m_applicationDao.findAll()) {
        applications.add(transformApplication(m_monitoredServiceDao.findByApplication(application), application));
    }
    //        for (final OnmsMonitoredService service : m_monitoredServiceDao.findAll()) {
    //            for (final OnmsApplication app : service.getApplications()) {
    //                final String appName = app.getName();
    //                Set<OnmsMonitoredService> serv = services.get(appName);
    //                if (serv == null) {
    //                    serv = new HashSet<OnmsMonitoredService>();
    //                    services.put(appName, serv);
    //                }
    //                serv.add(service);
    //            }
    //        }
    final Date to = new Date();
    final Date from = new Date(to.getTime() - AVAILABILITY_MS);
    for (OnmsLocationSpecificStatus status : m_locationDao.getMostRecentStatusChangesForLocation(def.getLocationName())) {
        mst.onStatus(status);
        ast.onStatus(status);
    }
    ld.setLocationMonitorState(new LocationMonitorState(monitors, mst.drain()));
    ld.setApplicationState(new ApplicationState(from, to, applications, monitors, ast.drainStatuses()));
    LOG.debug("getLocationDetails({}) returning {}", def.getLocationName(), ld);
    return ld;
}
Also used : LocationDetails(org.opennms.features.poller.remote.gwt.client.location.LocationDetails) OnmsLocationSpecificStatus(org.opennms.netmgt.model.OnmsLocationSpecificStatus) ApplicationState(org.opennms.features.poller.remote.gwt.client.ApplicationState) ArrayList(java.util.ArrayList) ApplicationInfo(org.opennms.features.poller.remote.gwt.client.ApplicationInfo) LocationMonitorState(org.opennms.features.poller.remote.gwt.client.LocationMonitorState) GWTLocationMonitor(org.opennms.features.poller.remote.gwt.client.GWTLocationMonitor) OnmsApplication(org.opennms.netmgt.model.OnmsApplication) Date(java.util.Date) OnmsLocationMonitor(org.opennms.netmgt.model.OnmsLocationMonitor) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet) Transactional(org.springframework.transaction.annotation.Transactional)

Example 9 with ApplicationInfo

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

the class DefaultLocationDataService method getInfoForAllApplications.

/**
     * <p>getInfoForAllApplications</p>
     *
     * @return a {@link java.util.List} object.
     */
@Transactional
@Override
public List<ApplicationInfo> getInfoForAllApplications() {
    waitForGeocoding("handleAllApplications");
    Map<OnmsApplication, StatusDetails> statusDetails = getStatusDetailsForAllApplications();
    final List<ApplicationInfo> appInfos = new ArrayList<ApplicationInfo>();
    for (Map.Entry<OnmsApplication, StatusDetails> entry : statusDetails.entrySet()) {
        final ApplicationInfo appInfo = getApplicationInfo(entry.getKey(), entry.getValue());
        appInfos.add(appInfo);
    }
    return appInfos;
}
Also used : StatusDetails(org.opennms.features.poller.remote.gwt.client.StatusDetails) ArrayList(java.util.ArrayList) ApplicationInfo(org.opennms.features.poller.remote.gwt.client.ApplicationInfo) OnmsApplication(org.opennms.netmgt.model.OnmsApplication) Map(java.util.Map) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Transactional(org.springframework.transaction.annotation.Transactional)

Example 10 with ApplicationInfo

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

the class DefaultLocationDataService method getApplicationsForLocation.

/** {@inheritDoc} */
@Transactional
@Override
public Collection<ApplicationInfo> getApplicationsForLocation(final LocationInfo locationInfo) {
    waitForGeocoding("getApplicationsForLocation");
    final Map<String, ApplicationInfo> apps = new HashMap<String, ApplicationInfo>();
    for (final OnmsLocationSpecificStatus status : m_locationDao.getMostRecentStatusChangesForLocation(locationInfo.getName())) {
        for (final OnmsApplication app : status.getMonitoredService().getApplications()) {
            if (!apps.containsKey(app.getName())) {
                apps.put(app.getName(), getApplicationInfo(app));
            }
        }
    }
    return apps.values();
}
Also used : HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) OnmsLocationSpecificStatus(org.opennms.netmgt.model.OnmsLocationSpecificStatus) ApplicationInfo(org.opennms.features.poller.remote.gwt.client.ApplicationInfo) OnmsApplication(org.opennms.netmgt.model.OnmsApplication) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

ApplicationInfo (org.opennms.features.poller.remote.gwt.client.ApplicationInfo)11 Transactional (org.springframework.transaction.annotation.Transactional)6 OnmsApplication (org.opennms.netmgt.model.OnmsApplication)4 ArrayList (java.util.ArrayList)3 Date (java.util.Date)3 ApplicationUpdatedRemoteEvent (org.opennms.features.poller.remote.gwt.client.remoteevents.ApplicationUpdatedRemoteEvent)3 OnmsLocationMonitor (org.opennms.netmgt.model.OnmsLocationMonitor)3 OnmsLocationSpecificStatus (org.opennms.netmgt.model.OnmsLocationSpecificStatus)3 OnmsMonitoredService (org.opennms.netmgt.model.OnmsMonitoredService)3 HashMap (java.util.HashMap)2 LinkedHashMap (java.util.LinkedHashMap)2 TreeSet (java.util.TreeSet)2 GWTLocationMonitor (org.opennms.features.poller.remote.gwt.client.GWTLocationMonitor)2 GWTMonitoredService (org.opennms.features.poller.remote.gwt.client.GWTMonitoredService)2 HashSet (java.util.HashSet)1 LinkedHashSet (java.util.LinkedHashSet)1 Map (java.util.Map)1 Test (org.junit.Test)1 ApplicationDetails (org.opennms.features.poller.remote.gwt.client.ApplicationDetails)1 ApplicationState (org.opennms.features.poller.remote.gwt.client.ApplicationState)1