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;
}
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();
}
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());
}
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;
}
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;
}
Aggregations