Search in sources :

Example 11 with GraphVertex

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

the class BusinessServicesTopologyProvider method addVertex.

private void addVertex(BusinessServiceGraph graph, GraphVertex graphVertex, AbstractBusinessServiceVertex topologyVertex) {
    if (topologyVertex == null) {
        // Create a topology vertex for the current vertex
        topologyVertex = createTopologyVertex(graphVertex);
        addVertices(topologyVertex);
    }
    for (GraphEdge graphEdge : graph.getOutEdges(graphVertex)) {
        GraphVertex childVertex = graph.getOpposite(graphVertex, graphEdge);
        // Create a topology vertex for the child vertex
        AbstractBusinessServiceVertex childTopologyVertex = createTopologyVertex(childVertex);
        graph.getInEdges(childVertex).stream().map(GraphEdge::getFriendlyName).filter(s -> !Strings.isNullOrEmpty(s)).findFirst().ifPresent(childTopologyVertex::setLabel);
        addVertices(childTopologyVertex);
        // Connect the two
        childTopologyVertex.setParent(topologyVertex);
        Edge edge = new BusinessServiceEdge(graphEdge, topologyVertex, childTopologyVertex);
        addEdges(edge);
        // Recurse
        addVertex(graph, childVertex, childTopologyVertex);
    }
}
Also used : GraphVertex(org.opennms.netmgt.bsm.service.model.graph.GraphVertex) GraphEdge(org.opennms.netmgt.bsm.service.model.graph.GraphEdge) Edge(org.opennms.features.topology.api.topo.Edge) GraphEdge(org.opennms.netmgt.bsm.service.model.graph.GraphEdge)

Example 12 with GraphVertex

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

the class BusinessServiceContainer method createRowForVertex.

private void createRowForVertex(BusinessServiceGraph graph, GraphVertex graphVertex, BusinessServiceRow parentRow) {
    final BusinessService businessService = graphVertex.getBusinessService();
    if (businessService == null) {
        return;
    }
    final long rowId = rowIdCounter.incrementAndGet();
    final Long parentBusinessServiceId = parentRow != null ? parentRow.getBusinessService().getId() : null;
    final BusinessServiceRow row = new BusinessServiceRow(rowId, businessService, parentBusinessServiceId);
    if (parentRow != null) {
        rowIdToParentRowIdMapping.put(rowId, parentRow.getRowId());
    }
    addBean(row);
    // Recurse with all of the children
    graph.getOutEdges(graphVertex).stream().map(e -> graph.getOpposite(graphVertex, e)).filter(v -> v.getBusinessService() != null).sorted((v1, v2) -> v1.getBusinessService().getName().compareTo(v2.getBusinessService().getName())).forEach(v -> createRowForVertex(graph, v, row));
}
Also used : AtomicLong(java.util.concurrent.atomic.AtomicLong) BusinessServiceGraph(org.opennms.netmgt.bsm.service.model.graph.BusinessServiceGraph) BeanContainer(com.vaadin.data.util.BeanContainer) GraphVertex(org.opennms.netmgt.bsm.service.model.graph.GraphVertex) Map(java.util.Map) BusinessService(org.opennms.netmgt.bsm.service.model.BusinessService) Collections(java.util.Collections) Maps(com.google.common.collect.Maps) BusinessService(org.opennms.netmgt.bsm.service.model.BusinessService) AtomicLong(java.util.concurrent.atomic.AtomicLong)

Example 13 with GraphVertex

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

the class GraphAlgorithms method calculateImpact.

public static List<GraphVertex> calculateImpact(BusinessServiceGraph graph, GraphVertex vertex) {
    if (vertex == null) {
        return Collections.emptyList();
    }
    // Gather the list of parent vertices that are impacted by the current vertex
    final List<GraphVertex> impactedParentVertices = graph.getInEdges(vertex).stream().filter(e -> calculateImpacting(graph, graph.getOpposite(vertex, e)).contains(e)).map(e -> graph.getOpposite(vertex, e)).sorted().collect(Collectors.toList());
    // Recurse
    final List<GraphVertex> impacts = Lists.newArrayList(impactedParentVertices);
    for (GraphVertex impactedParentVertex : impactedParentVertices) {
        impacts.addAll(calculateImpact(graph, impactedParentVertex));
    }
    return impacts;
}
Also used : Set(java.util.Set) DefaultBusinessServiceStateMachine(org.opennms.netmgt.bsm.service.internal.DefaultBusinessServiceStateMachine) Collectors(java.util.stream.Collectors) BusinessServiceGraph(org.opennms.netmgt.bsm.service.model.graph.BusinessServiceGraph) List(java.util.List) Lists(com.google.common.collect.Lists) StatusWithIndex(org.opennms.netmgt.bsm.service.model.StatusWithIndex) Status(org.opennms.netmgt.bsm.service.model.Status) StatusWithIndices(org.opennms.netmgt.bsm.service.model.StatusWithIndices) GraphVertex(org.opennms.netmgt.bsm.service.model.graph.GraphVertex) Optional(java.util.Optional) GraphEdge(org.opennms.netmgt.bsm.service.model.graph.GraphEdge) Collections(java.util.Collections) GraphVertex(org.opennms.netmgt.bsm.service.model.graph.GraphVertex)

Example 14 with GraphVertex

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

the class GraphAlgorithms method calculateRootCause.

public static List<GraphVertex> calculateRootCause(BusinessServiceGraph graph, GraphVertex vertex) {
    if (vertex == null || vertex.getStatus().isLessThanOrEqual(Status.NORMAL)) {
        return Collections.emptyList();
    }
    // Gather the list of child vertices that impact the current vertex
    final List<GraphVertex> childVerticesWithImpact = calculateImpacting(graph, vertex).stream().map(e -> graph.getOpposite(vertex, e)).sorted().collect(Collectors.toList());
    // Recurse
    final List<GraphVertex> causes = Lists.newArrayList(childVerticesWithImpact);
    for (GraphVertex childVertexWithImpact : childVerticesWithImpact) {
        causes.addAll(calculateRootCause(graph, childVertexWithImpact));
    }
    return causes;
}
Also used : GraphVertex(org.opennms.netmgt.bsm.service.model.graph.GraphVertex)

Example 15 with GraphVertex

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

the class DefaultBusinessServiceStateMachine method explain.

@Override
public ThresholdResultExplanation explain(BusinessService businessService, Threshold threshold) {
    final GraphVertex vertex = getGraph().getVertexByBusinessServiceId(businessService.getId());
    // Calculate the weighed statuses from the child edges
    List<StatusWithIndex> statusesWithIndices = weighEdges(getGraph().getOutEdges(vertex));
    List<Status> statuses = statusesWithIndices.stream().map(StatusWithIndex::getStatus).collect(Collectors.toList());
    // Reduce
    Status reducedStatus = threshold.reduce(statusesWithIndices).orElse(new StatusWithIndices(MIN_SEVERITY, Collections.emptyList())).getStatus();
    ThresholdResultExplanation explanation = new ThresholdResultExplanation();
    explanation.setStatus(reducedStatus);
    explanation.setHitsByStatus(threshold.getHitsByStatus(statuses));
    explanation.setGraphEdges(getGraph().getOutEdges(vertex));
    explanation.setWeightStatuses(statuses);
    explanation.setFunction(threshold);
    Map<GraphEdge, GraphVertex> graphEdgeToGraphVertex = new HashMap<>();
    for (Edge eachEdge : businessService.getEdges()) {
        GraphVertex vertexForEdge = getGraph().getVertexByEdgeId(eachEdge.getId());
        GraphEdge graphEdge = getGraph().getGraphEdgeByEdgeId(eachEdge.getId());
        if (vertexForEdge != null && graphEdge != null) {
            graphEdgeToGraphVertex.put(graphEdge, vertexForEdge);
        }
    }
    explanation.setGraphEdgeToGraphVertexMapping(graphEdgeToGraphVertex);
    return explanation;
}
Also used : StatusWithIndex(org.opennms.netmgt.bsm.service.model.StatusWithIndex) Status(org.opennms.netmgt.bsm.service.model.Status) GraphVertex(org.opennms.netmgt.bsm.service.model.graph.GraphVertex) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) ThresholdResultExplanation(org.opennms.netmgt.bsm.service.model.functions.reduce.ThresholdResultExplanation) GraphEdge(org.opennms.netmgt.bsm.service.model.graph.GraphEdge) Edge(org.opennms.netmgt.bsm.service.model.edge.Edge) GraphEdge(org.opennms.netmgt.bsm.service.model.graph.GraphEdge) StatusWithIndices(org.opennms.netmgt.bsm.service.model.StatusWithIndices)

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