Search in sources :

Example 21 with OnmsLocationSpecificStatus

use of org.opennms.netmgt.model.OnmsLocationSpecificStatus 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 22 with OnmsLocationSpecificStatus

use of org.opennms.netmgt.model.OnmsLocationSpecificStatus in project opennms by OpenNMS.

the class DefaultLocationDataService method getApplicationDetails.

/**
     * <p>getApplicationDetails</p>
     *
     * @param app a {@link org.opennms.netmgt.model.OnmsApplication} object.
     * @return a {@link org.opennms.features.poller.remote.gwt.client.ApplicationDetails} object.
     */
@Transactional
@Override
public ApplicationDetails getApplicationDetails(final OnmsApplication app) {
    waitForGeocoding("getApplicationDetails");
    final ApplicationInfo applicationInfo = getApplicationInfo(app, StatusDetails.unknown());
    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>();
    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));
            }
        }
    }
    ApplicationDetails details = new ApplicationDetails(applicationInfo, from, to, monitors, statuses);
    LOG.warn("getApplicationDetails({}) returning {}", app.getName(), details);
    return details;
}
Also used : GWTLocationSpecificStatus(org.opennms.features.poller.remote.gwt.client.GWTLocationSpecificStatus) OnmsLocationSpecificStatus(org.opennms.netmgt.model.OnmsLocationSpecificStatus) ApplicationInfo(org.opennms.features.poller.remote.gwt.client.ApplicationInfo) ArrayList(java.util.ArrayList) GWTLocationMonitor(org.opennms.features.poller.remote.gwt.client.GWTLocationMonitor) OnmsLocationMonitor(org.opennms.netmgt.model.OnmsLocationMonitor) ApplicationDetails(org.opennms.features.poller.remote.gwt.client.ApplicationDetails) Date(java.util.Date) OnmsMonitoredService(org.opennms.netmgt.model.OnmsMonitoredService) Transactional(org.springframework.transaction.annotation.Transactional)

Example 23 with OnmsLocationSpecificStatus

use of org.opennms.netmgt.model.OnmsLocationSpecificStatus 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 24 with OnmsLocationSpecificStatus

use of org.opennms.netmgt.model.OnmsLocationSpecificStatus in project opennms by OpenNMS.

the class LocationDataManagerTest method testGetAllStatusChangesAt.

@Test
public void testGetAllStatusChangesAt() {
    Collection<OnmsLocationSpecificStatus> changes = m_locationMonitorDao.getAllStatusChangesAt(new Date());
    assertEquals(4888, changes.size());
}
Also used : OnmsLocationSpecificStatus(org.opennms.netmgt.model.OnmsLocationSpecificStatus) Date(java.util.Date) Test(org.junit.Test)

Example 25 with OnmsLocationSpecificStatus

use of org.opennms.netmgt.model.OnmsLocationSpecificStatus in project opennms by OpenNMS.

the class PollerBackEndTest method testStatusUpWhenNoneKnown.

public void testStatusUpWhenNoneKnown() {
    expect(m_locMonDao.get(LOCATION_MONITOR_ID)).andReturn(m_locationMonitor);
    expect(m_monSvcDao.get(2)).andReturn(m_dnsService);
    expect(m_locMonDao.getMostRecentStatusChange(m_locationMonitor, m_dnsService)).andReturn(null);
    // called when saving performance data
    expect(m_monitoringLocationDao.get(m_locationDefinition.getLocationName())).andReturn(m_locationDefinition);
    expect(m_pollerConfig.getPackage(m_package.getName())).andReturn(m_package);
    expect(m_pollerConfig.getServiceInPackage("DNS", m_package)).andReturn(m_dnsSvcConfig).times(3);
    expect(m_pollerConfig.parameters(m_dnsSvcConfig)).andReturn(m_dnsSvcConfig.getParameters()).times(6);
    final PollStatus newStatus = PollStatus.available(1234.0);
    OnmsLocationSpecificStatus expectedStatus = new OnmsLocationSpecificStatus(m_locationMonitor, m_dnsService, newStatus);
    m_locMonDao.saveStatusChange(isA(OnmsLocationSpecificStatus.class));
    expectLastCall().andAnswer(new StatusChecker(expectedStatus));
    m_mocks.replayAll();
    m_backEnd.saveResponseTimeData(m_locationMonitor.getId(), m_dnsService, 1234, m_package);
    m_backEnd.reportResult(LOCATION_MONITOR_ID, 2, newStatus);
}
Also used : PollStatus(org.opennms.netmgt.poller.PollStatus) OnmsLocationSpecificStatus(org.opennms.netmgt.model.OnmsLocationSpecificStatus)

Aggregations

OnmsLocationSpecificStatus (org.opennms.netmgt.model.OnmsLocationSpecificStatus)39 OnmsMonitoredService (org.opennms.netmgt.model.OnmsMonitoredService)18 Date (java.util.Date)17 OnmsLocationMonitor (org.opennms.netmgt.model.OnmsLocationMonitor)14 ArrayList (java.util.ArrayList)13 OnmsApplication (org.opennms.netmgt.model.OnmsApplication)11 OnmsMonitoringLocation (org.opennms.netmgt.model.monitoringLocations.OnmsMonitoringLocation)8 PollStatus (org.opennms.netmgt.poller.PollStatus)8 Transactional (org.springframework.transaction.annotation.Transactional)8 HashSet (java.util.HashSet)7 SimpleWebTable (org.opennms.web.svclayer.model.SimpleWebTable)6 LinkedList (java.util.LinkedList)5 GWTLocationMonitor (org.opennms.features.poller.remote.gwt.client.GWTLocationMonitor)5 LinkedHashSet (java.util.LinkedHashSet)4 Test (org.junit.Test)4 StatusDetails (org.opennms.features.poller.remote.gwt.client.StatusDetails)4 HashMap (java.util.HashMap)3 LinkedHashMap (java.util.LinkedHashMap)3 ApplicationInfo (org.opennms.features.poller.remote.gwt.client.ApplicationInfo)3 GWTLocationSpecificStatus (org.opennms.features.poller.remote.gwt.client.GWTLocationSpecificStatus)3