public BusinessServiceEdge(GraphEdge graphEdge, AbstractBusinessServiceVertex source, AbstractBusinessServiceVertex target) { super(BusinessServicesTopologyProvider.TOPOLOGY_NAMESPACE, String.format("connection:%s:%s", source.getId(), target.getId()), source, target); this.source = source; this.target = target; this.mapFunction = graphEdge.getMapFunction(); this.weight = graphEdge.getWeight(); setTooltipText(String.format("Map function: %s, Weight: %s", graphEdge.getMapFunction().getClass().getSimpleName(), graphEdge.getWeight())); }
private String getLabel(GraphEdge graphEdge, ThresholdResultExplanation explanation) { if (!Strings.isNullOrEmpty(graphEdge.getFriendlyName())) { return graphEdge.getFriendlyName(); } return GraphVertexToTopologyVertexConverter.createTopologyVertex(explanation.getGraphVertex(graphEdge)).getLabel(); }
if (newStatus.isGreaterThan(MIN_SEVERITY)) { mappedStatus = edge.getMapFunction().map(newStatus).orElse(MIN_SEVERITY); } else { mappedStatus = newStatus; if (mappedStatus.equals(edge.getStatus())) { edge.setStatus(mappedStatus); updatedEges.add(edge);
public double getWeightFactor(GraphEdge eachEdge) { int weightSum = getWeightSum(); return (double) eachEdge.getWeight() / (double) weightSum; }
public double getStatusFactor(GraphEdge eachEdge, Status status) { if (eachEdge.getStatus().isGreaterThanOrEqual(status)) { return getWeightFactor(eachEdge); } return 0; }
@Override public String transform(GraphEdge edge) { return String.format("%s", edge.getMapFunction().getClass().getSimpleName()); } });
public double getWeightFactor(GraphEdge eachEdge) { int weightSum = getWeightSum(); return (double) eachEdge.getWeight() / (double) weightSum; }
public double getStatusFactor(GraphEdge eachEdge, Status status) { if (eachEdge.getStatus().isGreaterThanOrEqual(status)) { return getWeightFactor(eachEdge); } return 0; }
/** * Apply the edges weights to the associated statuses set in the map, * ignoring the actual status stored in the edge. Can be used for simulations * without needing to change the actual edge's status. * * @param edgesWithStatus * @return */ public static List<StatusWithIndex> weighStatuses(Map<GraphEdge, Status> edgesWithStatus) { // Find the greatest common divisor of all the weights int gcd = edgesWithStatus.keySet().stream() .map(GraphEdge::getWeight) .reduce((a,b) -> BigInteger.valueOf(a).gcd(BigInteger.valueOf(b)).intValue()) .orElse(1); // Multiply the statuses based on their relative weight List<StatusWithIndex> statuses = Lists.newArrayList(); int k = 0; for (Entry<GraphEdge, Status> entry : edgesWithStatus.entrySet()) { int relativeWeight = Math.floorDiv(entry.getKey().getWeight(), gcd); for (int i = 0; i < relativeWeight; i++) { statuses.add(new StatusWithIndex(entry.getValue(), k)); } k++; } return statuses; }
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; }