Search in sources :

Example 11 with LocationInfo

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

Example 12 with LocationInfo

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

the class DefaultLocationDataService method getInfoForAllLocations.

/**
 * <p>getInfoForAllLocations</p>
 *
 * @return a {@link java.util.List} object.
 */
@Transactional
@Override
public List<LocationInfo> getInfoForAllLocations() {
    waitForGeocoding("getInfoForAllLocations");
    Map<String, StatusDetails> statusDetails = getStatusDetailsForAllLocations();
    List<LocationInfo> locations = new ArrayList<LocationInfo>();
    for (Map.Entry<String, StatusDetails> entry : statusDetails.entrySet()) {
        OnmsMonitoringLocation def = m_monitoringLocationDao.get(entry.getKey());
        LocationInfo locationInfo = this.getLocationInfo(def, entry.getValue());
        locations.add(locationInfo);
    }
    return locations;
}
Also used : StatusDetails(org.opennms.features.poller.remote.gwt.client.StatusDetails) ArrayList(java.util.ArrayList) Map(java.util.Map) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) LocationInfo(org.opennms.features.poller.remote.gwt.client.location.LocationInfo) OnmsMonitoringLocation(org.opennms.netmgt.model.monitoringLocations.OnmsMonitoringLocation) Transactional(org.springframework.transaction.annotation.Transactional)

Example 13 with LocationInfo

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

the class DefaultLocationDataService method getLocationInfo.

private LocationInfo getLocationInfo(final OnmsMonitoringLocation def, final StatusDetails monitorStatus) {
    GWTLatLng latLng = getLatLng(def, false);
    if (latLng == null) {
        LOG.debug("no geolocation or coordinates found, using OpenNMS World HQ");
        latLng = new GWTLatLng(35.715751, -79.16262);
    }
    final GWTMarkerState state = new GWTMarkerState(def.getLocationName(), latLng, Status.UNKNOWN);
    Set<String> tags = new TreeSet<String>();
    if (def.getTags() != null) {
        for (String tag : def.getTags()) {
            tags.add(tag);
        }
    }
    final LocationInfo locationInfo = new LocationInfo(def.getLocationName(), def.getMonitoringArea(), def.getGeolocation(), latLng.getCoordinates(), def.getPriority(), state, null, tags);
    state.setStatus(monitorStatus.getStatus());
    locationInfo.setStatusDetails(monitorStatus);
    // LOG.debug("getLocationInfo({}) returning {}", def.getLocationName(), locationInfo);
    return locationInfo;
}
Also used : GWTLatLng(org.opennms.features.poller.remote.gwt.client.GWTLatLng) TreeSet(java.util.TreeSet) GWTMarkerState(org.opennms.features.poller.remote.gwt.client.GWTMarkerState) LocationInfo(org.opennms.features.poller.remote.gwt.client.location.LocationInfo)

Example 14 with LocationInfo

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

the class LocationAddedToMapTest method testStatusMessage.

@Test
public void testStatusMessage() {
    int numLocations = 10;
    Set<LocationInfo> locations = new HashSet<>();
    createLocations(numLocations, locations);
    m_testServer.sendDomainEvent(new LocationsUpdatedRemoteEvent(locations));
    int updated = 0;
    while (!m_testExecutor.runOnePass()) {
        updated++;
        assertEquals("Updated " + updated + " of 10", m_testApplicationView.getStatusMessage());
    }
}
Also used : LocationsUpdatedRemoteEvent(org.opennms.features.poller.remote.gwt.client.remoteevents.LocationsUpdatedRemoteEvent) LocationInfo(org.opennms.features.poller.remote.gwt.client.location.LocationInfo) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 15 with LocationInfo

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

the class LocationAddedToMapTest method createApps.

private Set<ApplicationInfo> createApps(int numApps, Set<LocationInfo> locations) {
    Set<String> locNames = new HashSet<>();
    for (LocationInfo location : locations) {
        locNames.add(location.getName());
    }
    Set<ApplicationInfo> apps = new HashSet<>();
    for (int i = 1; i <= numApps; i++) {
        apps.add(new ApplicationInfo(i, "app" + i, Collections.<GWTMonitoredService>emptySet(), locNames, new StatusDetails(Status.UP, "All things good here")));
    }
    return apps;
}
Also used : HashSet(java.util.HashSet) LocationInfo(org.opennms.features.poller.remote.gwt.client.location.LocationInfo)

Aggregations

LocationInfo (org.opennms.features.poller.remote.gwt.client.location.LocationInfo)18 Test (org.junit.Test)5 LocationUpdatedRemoteEvent (org.opennms.features.poller.remote.gwt.client.remoteevents.LocationUpdatedRemoteEvent)5 ArrayList (java.util.ArrayList)4 ApplicationUpdatedRemoteEvent (org.opennms.features.poller.remote.gwt.client.remoteevents.ApplicationUpdatedRemoteEvent)4 HashSet (java.util.HashSet)3 LocationsUpdatedRemoteEvent (org.opennms.features.poller.remote.gwt.client.remoteevents.LocationsUpdatedRemoteEvent)3 HashMap (java.util.HashMap)2 LinkedHashMap (java.util.LinkedHashMap)2 ApplicationInfo (org.opennms.features.poller.remote.gwt.client.ApplicationInfo)2 UpdateCompleteRemoteEvent (org.opennms.features.poller.remote.gwt.client.remoteevents.UpdateCompleteRemoteEvent)2 OnmsMonitoringLocation (org.opennms.netmgt.model.monitoringLocations.OnmsMonitoringLocation)2 Transactional (org.springframework.transaction.annotation.Transactional)2 Cell (com.google.gwt.user.client.ui.HTMLTable.Cell)1 Date (java.util.Date)1 Map (java.util.Map)1 TreeSet (java.util.TreeSet)1 GWTLatLng (org.opennms.features.poller.remote.gwt.client.GWTLatLng)1 GWTMarkerState (org.opennms.features.poller.remote.gwt.client.GWTMarkerState)1 StatusDetails (org.opennms.features.poller.remote.gwt.client.StatusDetails)1