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;
}
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;
}
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;
}
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());
}
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);
}
Aggregations