use of org.opennms.features.poller.remote.gwt.client.GWTLocationMonitor 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;
}
use of org.opennms.features.poller.remote.gwt.client.GWTLocationMonitor in project opennms by OpenNMS.
the class DefaultLocationDataService method transformLocationMonitor.
private static GWTLocationMonitor transformLocationMonitor(final OnmsLocationMonitor monitor) {
final GWTLocationMonitor gMonitor = new GWTLocationMonitor();
gMonitor.setId(monitor.getId());
gMonitor.setDefinitionName(monitor.getLocation());
gMonitor.setName(monitor.getName());
gMonitor.setStatus(monitor.getStatus().toString());
gMonitor.setLastCheckInTime(monitor.getLastUpdated());
return gMonitor;
}
use of org.opennms.features.poller.remote.gwt.client.GWTLocationMonitor 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.features.poller.remote.gwt.client.GWTLocationMonitor 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.features.poller.remote.gwt.client.GWTLocationMonitor 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;
}
Aggregations