Search in sources :

Example 1 with OnmsApplication

use of org.opennms.netmgt.model.OnmsApplication in project opennms by OpenNMS.

the class DefaultLocationDataService method getStatusDetailsForAllApplications.

private Map<OnmsApplication, StatusDetails> getStatusDetailsForAllApplications() {
    final Collection<OnmsApplication> apps = m_applicationDao.findAll();
    Map<OnmsApplication, StatusDetails> statusDetails = new LinkedHashMap<OnmsApplication, StatusDetails>();
    for (final OnmsApplication app : apps) {
        StatusDetails appStatusDetails = getStatusDetailsForApplication(app);
        statusDetails.put(app, appStatusDetails);
    }
    return statusDetails;
}
Also used : StatusDetails(org.opennms.features.poller.remote.gwt.client.StatusDetails) OnmsApplication(org.opennms.netmgt.model.OnmsApplication) LinkedHashMap(java.util.LinkedHashMap)

Example 2 with OnmsApplication

use of org.opennms.netmgt.model.OnmsApplication in project opennms by OpenNMS.

the class ApplicationSearchProvider method query.

@Override
public List<SearchResult> query(SearchQuery searchQuery, GraphContainer container) {
    LOG.info("ApplicationServiceSearchProvider->query: called with search query: '{}'", searchQuery);
    List<SearchResult> results = Lists.newArrayList();
    String queryString = searchQuery.getQueryString();
    CriteriaBuilder bldr = new CriteriaBuilder(OnmsApplication.class);
    if (queryString != null && queryString.length() > 0) {
        bldr.ilike("name", String.format("%%%s%%", queryString));
    }
    bldr.orderBy("name", true);
    bldr.limit(10);
    Criteria dbQueryCriteria = bldr.toCriteria();
    for (OnmsApplication application : applicationDao.findMatching(dbQueryCriteria)) {
        final ApplicationVertex applicationVertex = new ApplicationVertex(application);
        SearchResult searchResult = new SearchResult(applicationVertex, true, false);
        results.add(searchResult);
    }
    LOG.info("ApplicationServiceSearchProvider->query: found {} results: {}", results.size(), results);
    return results;
}
Also used : CriteriaBuilder(org.opennms.core.criteria.CriteriaBuilder) SearchResult(org.opennms.features.topology.api.topo.SearchResult) Criteria(org.opennms.core.criteria.Criteria) OnmsApplication(org.opennms.netmgt.model.OnmsApplication)

Example 3 with OnmsApplication

use of org.opennms.netmgt.model.OnmsApplication in project opennms by OpenNMS.

the class ApplicationTopologyProvider method load.

private void load() {
    resetContainer();
    for (OnmsApplication application : applicationDao.findAll()) {
        ApplicationVertex applicationVertex = new ApplicationVertex(application);
        addVertices(applicationVertex);
        for (OnmsMonitoredService eachMonitoredService : application.getMonitoredServices()) {
            final ApplicationVertex serviceVertex = new ApplicationVertex(eachMonitoredService);
            applicationVertex.addChildren(serviceVertex);
            addVertices(serviceVertex);
            // connect with application
            String id = String.format("connection:%s:%s", applicationVertex.getId(), serviceVertex.getId());
            Edge edge = new AbstractEdge(getNamespace(), id, applicationVertex, serviceVertex);
            addEdges(edge);
        }
    }
}
Also used : AbstractEdge(org.opennms.features.topology.api.topo.AbstractEdge) OnmsApplication(org.opennms.netmgt.model.OnmsApplication) Edge(org.opennms.features.topology.api.topo.Edge) AbstractEdge(org.opennms.features.topology.api.topo.AbstractEdge) OnmsMonitoredService(org.opennms.netmgt.model.OnmsMonitoredService)

Example 4 with OnmsApplication

use of org.opennms.netmgt.model.OnmsApplication in project opennms by OpenNMS.

the class PollerBackEndTest method setUp.

@Override
protected void setUp() throws Exception {
    System.setProperty("opennms.home", "src/test/test-configurations/PollerBackEndTest-home");
    m_monitoringLocationDao = m_mocks.createMock(MonitoringLocationDao.class);
    m_locMonDao = m_mocks.createMock(LocationMonitorDao.class);
    m_scanReportDao = m_mocks.createMock(ScanReportDao.class);
    m_monSvcDao = m_mocks.createMock(MonitoredServiceDao.class);
    m_pollerConfig = m_mocks.createMock(PollerConfig.class);
    m_timeKeeper = m_mocks.createMock(TimeKeeper.class);
    m_eventIpcManager = new MockEventIpcManager();
    m_backEnd = new DefaultPollerBackEnd();
    m_backEnd.setMonitoringLocationDao(m_monitoringLocationDao);
    m_backEnd.setLocationMonitorDao(m_locMonDao);
    m_backEnd.setScanReportDao(m_scanReportDao);
    m_backEnd.setMonitoredServiceDao(m_monSvcDao);
    m_backEnd.setPollerConfig(m_pollerConfig);
    m_backEnd.setTimeKeeper(m_timeKeeper);
    m_backEnd.setEventIpcManager(m_eventIpcManager);
    m_backEnd.setDisconnectedTimeout(DISCONNECTED_TIMEOUT);
    m_backEnd.setPersisterFactory(new MockPersisterFactory());
    m_startTime = new Date(System.currentTimeMillis() - 600000);
    expect(m_timeKeeper.getCurrentDate()).andReturn(m_startTime);
    replay(m_timeKeeper);
    m_backEnd.afterPropertiesSet();
    verify(m_timeKeeper);
    reset(m_timeKeeper);
    // set up some objects that can be used to mock up the tests
    // the location definition
    m_locationDefinition = new OnmsMonitoringLocation();
    m_locationDefinition.setMonitoringArea("Oakland");
    m_locationDefinition.setLocationName("OAK");
    m_locationDefinition.setPollingPackageNames(Collections.singletonList("OAKPackage"));
    m_package = createPackage("OAKPackage", "ipaddr = '192.168.1.1'");
    m_serviceSelector = new ServiceSelector(m_package.getFilter().getContent(), Arrays.asList(new String[] { "HTTP", "DNS" }));
    m_httpSvcConfig = addService(m_package, "HTTP", 1234, "url", "http://www.opennms.org");
    m_dnsSvcConfig = addService(m_package, "DNS", 5678, "hostname", "www.opennms.org");
    m_locationMonitor = new OnmsLocationMonitor();
    m_locationMonitor.setId(LOCATION_MONITOR_ID);
    m_locationMonitor.setLocation(m_locationDefinition.getLocationName());
    OnmsApplication application = new OnmsApplication();
    application.setName(APPLICATION_NAME);
    NetworkBuilder builder = new NetworkBuilder();
    builder.addNode("testNode").setId(1);
    builder.addInterface("192.168.1.1").setId(1);
    m_httpService = builder.addService(new OnmsServiceType("HTTP"));
    m_httpService.setId(1);
    m_httpService.setApplications(Collections.singleton(application));
    m_dnsService = builder.addService(new OnmsServiceType("DNS"));
    m_dnsService.setId(2);
    m_dnsService.setApplications(Collections.singleton(application));
    m_monServices = new OnmsMonitoredService[] { m_httpService, m_dnsService };
    long now = System.currentTimeMillis();
    PollStatus httpResult = PollStatus.available(1000.0);
    httpResult.setTimestamp(new Date(now - 300000));
    m_httpCurrentStatus = new OnmsLocationSpecificStatus(m_locationMonitor, m_httpService, httpResult);
    m_httpCurrentStatus.setId(1);
    PollStatus dnsResult = PollStatus.unavailable("Non responsive");
    dnsResult.setTimestamp(new Date(now - 300000));
    m_dnsCurrentStatus = new OnmsLocationSpecificStatus(m_locationMonitor, m_dnsService, dnsResult);
    m_dnsCurrentStatus.setId(2);
    m_pollerDetails = new HashMap<String, String>();
    m_pollerDetails.put("os.name", "WonkaOS");
    m_pollerDetails.put("os.version", "1.2.3");
}
Also used : PollStatus(org.opennms.netmgt.poller.PollStatus) TimeKeeper(org.opennms.netmgt.collection.api.TimeKeeper) MockEventIpcManager(org.opennms.netmgt.dao.mock.MockEventIpcManager) OnmsLocationSpecificStatus(org.opennms.netmgt.model.OnmsLocationSpecificStatus) ScanReportDao(org.opennms.netmgt.dao.api.ScanReportDao) MonitoredServiceDao(org.opennms.netmgt.dao.api.MonitoredServiceDao) PollerConfig(org.opennms.netmgt.config.PollerConfig) ServiceSelector(org.opennms.netmgt.model.ServiceSelector) MonitoringLocationDao(org.opennms.netmgt.dao.api.MonitoringLocationDao) OnmsApplication(org.opennms.netmgt.model.OnmsApplication) LocationMonitorDao(org.opennms.netmgt.dao.api.LocationMonitorDao) DefaultPollerBackEnd(org.opennms.netmgt.poller.remote.support.DefaultPollerBackEnd) Date(java.util.Date) NetworkBuilder(org.opennms.netmgt.model.NetworkBuilder) OnmsServiceType(org.opennms.netmgt.model.OnmsServiceType) MockPersisterFactory(org.opennms.netmgt.mock.MockPersisterFactory) OnmsLocationMonitor(org.opennms.netmgt.model.OnmsLocationMonitor) OnmsMonitoringLocation(org.opennms.netmgt.model.monitoringLocations.OnmsMonitoringLocation)

Example 5 with OnmsApplication

use of org.opennms.netmgt.model.OnmsApplication in project opennms by OpenNMS.

the class DefaultDistributedStatusServiceTest method testCreateFacilityStatusTableNoApplications.

public void testCreateFacilityStatusTableNoApplications() {
    expect(m_monitoringLocationDao.findAll()).andReturn(Collections.singletonList(m_locationDefinition1));
    expect(m_applicationDao.findAll()).andReturn(new ArrayList<OnmsApplication>());
    ThrowableAnticipator ta = new ThrowableAnticipator();
    ta.anticipate(new IllegalArgumentException("there are no applications"));
    Date start = new Date();
    // one second after start time
    Date end = new Date(start.getTime() + 1000);
    m_easyMockUtils.replayAll();
    try {
        m_service.createFacilityStatusTable(start, end);
    } catch (Throwable t) {
        ta.throwableReceived(t);
    }
    ta.verifyAnticipated();
    m_easyMockUtils.verifyAll();
}
Also used : OnmsApplication(org.opennms.netmgt.model.OnmsApplication) Date(java.util.Date) ThrowableAnticipator(org.opennms.test.ThrowableAnticipator)

Aggregations

OnmsApplication (org.opennms.netmgt.model.OnmsApplication)42 OnmsMonitoredService (org.opennms.netmgt.model.OnmsMonitoredService)20 OnmsLocationMonitor (org.opennms.netmgt.model.OnmsLocationMonitor)14 ArrayList (java.util.ArrayList)13 OnmsMonitoringLocation (org.opennms.netmgt.model.monitoringLocations.OnmsMonitoringLocation)12 Date (java.util.Date)11 OnmsLocationSpecificStatus (org.opennms.netmgt.model.OnmsLocationSpecificStatus)11 LinkedList (java.util.LinkedList)8 Transactional (org.springframework.transaction.annotation.Transactional)6 HashSet (java.util.HashSet)5 ApplicationInfo (org.opennms.features.poller.remote.gwt.client.ApplicationInfo)4 StatusDetails (org.opennms.features.poller.remote.gwt.client.StatusDetails)4 SimpleWebTable (org.opennms.web.svclayer.model.SimpleWebTable)4 LinkedHashMap (java.util.LinkedHashMap)3 List (java.util.List)3 Test (org.junit.Test)3 OnmsNode (org.opennms.netmgt.model.OnmsNode)3 OnmsServiceType (org.opennms.netmgt.model.OnmsServiceType)3 DistributedStatusHistoryModel (org.opennms.web.svclayer.model.DistributedStatusHistoryModel)3 HashMap (java.util.HashMap)2