Search in sources :

Example 1 with LocationMonitorState

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

the class DefaultLocationDataService method getStatusDetailsForAllLocations.

@Override
public Map<String, StatusDetails> getStatusDetailsForAllLocations() {
    final Collection<OnmsMonitoringLocation> definitions = m_monitoringLocationDao.findAll();
    AllMonitorStatusTracker tracker = new AllMonitorStatusTracker();
    MonitorTracker monTracker = new MonitorTracker();
    for (OnmsLocationSpecificStatus status : m_locationDao.getAllMostRecentStatusChanges()) {
        tracker.onStatus(status);
    }
    for (OnmsLocationMonitor monitor : m_locationDao.findAll()) {
        monTracker.onMonitor(monitor);
    }
    Map<String, StatusDetails> statusDetails = new LinkedHashMap<String, StatusDetails>();
    for (final OnmsMonitoringLocation def : definitions) {
        LocationMonitorState monitorState = new LocationMonitorState(monTracker.drain(def.getLocationName()), tracker.drain(def.getLocationName()));
        final StatusDetails monitorStatus = monitorState.getStatusDetails();
        statusDetails.put(def.getLocationName(), monitorStatus);
    }
    return statusDetails;
}
Also used : OnmsLocationSpecificStatus(org.opennms.netmgt.model.OnmsLocationSpecificStatus) StatusDetails(org.opennms.features.poller.remote.gwt.client.StatusDetails) LocationMonitorState(org.opennms.features.poller.remote.gwt.client.LocationMonitorState) OnmsLocationMonitor(org.opennms.netmgt.model.OnmsLocationMonitor) OnmsMonitoringLocation(org.opennms.netmgt.model.monitoringLocations.OnmsMonitoringLocation) LinkedHashMap(java.util.LinkedHashMap)

Example 2 with LocationMonitorState

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

the class LocationDataServiceIT method testLocationMonitorState.

@Test
public void testLocationMonitorState() throws Exception {
    m_pollerBackEnd.reportResult(m_rduMonitor1.getId(), m_localhostHttpService.getId(), getAvailable(new Date(now() - days(20) - hours(3))));
    m_pollerBackEnd.reportResult(m_rduMonitor1.getId(), m_localhostHttpService.getId(), getDown(new Date(now() - days(20) - hours(2))));
    m_pollerBackEnd.reportResult(m_rduMonitor1.getId(), m_localhostHttpService.getId(), getAvailable(new Date(now() - days(20) - hours(1))));
    m_pollerBackEnd.reportResult(m_rduMonitor1.getId(), m_googleHttpService.getId(), getDown(new Date(now() - days(20) - hours(4))));
    LocationDetails ld = m_locationDataService.getLocationDetails("RDU");
    LocationMonitorState lms = ld.getLocationMonitorState();
    assertEquals(Status.DOWN, lms.getStatusDetails().getStatus());
    assertEquals(2, lms.getServices().size());
    assertEquals(1, lms.getServicesDown().size());
    assertEquals(1, lms.getMonitorsWithServicesDown().size());
    assertEquals(2, lms.getMonitorsStarted());
    assertEquals(0, lms.getMonitorsStopped());
    assertEquals(0, lms.getMonitorsDisconnected());
}
Also used : LocationDetails(org.opennms.features.poller.remote.gwt.client.location.LocationDetails) LocationMonitorState(org.opennms.features.poller.remote.gwt.client.LocationMonitorState) Date(java.util.Date) Test(org.junit.Test)

Example 3 with LocationMonitorState

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

the class DefaultLocationDataService method getStatusDetailsForLocation.

/**
 * {@inheritDoc}
 */
@Transactional
@Override
public StatusDetails getStatusDetailsForLocation(final OnmsMonitoringLocation def) {
    waitForGeocoding("getStatusDetails");
    final DefaultLocationDataService.MonitorStatusTracker mst = new DefaultLocationDataService.MonitorStatusTracker(def.getLocationName());
    final List<GWTLocationMonitor> monitors = new ArrayList<GWTLocationMonitor>();
    for (OnmsLocationMonitor mon : m_locationDao.findByLocationDefinition(def)) {
        monitors.add(transformLocationMonitor(mon));
    }
    for (OnmsLocationSpecificStatus status : m_locationDao.getMostRecentStatusChangesForLocation(def.getLocationName())) {
        mst.onStatus(status);
    }
    LocationMonitorState monitorState = new LocationMonitorState(monitors, mst.drain());
    StatusDetails statusDetails = monitorState.getStatusDetails();
    LOG.debug("getStatusDetails({}) returning {}", def.getLocationName(), statusDetails);
    return statusDetails;
}
Also used : OnmsLocationSpecificStatus(org.opennms.netmgt.model.OnmsLocationSpecificStatus) ArrayList(java.util.ArrayList) StatusDetails(org.opennms.features.poller.remote.gwt.client.StatusDetails) LocationMonitorState(org.opennms.features.poller.remote.gwt.client.LocationMonitorState) GWTLocationMonitor(org.opennms.features.poller.remote.gwt.client.GWTLocationMonitor) OnmsLocationMonitor(org.opennms.netmgt.model.OnmsLocationMonitor) Transactional(org.springframework.transaction.annotation.Transactional)

Example 4 with LocationMonitorState

use of org.opennms.features.poller.remote.gwt.client.LocationMonitorState 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)

Aggregations

LocationMonitorState (org.opennms.features.poller.remote.gwt.client.LocationMonitorState)4 OnmsLocationMonitor (org.opennms.netmgt.model.OnmsLocationMonitor)3 OnmsLocationSpecificStatus (org.opennms.netmgt.model.OnmsLocationSpecificStatus)3 ArrayList (java.util.ArrayList)2 Date (java.util.Date)2 GWTLocationMonitor (org.opennms.features.poller.remote.gwt.client.GWTLocationMonitor)2 StatusDetails (org.opennms.features.poller.remote.gwt.client.StatusDetails)2 LocationDetails (org.opennms.features.poller.remote.gwt.client.location.LocationDetails)2 Transactional (org.springframework.transaction.annotation.Transactional)2 HashSet (java.util.HashSet)1 LinkedHashMap (java.util.LinkedHashMap)1 LinkedHashSet (java.util.LinkedHashSet)1 Test (org.junit.Test)1 ApplicationInfo (org.opennms.features.poller.remote.gwt.client.ApplicationInfo)1 ApplicationState (org.opennms.features.poller.remote.gwt.client.ApplicationState)1 OnmsApplication (org.opennms.netmgt.model.OnmsApplication)1 OnmsMonitoringLocation (org.opennms.netmgt.model.monitoringLocations.OnmsMonitoringLocation)1