Search in sources :

Example 6 with GraphVertex

use of org.opennms.netmgt.bsm.service.model.graph.GraphVertex in project opennms by OpenNMS.

the class DefaultBusinessServiceStateMachineTest method canPerformRootCauseAndImpactAnalysis.

@Test
public void canPerformRootCauseAndImpactAnalysis() {
    // Create a hierarchy using all of the available reduction functions
    HighestSeverity highestSeverity = new HighestSeverity();
    Threshold threshold = new Threshold();
    threshold.setThreshold(0.5f);
    HighestSeverityAbove highestSeverityAbove = new HighestSeverityAbove();
    highestSeverityAbove.setThreshold(Status.MINOR);
    MockBusinessServiceHierarchy h = MockBusinessServiceHierarchy.builder().withBusinessService(1).withName("b1").withReductionFunction(highestSeverityAbove).withBusinessService(2).withName("b2").withReductionFunction(highestSeverity).withReductionKey(21, "a1").withReductionKey(22, "a2").withReductionKey(23, "a3").commit().withBusinessService(3).withName("b3").withReductionFunction(threshold).withReductionKey(34, "a4").withReductionKey(35, "a5").withReductionKey(36, "a6").withReductionKey(37, "a7").commit().commit().build();
    // Setup the state machine
    DefaultBusinessServiceStateMachine stateMachine = new DefaultBusinessServiceStateMachine();
    stateMachine.setBusinessServices(h.getBusinessServices());
    // Bump b2 to MINOR, caused by a1
    stateMachine.handleNewOrUpdatedAlarm(new MockAlarmWrapper("a1", Status.MINOR));
    // Bump b3 to MAJOR, caused by a4, a6 and a7
    stateMachine.handleNewOrUpdatedAlarm(new MockAlarmWrapper("a4", Status.MAJOR));
    stateMachine.handleNewOrUpdatedAlarm(new MockAlarmWrapper("a6", Status.CRITICAL));
    stateMachine.handleNewOrUpdatedAlarm(new MockAlarmWrapper("a7", Status.MAJOR));
    // Bumped b1 to MAJOR, caused by b3
    // Verify the state
    assertEquals(Status.MAJOR, stateMachine.getOperationalStatus(h.getBusinessServiceById(1)));
    assertEquals(Status.MINOR, stateMachine.getOperationalStatus(h.getBusinessServiceById(2)));
    assertEquals(Status.MAJOR, stateMachine.getOperationalStatus(h.getBusinessServiceById(3)));
    // Calculate and verify the root causes, b2 caused by a1
    List<GraphVertex> causedby = stateMachine.calculateRootCause(h.getBusinessServiceById(2));
    assertEquals(1, causedby.size());
    assertEquals("a1", causedby.get(0).getReductionKey());
    // b3 caused by a4, a6 and a7
    causedby = stateMachine.calculateRootCause(h.getBusinessServiceById(3));
    assertEquals(3, causedby.size());
    assertEquals("a4", causedby.get(0).getReductionKey());
    assertEquals("a6", causedby.get(1).getReductionKey());
    assertEquals("a7", causedby.get(2).getReductionKey());
    // b1 caused by b3, which was in turn caused by a4, a6 and a7
    causedby = stateMachine.calculateRootCause(h.getBusinessServiceById(1));
    assertEquals(4, causedby.size());
    assertEquals(Long.valueOf(3), causedby.get(0).getBusinessService().getId());
    assertEquals("a4", causedby.get(1).getReductionKey());
    assertEquals("a6", causedby.get(2).getReductionKey());
    assertEquals("a7", causedby.get(3).getReductionKey());
    // Now calculate the impact, a1 impacts b2
    List<GraphVertex> impacts = stateMachine.calculateImpact("a1");
    assertEquals(1, impacts.size());
    assertEquals("b2", impacts.get(0).getBusinessService().getName());
    // a4 impacts b3 which impacts b1
    impacts = stateMachine.calculateImpact("a4");
    assertEquals(2, impacts.size());
    assertEquals("b3", impacts.get(0).getBusinessService().getName());
    assertEquals("b1", impacts.get(1).getBusinessService().getName());
    // b3 impacts b1
    impacts = stateMachine.calculateImpact(h.getBusinessServiceById(3));
    assertEquals(1, impacts.size());
    assertEquals("b1", impacts.get(0).getBusinessService().getName());
}
Also used : HighestSeverity(org.opennms.netmgt.bsm.service.model.functions.reduce.HighestSeverity) GraphVertex(org.opennms.netmgt.bsm.service.model.graph.GraphVertex) MockBusinessServiceHierarchy(org.opennms.netmgt.bsm.mock.MockBusinessServiceHierarchy) HighestSeverityAbove(org.opennms.netmgt.bsm.service.model.functions.reduce.HighestSeverityAbove) MockAlarmWrapper(org.opennms.netmgt.bsm.mock.MockAlarmWrapper) Threshold(org.opennms.netmgt.bsm.service.model.functions.reduce.Threshold) Test(org.junit.Test)

Example 7 with GraphVertex

use of org.opennms.netmgt.bsm.service.model.graph.GraphVertex in project opennms by OpenNMS.

the class DefaultBusinessServiceStateMachine method clone.

@Override
public BusinessServiceStateMachine clone(boolean preserveState) {
    m_rwLock.readLock().lock();
    try {
        final BusinessServiceStateMachine sm = new DefaultBusinessServiceStateMachine();
        // Rebuild the graph using the business services from the existing state machine
        final BusinessServiceGraph graph = getGraph();
        sm.setBusinessServices(graph.getVertices().stream().map(GraphVertex::getBusinessService).filter(Objects::nonNull).collect(Collectors.toList()));
        // Prime the state
        if (preserveState) {
            for (String reductionKey : graph.getReductionKeys()) {
                GraphVertex reductionKeyVertex = graph.getVertexByReductionKey(reductionKey);
                sm.handleNewOrUpdatedAlarm(new AlarmWrapper() {

                    @Override
                    public String getReductionKey() {
                        return reductionKey;
                    }

                    @Override
                    public Status getStatus() {
                        return reductionKeyVertex.getStatus();
                    }
                });
            }
        }
        return sm;
    } finally {
        m_rwLock.readLock().unlock();
    }
}
Also used : Status(org.opennms.netmgt.bsm.service.model.Status) GraphVertex(org.opennms.netmgt.bsm.service.model.graph.GraphVertex) BusinessServiceStateMachine(org.opennms.netmgt.bsm.service.BusinessServiceStateMachine) AlarmWrapper(org.opennms.netmgt.bsm.service.model.AlarmWrapper) Objects(java.util.Objects) BusinessServiceGraph(org.opennms.netmgt.bsm.service.model.graph.BusinessServiceGraph)

Example 8 with GraphVertex

use of org.opennms.netmgt.bsm.service.model.graph.GraphVertex in project opennms by OpenNMS.

the class BusinessServiceVertexStatusInfoPanelItemProvider method createComponent.

private Component createComponent(BusinessServiceVertex vertex, GraphContainer container) {
    final FormLayout rootLayout = new FormLayout();
    rootLayout.setSizeFull();
    rootLayout.setSpacing(false);
    rootLayout.setMargin(false);
    rootLayout.addStyleName("severity");
    final BusinessServiceStateMachine stateMachine = SimulationAwareStateMachineFactory.createStateMachine(businessServiceManager, container.getCriteria());
    final Status overallStatus = BusinessServicesStatusProvider.getStatus(stateMachine, vertex);
    rootLayout.addComponent(createStatusLabel("Overall", overallStatus));
    rootLayout.addComponent(new Label());
    final BusinessServiceGraph graph = stateMachine.getGraph();
    final BusinessService businessService = businessServiceManager.getBusinessServiceById(vertex.getServiceId());
    final Set<GraphVertex> impactingVertices = getImpactingVertices(stateMachine, graph, businessService);
    for (final Edge edge : businessService.getEdges()) {
        // Get the topology vertex for the child to determine the display label
        final Vertex childVertex = businessServicesTopologyProvider.getVertex(edge.accept(new EdgeVisitor<VertexRef>() {

            @Override
            public VertexRef visit(final IpServiceEdge edge) {
                return new IpServiceVertex(edge.getIpService(), 0);
            }

            @Override
            public VertexRef visit(final ReductionKeyEdge edge) {
                return new ReductionKeyVertex(edge.getReductionKey(), 0);
            }

            @Override
            public VertexRef visit(final ChildEdge edge) {
                return new BusinessServiceVertex(edge.getChild(), 0);
            }
        }));
        final Status edgeStatus = stateMachine.getOperationalStatus(edge);
        rootLayout.addComponent(createStatusLabel(childVertex.getLabel(), edgeStatus, String.format("%s &times; %d <i class=\"pull-right glyphicon %s\"></i>", edgeStatus.getLabel(), edge.getWeight(), impactingVertices.contains(graph.getVertexByEdgeId(edge.getId())) ? "glyphicon-flash" : "")));
    }
    return rootLayout;
}
Also used : FormLayout(com.vaadin.ui.FormLayout) Status(org.opennms.netmgt.bsm.service.model.Status) Vertex(org.opennms.features.topology.api.topo.Vertex) IpServiceVertex(org.opennms.features.topology.plugins.topo.bsm.IpServiceVertex) GraphVertex(org.opennms.netmgt.bsm.service.model.graph.GraphVertex) BusinessServiceVertex(org.opennms.features.topology.plugins.topo.bsm.BusinessServiceVertex) ReductionKeyVertex(org.opennms.features.topology.plugins.topo.bsm.ReductionKeyVertex) ReductionKeyVertex(org.opennms.features.topology.plugins.topo.bsm.ReductionKeyVertex) ChildEdge(org.opennms.netmgt.bsm.service.model.edge.ChildEdge) Label(com.vaadin.ui.Label) UIHelper.createLabel(org.opennms.netmgt.vaadin.core.UIHelper.createLabel) IpServiceEdge(org.opennms.netmgt.bsm.service.model.edge.IpServiceEdge) BusinessServiceGraph(org.opennms.netmgt.bsm.service.model.graph.BusinessServiceGraph) EdgeVisitor(org.opennms.netmgt.bsm.service.model.edge.EdgeVisitor) IpServiceVertex(org.opennms.features.topology.plugins.topo.bsm.IpServiceVertex) ReductionKeyEdge(org.opennms.netmgt.bsm.service.model.edge.ReductionKeyEdge) BusinessService(org.opennms.netmgt.bsm.service.model.BusinessService) GraphVertex(org.opennms.netmgt.bsm.service.model.graph.GraphVertex) BusinessServiceStateMachine(org.opennms.netmgt.bsm.service.BusinessServiceStateMachine) ChildEdge(org.opennms.netmgt.bsm.service.model.edge.ChildEdge) ReductionKeyEdge(org.opennms.netmgt.bsm.service.model.edge.ReductionKeyEdge) Edge(org.opennms.netmgt.bsm.service.model.edge.Edge) IpServiceEdge(org.opennms.netmgt.bsm.service.model.edge.IpServiceEdge) BusinessServiceVertex(org.opennms.features.topology.plugins.topo.bsm.BusinessServiceVertex)

Example 9 with GraphVertex

use of org.opennms.netmgt.bsm.service.model.graph.GraphVertex in project opennms by OpenNMS.

the class AbstractAnalysisOperation method execute.

@Override
public void execute(List<VertexRef> targets, OperationContext operationContext) {
    final List<AbstractBusinessServiceVertex> vertices = getVertices(targets);
    final BusinessServiceStateMachine stateMachine = SimulationAwareStateMachineFactory.createStateMachine(businessServiceManager, operationContext.getGraphContainer().getCriteria());
    final Set<GraphVertex> graphVerticesToFocus = Sets.newHashSet();
    final BusinessServiceVertexVisitor<Collection<GraphVertex>> visitor = getVisitorForVerticesToFocus(stateMachine);
    for (AbstractBusinessServiceVertex vertex : vertices) {
        graphVerticesToFocus.addAll(vertex.accept(visitor));
    }
    LOG.debug("Found {} business services.", graphVerticesToFocus.size());
    if (graphVerticesToFocus.isEmpty()) {
        new InfoDialog("No result", getMessageForNoResultDialog()).open();
    } else {
        focusOnVertices(targets.get(0), graphVerticesToFocus, operationContext.getGraphContainer());
    }
}
Also used : GraphVertex(org.opennms.netmgt.bsm.service.model.graph.GraphVertex) BusinessServiceStateMachine(org.opennms.netmgt.bsm.service.BusinessServiceStateMachine) InfoDialog(org.opennms.netmgt.vaadin.core.InfoDialog) Collection(java.util.Collection) AbstractBusinessServiceVertex(org.opennms.features.topology.plugins.topo.bsm.AbstractBusinessServiceVertex)

Example 10 with GraphVertex

use of org.opennms.netmgt.bsm.service.model.graph.GraphVertex in project opennms by OpenNMS.

the class BusinessServicesStatusProvider method getStatus.

public static org.opennms.netmgt.bsm.service.model.Status getStatus(BusinessServiceStateMachine stateMachine, BusinessServiceEdge edge) {
    final BusinessServiceGraph graph = stateMachine.getGraph();
    // We need both the source and target vertices to find the edge in the graph
    final GraphVertex source = getGraphVertex(edge.getBusinessServiceSource(), stateMachine.getGraph());
    final GraphVertex target = getGraphVertex(edge.getBusinessServiceTarget(), stateMachine.getGraph());
    final GraphEdge graphEdge = graph.findEdge(source, target);
    return graphEdge != null ? graphEdge.getStatus() : null;
}
Also used : GraphVertex(org.opennms.netmgt.bsm.service.model.graph.GraphVertex) GraphEdge(org.opennms.netmgt.bsm.service.model.graph.GraphEdge) BusinessServiceGraph(org.opennms.netmgt.bsm.service.model.graph.BusinessServiceGraph)

Aggregations

GraphVertex (org.opennms.netmgt.bsm.service.model.graph.GraphVertex)17 BusinessServiceGraph (org.opennms.netmgt.bsm.service.model.graph.BusinessServiceGraph)7 GraphEdge (org.opennms.netmgt.bsm.service.model.graph.GraphEdge)7 Status (org.opennms.netmgt.bsm.service.model.Status)4 BusinessServiceStateMachine (org.opennms.netmgt.bsm.service.BusinessServiceStateMachine)3 Edge (org.opennms.netmgt.bsm.service.model.edge.Edge)3 Collections (java.util.Collections)2 Test (org.junit.Test)2 MockAlarmWrapper (org.opennms.netmgt.bsm.mock.MockAlarmWrapper)2 MockBusinessServiceHierarchy (org.opennms.netmgt.bsm.mock.MockBusinessServiceHierarchy)2 AlarmWrapper (org.opennms.netmgt.bsm.service.model.AlarmWrapper)2 BusinessService (org.opennms.netmgt.bsm.service.model.BusinessService)2 StatusWithIndex (org.opennms.netmgt.bsm.service.model.StatusWithIndex)2 StatusWithIndices (org.opennms.netmgt.bsm.service.model.StatusWithIndices)2 ChildEdge (org.opennms.netmgt.bsm.service.model.edge.ChildEdge)2 IpServiceEdge (org.opennms.netmgt.bsm.service.model.edge.IpServiceEdge)2 ReductionKeyEdge (org.opennms.netmgt.bsm.service.model.edge.ReductionKeyEdge)2 HighestSeverity (org.opennms.netmgt.bsm.service.model.functions.reduce.HighestSeverity)2 Lists (com.google.common.collect.Lists)1 Maps (com.google.common.collect.Maps)1