Search in sources :

Example 11 with NCSComponent

use of org.opennms.netmgt.model.ncs.NCSComponent in project opennms by OpenNMS.

the class DefaultNCSCorrelationService method findComponentsThatDependOn.

@Override
public List<NCSComponent> findComponentsThatDependOn(Long componentId) {
    NCSComponent comp = m_componentRepo.get(componentId);
    List<NCSComponent> parents = m_componentRepo.findComponentsThatDependOn(comp);
    for (NCSComponent parent : parents) {
        m_componentRepo.initialize(parent);
    }
    return parents;
}
Also used : NCSComponent(org.opennms.netmgt.model.ncs.NCSComponent)

Example 12 with NCSComponent

use of org.opennms.netmgt.model.ncs.NCSComponent in project opennms by OpenNMS.

the class NCSTypeListController method getComponentHTML.

private String getComponentHTML(NCSComponent component) {
    StringBuffer buffer = new StringBuffer();
    if (component != null) {
        Set<NCSComponent> subcomponents = component.getSubcomponents();
        if (subcomponents.size() > 0) {
            buffer.append("<li class=\"Expanded\">");
            buffer.append(component.getName());
            buffer.append("<ul>\n");
            for (NCSComponent c : subcomponents) {
                buffer.append(getComponentHTML(c));
            }
            buffer.append("</ul>");
        } else {
            buffer.append("<li>");
            buffer.append(component.getName());
        }
        buffer.append("</li>\n");
    }
    return buffer.toString();
}
Also used : NCSComponent(org.opennms.netmgt.model.ncs.NCSComponent)

Example 13 with NCSComponent

use of org.opennms.netmgt.model.ncs.NCSComponent in project opennms by OpenNMS.

the class DependencyRulesIT method testNodeDownUpCase.

@Test
@DirtiesContext
public void testNodeDownUpCase() throws Exception {
    // Get engine
    DroolsCorrelationEngine engine = findEngineByName("dependencyRules");
    // Antecipate down event
    getAnticipator().reset();
    Set<NCSComponent> impactedByNodeDown = new LinkedHashSet<NCSComponent>();
    for (NCSComponent c : findSubcomponentsOnNode(m_svc, "space", "1111-PE1")) {
        impactedByNodeDown.addAll(findPathToSubcomponent(m_svc, c.getForeignSource(), c.getForeignId()));
    }
    impactedByNodeDown = uniq(impactedByNodeDown);
    anticipate(transform(impactedByNodeDown, toComponentImpactedEvent(17)));
    // Generate down event
    System.err.println("SENDING nodeDown EVENT!!");
    engine.correlate(createNodeDownEvent(17, m_pe1NodeId));
    // Check down event
    getAnticipator().verifyAnticipated();
    // Anticipate up event
    getAnticipator().reset();
    anticipate(transform(impactedByNodeDown, toComponentResolvedEvent(19)));
    // Generate up event
    System.err.println("SENDING nodeUpEvent EVENT!!");
    engine.correlate(createNodeUpEvent(19, m_pe1NodeId));
    // Check up event
    getAnticipator().verifyAnticipated();
    // Memory should be clean!
    assertEquals("Unexpected objects in memory" + engine.getKieSessionObjects(), 0, engine.getKieSessionObjects().size());
}
Also used : LinkedHashSet(java.util.LinkedHashSet) NCSComponent(org.opennms.netmgt.model.ncs.NCSComponent) DroolsCorrelationEngine(org.opennms.netmgt.correlation.drools.DroolsCorrelationEngine) Test(org.junit.Test) DirtiesContext(org.springframework.test.annotation.DirtiesContext)

Example 14 with NCSComponent

use of org.opennms.netmgt.model.ncs.NCSComponent in project opennms by OpenNMS.

the class DependencyRulesIT method uniq.

private static Set<NCSComponent> uniq(Set<NCSComponent> components) {
    Set<NCSComponent> results = new LinkedHashSet<NCSComponent>();
    Set<String> ids = new HashSet<String>();
    for (NCSComponent component : components) {
        String id = component.getForeignSource() + ":" + component.getForeignId();
        if (!ids.contains(id)) {
            ids.add(id);
            results.add(component);
        }
    }
    return results;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) NCSComponent(org.opennms.netmgt.model.ncs.NCSComponent) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet)

Example 15 with NCSComponent

use of org.opennms.netmgt.model.ncs.NCSComponent in project opennms by OpenNMS.

the class NCSSearchProvider method query.

@Override
public List<SearchResult> query(SearchQuery searchQuery, GraphContainer graphContainer) {
    List<SearchResult> searchResults = new ArrayList<SearchResult>();
    List<NCSComponent> components = m_ncsComponentRepository.findByType("Service");
    for (NCSComponent component : components) {
        if (searchQuery.matches(component.getName())) {
            searchResults.add(new SearchResult(NAMESPACE, String.valueOf(component.getId()), component.getName(), searchQuery.getQueryString(), !SearchResult.COLLAPSIBLE, !SearchResult.COLLAPSED));
        }
    }
    return searchResults;
}
Also used : NCSComponent(org.opennms.netmgt.model.ncs.NCSComponent) ArrayList(java.util.ArrayList) SearchResult(org.opennms.features.topology.api.topo.SearchResult)

Aggregations

NCSComponent (org.opennms.netmgt.model.ncs.NCSComponent)30 NCSBuilder (org.opennms.netmgt.model.ncs.NCSBuilder)6 Test (org.junit.Test)5 Before (org.junit.Before)4 NetworkBuilder (org.opennms.netmgt.model.NetworkBuilder)4 ArrayList (java.util.ArrayList)3 HashSet (java.util.HashSet)3 LinkedHashSet (java.util.LinkedHashSet)3 EventProxyException (org.opennms.netmgt.events.api.EventProxyException)3 Transactional (org.springframework.transaction.annotation.Transactional)3 LinkedList (java.util.LinkedList)2 Criteria (org.opennms.features.topology.api.topo.Criteria)2 OnmsNode (org.opennms.netmgt.model.OnmsNode)2 NodeIdentification (org.opennms.netmgt.model.ncs.NCSComponent.NodeIdentification)2 NCSComponentRepository (org.opennms.netmgt.model.ncs.NCSComponentRepository)2 Item (com.vaadin.data.Item)1 Validator (com.vaadin.data.Validator)1 PropertysetItem (com.vaadin.data.util.PropertysetItem)1 Button (com.vaadin.ui.Button)1 ClickEvent (com.vaadin.ui.Button.ClickEvent)1