use of org.opennms.netmgt.model.OnmsApplication in project opennms by OpenNMS.
the class LocationDataManagerTest method testLocationMonitorDaoFindByApplication.
@Test
public void testLocationMonitorDaoFindByApplication() {
OnmsApplication app = m_applicationDao.findByName("Domain Controllers");
Collection<OnmsLocationMonitor> monitors = m_locationMonitorDao.findByApplication(app);
assertEquals(376, monitors.size());
}
use of org.opennms.netmgt.model.OnmsApplication in project opennms by OpenNMS.
the class RemotePollerAvailabilityRestServiceIT method createLocationMonitors.
private void createLocationMonitors() throws InterruptedException {
m_transactionTemplate.execute(new TransactionCallbackWithoutResult() {
@Override
protected void doInTransactionWithoutResult(TransactionStatus status) {
System.err.println("======= Starting createLocationMonitors() ======");
OnmsLocationMonitor locMon1 = new OnmsLocationMonitor();
locMon1.setId(UUID.randomUUID().toString());
locMon1.setLocation("RDU");
locMon1.setLastUpdated(new Date());
locMon1.setStatus(MonitorStatus.STARTED);
m_locationMonitorDao.save(locMon1);
OnmsApplication ipv6App = new OnmsApplication();
ipv6App.setName("IPv6");
m_applicationDao.saveOrUpdate(ipv6App);
OnmsApplication ipv4App = new OnmsApplication();
ipv4App.setName("IPv4");
m_applicationDao.saveOrUpdate(ipv4App);
OnmsMonitoredService service2 = m_monServiceDao.findByType("HTTP").get(1);
service2.addApplication(ipv4App);
ipv4App.addMonitoredService(service2);
m_monServiceDao.saveOrUpdate(service2);
m_applicationDao.saveOrUpdate(ipv4App);
List<OnmsMonitoredService> services = m_monServiceDao.findByType("HTTP");
for (OnmsMonitoredService service : services) {
service = m_monServiceDao.findByType("HTTP").get(0);
service.addApplication(ipv6App);
ipv6App.addMonitoredService(service);
m_monServiceDao.saveOrUpdate(service);
m_applicationDao.saveOrUpdate(ipv6App);
OnmsLocationMonitor locMon = m_locationMonitorDao.findAll().get(0);
OnmsLocationSpecificStatus statusChange = new OnmsLocationSpecificStatus();
statusChange.setLocationMonitor(locMon);
statusChange.setPollResult(PollStatus.available());
statusChange.setMonitoredService(service);
m_locationMonitorDao.saveStatusChange(statusChange);
}
System.err.println("======= End createLocationMonitors() ======");
}
});
Thread.sleep(2000L);
m_transactionTemplate.execute(new TransactionCallbackWithoutResult() {
@Override
protected void doInTransactionWithoutResult(TransactionStatus status) {
List<OnmsMonitoredService> services = m_monServiceDao.findByType("HTTP");
for (OnmsMonitoredService service : services) {
OnmsLocationMonitor locMon = m_locationMonitorDao.findAll().get(0);
OnmsLocationSpecificStatus statusChange = new OnmsLocationSpecificStatus();
statusChange.setLocationMonitor(locMon);
statusChange.setPollResult(PollStatus.unavailable());
statusChange.setMonitoredService(service);
m_locationMonitorDao.saveStatusChange(statusChange);
}
}
});
Thread.sleep(2000L);
m_transactionTemplate.execute(new TransactionCallbackWithoutResult() {
@Override
protected void doInTransactionWithoutResult(TransactionStatus status) {
List<OnmsMonitoredService> services = m_monServiceDao.findByType("HTTP");
for (OnmsMonitoredService service : services) {
OnmsLocationMonitor locMon = m_locationMonitorDao.findAll().get(0);
OnmsLocationSpecificStatus statusChange = new OnmsLocationSpecificStatus();
statusChange.setLocationMonitor(locMon);
statusChange.setPollResult(PollStatus.available());
statusChange.setMonitoredService(service);
m_locationMonitorDao.saveStatusChange(statusChange);
}
}
});
}
use of org.opennms.netmgt.model.OnmsApplication in project opennms by OpenNMS.
the class DefaultLocationDataService method transformApplication.
private static ApplicationInfo transformApplication(final Collection<OnmsMonitoredService> services, final OnmsApplication application) {
final ApplicationInfo app = new ApplicationInfo();
app.setId(application.getId());
app.setName(application.getName());
final Set<GWTMonitoredService> s = new TreeSet<GWTMonitoredService>();
final Set<String> locations = new TreeSet<String>();
for (final OnmsMonitoredService service : services) {
for (final OnmsApplication oa : service.getApplications()) {
locations.add(oa.getName());
}
s.add(transformMonitoredService(service));
}
app.setServices(s);
app.setLocations(locations);
return app;
}
use of org.opennms.netmgt.model.OnmsApplication in project opennms by OpenNMS.
the class MockLocationMonitorDao method getStatusChangesBetweenForApplications.
@Override
public Collection<OnmsLocationSpecificStatus> getStatusChangesBetweenForApplications(final Date startDate, final Date endDate, final Collection<String> applicationNames) {
final List<OnmsLocationSpecificStatus> statuses = new ArrayList<>();
for (final OnmsLocationSpecificStatus status : getStatusChangesBetween(startDate, endDate)) {
boolean added = false;
for (final OnmsApplication app : status.getMonitoredService().getApplications()) {
for (final String applicationName : applicationNames) {
if (applicationName.equals(app.getName())) {
statuses.add(status);
added = true;
break;
}
}
if (added)
break;
}
}
return statuses;
}
use of org.opennms.netmgt.model.OnmsApplication in project opennms by OpenNMS.
the class DefaultLocationDataService method handleAllApplications.
/**
* {@inheritDoc}
*/
@Transactional
@Override
public void handleAllApplications(final Collection<ApplicationHandler> handlers) {
waitForGeocoding("handleAllApplications");
final Collection<OnmsApplication> apps = m_applicationDao.findAll();
for (final ApplicationHandler handler : handlers) {
handler.start(apps.size());
}
for (final OnmsApplication app : apps) {
for (final ApplicationHandler handler : handlers) {
handler.handle(app);
}
}
for (final ApplicationHandler handler : handlers) {
handler.finish();
}
}
Aggregations