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