Search in sources :

Example 1 with ApplicationDetails

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

the class LocationDataServiceIT method testApplicationDetailsHalfAvailableOneMonitor.

@Test
public void testApplicationDetailsHalfAvailableOneMonitor() throws Exception {
    // first, everything's up
    m_pollerBackEnd.reportResult(m_rduMonitor1.getId(), m_localhostHttpService.getId(), getAvailable(m_pollingStart));
    m_pollerBackEnd.reportResult(m_rduMonitor1.getId(), m_googleHttpService.getId(), getAvailable(m_pollingStart));
    // bring it down for 12 hours
    m_pollerBackEnd.reportResult(m_rduMonitor1.getId(), m_googleHttpService.getId(), getDown(new Date(m_pollingStart.getTime() + (1000 * 60 * 60 * 6))));
    // bring it back up
    m_pollerBackEnd.reportResult(m_rduMonitor1.getId(), m_googleHttpService.getId(), getAvailable(new Date(m_pollingStart.getTime() + (1000 * 60 * 60 * 18))));
    ApplicationDetails ad = m_locationDataService.getApplicationDetails("TestApp1");
    assertEquals("TestApp1", ad.getApplicationName());
    assertEquals(Double.valueOf(50), ad.getAvailability());
    assertEquals("currently available", StatusDetails.up(), ad.getStatusDetails());
}
Also used : ApplicationDetails(org.opennms.features.poller.remote.gwt.client.ApplicationDetails) Date(java.util.Date) Test(org.junit.Test)

Example 2 with ApplicationDetails

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

the class LocationDataServiceIT method testApplicationDetailsTwoMonitorsMarginal.

@Test
public void testApplicationDetailsTwoMonitorsMarginal() throws Exception {
    // first, everything's up
    m_pollerBackEnd.reportResult(m_rduMonitor1.getId(), m_localhostHttpService.getId(), getAvailable(m_pollingStart));
    m_pollerBackEnd.reportResult(m_rduMonitor2.getId(), m_localhostHttpService.getId(), getAvailable(m_pollingStart));
    m_pollerBackEnd.reportResult(m_rduMonitor1.getId(), m_googleHttpService.getId(), getAvailable(m_pollingStart));
    m_pollerBackEnd.reportResult(m_rduMonitor2.getId(), m_googleHttpService.getId(), getAvailable(m_pollingStart));
    // bring one down for 12 hours
    m_pollerBackEnd.reportResult(m_rduMonitor1.getId(), m_googleHttpService.getId(), getDown(new Date(m_pollingStart.getTime() + (1000 * 60 * 60 * 6))));
    // and back up
    m_pollerBackEnd.reportResult(m_rduMonitor1.getId(), m_googleHttpService.getId(), getAvailable(new Date(m_pollingStart.getTime() + (1000 * 60 * 60 * 18))));
    ApplicationDetails ad = m_locationDataService.getApplicationDetails("TestApp1");
    assertEquals("TestApp1", ad.getApplicationName());
    assertEquals(Double.valueOf(100), ad.getAvailability());
    assertEquals("currently available", StatusDetails.up(), ad.getStatusDetails());
}
Also used : ApplicationDetails(org.opennms.features.poller.remote.gwt.client.ApplicationDetails) Date(java.util.Date) Test(org.junit.Test)

Example 3 with ApplicationDetails

use of org.opennms.features.poller.remote.gwt.client.ApplicationDetails 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;
}
Also used : GWTLocationSpecificStatus(org.opennms.features.poller.remote.gwt.client.GWTLocationSpecificStatus) OnmsLocationSpecificStatus(org.opennms.netmgt.model.OnmsLocationSpecificStatus) ApplicationInfo(org.opennms.features.poller.remote.gwt.client.ApplicationInfo) ArrayList(java.util.ArrayList) GWTLocationMonitor(org.opennms.features.poller.remote.gwt.client.GWTLocationMonitor) OnmsLocationMonitor(org.opennms.netmgt.model.OnmsLocationMonitor) ApplicationDetails(org.opennms.features.poller.remote.gwt.client.ApplicationDetails) Date(java.util.Date) OnmsMonitoredService(org.opennms.netmgt.model.OnmsMonitoredService) Transactional(org.springframework.transaction.annotation.Transactional)

Example 4 with ApplicationDetails

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

the class LocationDataServiceIT method testApplicationDetailsTwoMonitorsOutagesOverlap.

@Test
public void testApplicationDetailsTwoMonitorsOutagesOverlap() throws Exception {
    // first, everything's up
    m_pollerBackEnd.reportResult(m_rduMonitor1.getId(), m_localhostHttpService.getId(), getAvailable(m_pollingStart));
    m_pollerBackEnd.reportResult(m_rduMonitor2.getId(), m_localhostHttpService.getId(), getAvailable(m_pollingStart));
    m_pollerBackEnd.reportResult(m_rduMonitor1.getId(), m_googleHttpService.getId(), getAvailable(m_pollingStart));
    m_pollerBackEnd.reportResult(m_rduMonitor2.getId(), m_googleHttpService.getId(), getAvailable(m_pollingStart));
    // bring one down for 12 hours
    m_pollerBackEnd.reportResult(m_rduMonitor1.getId(), m_googleHttpService.getId(), getDown(new Date(m_pollingStart.getTime() + (1000 * 60 * 60 * 6))));
    // and back up
    m_pollerBackEnd.reportResult(m_rduMonitor1.getId(), m_googleHttpService.getId(), getAvailable(new Date(m_pollingStart.getTime() + (1000 * 60 * 60 * 18))));
    // bring the other down for 12 hours, overlapping by 8
    m_pollerBackEnd.reportResult(m_rduMonitor2.getId(), m_googleHttpService.getId(), getDown(new Date(m_pollingStart.getTime() + (1000 * 60 * 60 * 10))));
    // and back up
    m_pollerBackEnd.reportResult(m_rduMonitor2.getId(), m_googleHttpService.getId(), getAvailable(new Date(m_pollingStart.getTime() + (1000 * 60 * 60 * 22))));
    ApplicationDetails ad = m_locationDataService.getApplicationDetails("TestApp1");
    assertEquals("TestApp1", ad.getApplicationName());
    assertEquals(Double.valueOf(16D / 24D * 100), ad.getAvailability());
    assertEquals("currently available", StatusDetails.up(), ad.getStatusDetails());
    final String detailString = ad.getDetailsAsString();
    System.err.println(detailString);
    assertTrue(detailString.contains(""));
}
Also used : ApplicationDetails(org.opennms.features.poller.remote.gwt.client.ApplicationDetails) Date(java.util.Date) Test(org.junit.Test)

Example 5 with ApplicationDetails

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

the class LocationDataServiceIT method testApplicationDetailsDownOneMonitor.

@Test
public void testApplicationDetailsDownOneMonitor() throws Exception {
    m_pollerBackEnd.reportResult(m_rduMonitor1.getId(), m_localhostHttpService.getId(), getDown(m_pollingStart));
    m_pollerBackEnd.reportResult(m_rduMonitor1.getId(), m_googleHttpService.getId(), getDown(m_pollingStart));
    ApplicationDetails ad = m_locationDataService.getApplicationDetails("TestApp1");
    assertEquals("TestApp1", ad.getApplicationName());
    assertEquals(Double.valueOf(0), ad.getAvailability());
    assertEquals("down for 24 hours", StatusDetails.down("foo"), ad.getStatusDetails());
}
Also used : ApplicationDetails(org.opennms.features.poller.remote.gwt.client.ApplicationDetails) Test(org.junit.Test)

Aggregations

ApplicationDetails (org.opennms.features.poller.remote.gwt.client.ApplicationDetails)7 Test (org.junit.Test)6 Date (java.util.Date)5 ArrayList (java.util.ArrayList)1 ApplicationInfo (org.opennms.features.poller.remote.gwt.client.ApplicationInfo)1 GWTLocationMonitor (org.opennms.features.poller.remote.gwt.client.GWTLocationMonitor)1 GWTLocationSpecificStatus (org.opennms.features.poller.remote.gwt.client.GWTLocationSpecificStatus)1 OnmsLocationMonitor (org.opennms.netmgt.model.OnmsLocationMonitor)1 OnmsLocationSpecificStatus (org.opennms.netmgt.model.OnmsLocationSpecificStatus)1 OnmsMonitoredService (org.opennms.netmgt.model.OnmsMonitoredService)1 Transactional (org.springframework.transaction.annotation.Transactional)1