Search in sources :

Example 1 with MonitorStatus

use of org.opennms.netmgt.model.OnmsLocationMonitor.MonitorStatus in project opennms by OpenNMS.

the class ServerUnreachableAdaptor method pollerCheckingIn.

/** {@inheritDoc} */
@Override
public MonitorStatus pollerCheckingIn(final String locationMonitorId, final Date currentConfigurationVersion) {
    // if we check in and get a remote exception then we switch to the EmptyConfiguration
    try {
        final MonitorStatus result = m_remoteBackEnd.pollerCheckingIn(locationMonitorId, currentConfigurationVersion);
        m_serverUnresponsive = false;
        return result;
    } catch (final RemoteAccessException e) {
        // we have failed to check in properly with the server
        m_serverUnresponsive = true;
        LOG.warn("Server is unable to respond due to the following exception.", e);
        return MonitorStatus.DISCONNECTED;
    }
}
Also used : RemoteAccessException(org.springframework.remoting.RemoteAccessException) MonitorStatus(org.opennms.netmgt.model.OnmsLocationMonitor.MonitorStatus)

Example 2 with MonitorStatus

use of org.opennms.netmgt.model.OnmsLocationMonitor.MonitorStatus in project opennms by OpenNMS.

the class DefaultLocationDataService method getUpdatedLocationsBetween.

/** {@inheritDoc} */
@Transactional
@Override
public Collection<LocationInfo> getUpdatedLocationsBetween(final Date startDate, final Date endDate) {
    waitForGeocoding("getApplicationDetails");
    final Collection<LocationInfo> locations = new ArrayList<LocationInfo>();
    final Map<String, OnmsMonitoringLocation> definitions = new HashMap<String, OnmsMonitoringLocation>();
    // check for any monitors that have changed status
    for (OnmsMonitoringLocation def : m_monitoringLocationDao.findAll()) {
        for (OnmsLocationMonitor mon : m_locationDao.findByLocationDefinition(def)) {
            final MonitorStatus status = m_monitorStatuses.get(mon.getLocation());
            if (status == null || !status.equals(mon.getStatus())) {
                definitions.put(def.getLocationName(), def);
                m_monitorStatuses.put(def.getLocationName(), mon.getStatus());
            }
        }
    }
    // check for any definitions that have status updates
    for (final OnmsLocationSpecificStatus status : m_locationDao.getStatusChangesBetween(startDate, endDate)) {
        final String definitionName = status.getLocationMonitor().getLocation();
        if (!definitions.containsKey(definitionName)) {
            definitions.put(definitionName, m_monitoringLocationDao.get(definitionName));
        }
    }
    for (final OnmsMonitoringLocation def : definitions.values()) {
        final LocationInfo location = getLocationInfo(def);
        locations.add(location);
    }
    return locations;
}
Also used : HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) OnmsLocationSpecificStatus(org.opennms.netmgt.model.OnmsLocationSpecificStatus) ArrayList(java.util.ArrayList) OnmsLocationMonitor(org.opennms.netmgt.model.OnmsLocationMonitor) MonitorStatus(org.opennms.netmgt.model.OnmsLocationMonitor.MonitorStatus) LocationInfo(org.opennms.features.poller.remote.gwt.client.location.LocationInfo) OnmsMonitoringLocation(org.opennms.netmgt.model.monitoringLocations.OnmsMonitoringLocation) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

MonitorStatus (org.opennms.netmgt.model.OnmsLocationMonitor.MonitorStatus)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 LocationInfo (org.opennms.features.poller.remote.gwt.client.location.LocationInfo)1 OnmsLocationMonitor (org.opennms.netmgt.model.OnmsLocationMonitor)1 OnmsLocationSpecificStatus (org.opennms.netmgt.model.OnmsLocationSpecificStatus)1 OnmsMonitoringLocation (org.opennms.netmgt.model.monitoringLocations.OnmsMonitoringLocation)1 RemoteAccessException (org.springframework.remoting.RemoteAccessException)1 Transactional (org.springframework.transaction.annotation.Transactional)1