Search in sources :

Example 21 with BroadcastDomain

use of org.opennms.netmgt.model.topology.BroadcastDomain in project opennms by OpenNMS.

the class EnhancedLinkd method deleteNode.

void deleteNode(int nodeid) {
    LOG.info("deleteNode: deleting LinkableNode for node {}", nodeid);
    Date now = new Date();
    BroadcastDomain domain = m_queryMgr.getBroadcastDomain(nodeid);
    LOG.debug("deleteNode: {}, found broadcast domain: nodes {}, macs {}", nodeid, domain.getBridgeNodesOnDomain(), domain.getMacsOnDomain());
    // must be calculated the topology for nodeid...
    domain.getLock(this);
    LOG.info("deleteNode: node: {}, start: merging topology for domain", nodeid);
    domain.clearTopologyForBridge(nodeid);
    LOG.info("deleteNode: node: {}, end: merging topology for domain", nodeid);
    LOG.info("deleteNode: node: {}, start: save topology for domain", nodeid);
    m_queryMgr.store(domain, now);
    LOG.info("deleteNode: node: {}, end: save topology for domain", nodeid);
    domain.removeBridge(nodeid);
    domain.releaseLock(this);
    Node node = removeNode(nodeid);
    if (node == null) {
        LOG.warn("deleteNode: node not found: {}", nodeid);
    } else {
        Collection<NodeDiscovery> collections = getSnmpCollections(node);
        LOG.info("deleteNode: fetched SnmpCollections from scratch, iterating over {} objects to delete", collections.size());
        for (NodeDiscovery collection : collections) {
            ReadyRunnable rr = getReadyRunnable(collection);
            if (rr == null) {
                LOG.warn("deleteNode: found null ReadyRunnable");
                continue;
            } else {
                rr.unschedule();
            }
        }
        NodeDiscovery topology = getNodeBridgeDiscoveryTopology(node);
        ReadyRunnable rr = getReadyRunnable(topology);
        if (rr == null) {
            LOG.warn("deleteNode: found null ReadyRunnable");
        } else {
            rr.unschedule();
        }
    }
    m_queryMgr.delete(nodeid);
    m_queryMgr.cleanBroadcastDomains();
}
Also used : BroadcastDomain(org.opennms.netmgt.model.topology.BroadcastDomain) ReadyRunnable(org.opennms.netmgt.enlinkd.scheduler.ReadyRunnable) Date(java.util.Date)

Example 22 with BroadcastDomain

use of org.opennms.netmgt.model.topology.BroadcastDomain in project opennms by OpenNMS.

the class EnhancedLinkdTopologyProvider method getBridgeLinks.

private void getBridgeLinks(Map<Integer, OnmsNode> nodemap, Map<Integer, List<OnmsSnmpInterface>> nodesnmpmap, Map<String, List<OnmsIpInterface>> macToIpMap, Map<Integer, List<OnmsIpInterface>> ipmap, Map<Integer, OnmsIpInterface> ipprimarymap) {
    for (BroadcastDomain domain : m_bridgeTopologyDao.getAllPersisted(m_bridgeBridgeLinkDao, m_bridgeMacLinkDao)) {
        LOG.info("loadtopology: parsing broadcast Domain: '{}', {}", domain);
        for (SharedSegment segment : domain.getTopology()) {
            if (segment.noMacsOnSegment() && segment.getBridgeBridgeLinks().size() == 1) {
                for (BridgeBridgeLink link : segment.getBridgeBridgeLinks()) {
                    Vertex source = getOrCreateVertex(nodemap.get(link.getNode().getId()), ipprimarymap.get(link.getNode().getId()));
                    Vertex target = getOrCreateVertex(nodemap.get(link.getDesignatedNode().getId()), ipprimarymap.get(link.getDesignatedNode().getId()));
                    BridgeLinkDetail detail = new BridgeLinkDetail(EnhancedLinkdTopologyProvider.TOPOLOGY_NAMESPACE_LINKD, source, link.getBridgePortIfIndex(), target, link.getDesignatedPortIfIndex(), link.getBridgePort(), link.getDesignatedPort(), link.getId(), link.getId());
                    LinkdEdge edge = connectVertices(detail, BRIDGE_EDGE_NAMESPACE);
                    edge.setTooltipText(getEdgeTooltipText(detail, nodesnmpmap));
                }
                continue;
            }
            if (segment.getBridgeMacLinks().size() == 1 && segment.getBridgeBridgeLinks().size() == 0) {
                for (BridgeMacLink sourcelink : segment.getBridgeMacLinks()) {
                    if (macToIpMap.containsKey(sourcelink.getMacAddress()) && macToIpMap.get(sourcelink.getMacAddress()).size() > 0) {
                        List<OnmsIpInterface> targetInterfaces = macToIpMap.get(sourcelink.getMacAddress());
                        OnmsIpInterface targetIp = targetInterfaces.get(0);
                        if (segment.getBridgeIdsOnSegment().contains(targetIp.getNode().getId()))
                            continue;
                        Vertex source = getOrCreateVertex(nodemap.get(sourcelink.getNode().getId()), ipprimarymap.get(sourcelink.getNode().getId()));
                        Vertex target = getOrCreateVertex(nodemap.get(targetIp.getNode().getId()), ipprimarymap.get(targetIp.getNode().getId()));
                        LinkdEdge edge = connectVertices(sourcelink, source, target, BRIDGE_EDGE_NAMESPACE);
                        edge.setTooltipText(getEdgeTooltipText(sourcelink, source, target, targetInterfaces, nodesnmpmap));
                    }
                }
                continue;
            }
            String cloudId = segment.getDesignatedBridge() + ":" + segment.getDesignatedPort();
            AbstractVertex cloudVertex = addVertex(cloudId, 0, 0);
            cloudVertex.setLabel("");
            cloudVertex.setIconKey("cloud");
            cloudVertex.setTooltipText("Shared Segment: " + nodemap.get(segment.getDesignatedBridge()).getLabel() + " port: " + segment.getDesignatedPort());
            addVertices(cloudVertex);
            LOG.info("loadtopology: adding cloud: id: '{}', {}", cloudId, cloudVertex.getTooltipText());
            for (BridgePort targetport : segment.getBridgePortsOnSegment()) {
                Vertex target = getOrCreateVertex(nodemap.get(targetport.getNode().getId()), ipprimarymap.get(targetport.getNode().getId()));
                LinkdEdge edge = connectVertices(targetport, cloudVertex, target, BRIDGE_EDGE_NAMESPACE);
                edge.setTooltipText(getEdgeTooltipText(targetport, target, nodesnmpmap));
            }
            for (String targetmac : segment.getMacsOnSegment()) {
                if (macToIpMap.containsKey(targetmac) && macToIpMap.get(targetmac).size() > 0) {
                    List<OnmsIpInterface> targetInterfaces = macToIpMap.get(targetmac);
                    OnmsIpInterface targetIp = targetInterfaces.get(0);
                    if (segment.getBridgeIdsOnSegment().contains(targetIp.getNode().getId()))
                        continue;
                    Vertex target = getOrCreateVertex(nodemap.get(targetIp.getNode().getId()), ipprimarymap.get(targetIp.getNode().getId()));
                    LinkdEdge edge = connectCloudMacVertices(targetmac, cloudVertex, target, BRIDGE_EDGE_NAMESPACE);
                    edge.setTooltipText(getEdgeTooltipText(targetmac, target, targetInterfaces));
                }
            }
        }
    }
}
Also used : AbstractVertex(org.opennms.features.topology.api.topo.AbstractVertex) Vertex(org.opennms.features.topology.api.topo.Vertex) AbstractVertex(org.opennms.features.topology.api.topo.AbstractVertex) BridgePort(org.opennms.netmgt.model.topology.BridgePort) OnmsIpInterface(org.opennms.netmgt.model.OnmsIpInterface) BroadcastDomain(org.opennms.netmgt.model.topology.BroadcastDomain) BridgeBridgeLink(org.opennms.netmgt.model.BridgeBridgeLink) SharedSegment(org.opennms.netmgt.model.topology.SharedSegment) BridgeMacLink(org.opennms.netmgt.model.BridgeMacLink)

Example 23 with BroadcastDomain

use of org.opennms.netmgt.model.topology.BroadcastDomain in project opennms by OpenNMS.

the class BridgeTopologyDaoInMemory method getAllPersisted.

@Override
public Set<BroadcastDomain> getAllPersisted(BridgeBridgeLinkDao bridgeBridgeLinkDao, BridgeMacLinkDao bridgeMacLinkDao) {
    List<SharedSegment> segments = new ArrayList<SharedSegment>();
    BRIDGELINK: for (BridgeBridgeLink link : bridgeBridgeLinkDao.findAll()) {
        for (SharedSegment segment : segments) {
            if (segment.containsPort(link.getNode().getId(), link.getBridgePort()) || segment.containsPort(link.getDesignatedNode().getId(), link.getDesignatedPort())) {
                segment.add(link);
                continue BRIDGELINK;
            }
        }
        SharedSegment segment = new SharedSegment();
        segment.add(link);
        segment.setDesignatedBridge(link.getDesignatedNode().getId());
        segments.add(segment);
    }
    MACLINK: for (BridgeMacLink link : bridgeMacLinkDao.findAll()) {
        link.setBridgeDot1qTpFdbStatus(BridgeDot1qTpFdbStatus.DOT1D_TP_FDB_STATUS_LEARNED);
        for (SharedSegment segment : segments) {
            if (segment.containsMac(link.getMacAddress()) || segment.containsPort(link.getNode().getId(), link.getBridgePort())) {
                segment.add(link);
                continue MACLINK;
            }
        }
        SharedSegment segment = new SharedSegment();
        segment.add(link);
        segment.setDesignatedBridge(link.getNode().getId());
        segments.add(segment);
    }
    Set<Set<Integer>> nodelinked = new HashSet<Set<Integer>>();
    SHARED: for (SharedSegment segment : segments) {
        Set<Integer> nodesOnSegment = new HashSet<Integer>(segment.getBridgeIdsOnSegment());
        for (Set<Integer> nodes : nodelinked) {
            for (Integer nodeid : nodesOnSegment) {
                if (nodes.contains(nodeid))
                    continue SHARED;
            }
        }
        nodelinked.add(getNodesOnDomainSet(segments, segment, new HashSet<SharedSegment>(), nodesOnSegment));
    }
    Set<BroadcastDomain> domains = new HashSet<BroadcastDomain>();
    for (Set<Integer> nodes : nodelinked) {
        BroadcastDomain domain = new BroadcastDomain();
        for (Integer nodeid : nodes) domain.addBridge(new Bridge(nodeid));
        domains.add(domain);
    }
    // Assign the segment to domain and add to single nodes
    for (SharedSegment segment : segments) {
        BroadcastDomain domain = null;
        for (BroadcastDomain cdomain : domains) {
            if (cdomain.containsAtleastOne(segment.getBridgeIdsOnSegment())) {
                domain = cdomain;
                break;
            }
        }
        if (domain == null) {
            domain = new BroadcastDomain();
            domains.add(domain);
        }
        domain.loadTopologyEntry(segment);
    }
    return domains;
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) ArrayList(java.util.ArrayList) BroadcastDomain(org.opennms.netmgt.model.topology.BroadcastDomain) BridgeBridgeLink(org.opennms.netmgt.model.BridgeBridgeLink) SharedSegment(org.opennms.netmgt.model.topology.SharedSegment) BridgeMacLink(org.opennms.netmgt.model.BridgeMacLink) Bridge(org.opennms.netmgt.model.topology.Bridge) HashSet(java.util.HashSet)

Example 24 with BroadcastDomain

use of org.opennms.netmgt.model.topology.BroadcastDomain in project opennms by OpenNMS.

the class BridgeTopologyDaoInMemory method clean.

@Override
public synchronized void clean() {
    Set<BroadcastDomain> empties = new HashSet<BroadcastDomain>();
    for (BroadcastDomain domain : m_domains) {
        if (domain.isEmpty())
            empties.add(domain);
    }
    m_domains.removeAll(empties);
}
Also used : BroadcastDomain(org.opennms.netmgt.model.topology.BroadcastDomain) HashSet(java.util.HashSet)

Example 25 with BroadcastDomain

use of org.opennms.netmgt.model.topology.BroadcastDomain in project opennms by OpenNMS.

the class BroadcastDomainTest method testCThenAB.

@Test
public void testCThenAB() {
    ABCTopology topology = new ABCTopology();
    BroadcastDomain domain = new BroadcastDomain();
    domain.addBridge(new Bridge(topology.nodeCId));
    domain.setBridgeElements(topology.elemlist);
    NodeDiscoveryBridgeTopology ndbt = new NodeDiscoveryBridgeTopology(linkd, new Node(topology.nodeAId, null, null, null, location));
    ndbt.setDomain(domain);
    ndbt.addUpdatedBFT(domain.getBridge(topology.nodeCId), topology.bftC);
    ndbt.calculate();
    domain.addBridge(new Bridge(topology.nodeAId));
    domain.addBridge(new Bridge(topology.nodeBId));
    domain.setBridgeElements(topology.elemlist);
    ndbt.addUpdatedBFT(domain.getBridge(topology.nodeAId), topology.bftA);
    ndbt.addUpdatedBFT(domain.getBridge(topology.nodeBId), topology.bftB);
    ndbt.calculate();
    topology.check(ndbt.getDomain());
}
Also used : BroadcastDomain(org.opennms.netmgt.model.topology.BroadcastDomain) Bridge(org.opennms.netmgt.model.topology.Bridge) Test(org.junit.Test)

Aggregations

BroadcastDomain (org.opennms.netmgt.model.topology.BroadcastDomain)46 Test (org.junit.Test)39 Bridge (org.opennms.netmgt.model.topology.Bridge)36 BridgeMacLink (org.opennms.netmgt.model.BridgeMacLink)9 SharedSegment (org.opennms.netmgt.model.topology.SharedSegment)7 BridgeBridgeLink (org.opennms.netmgt.model.BridgeBridgeLink)6 OnmsNode (org.opennms.netmgt.model.OnmsNode)4 HashSet (java.util.HashSet)3 NetworkBuilder (org.opennms.netmgt.model.NetworkBuilder)3 Nms10205bNetworkBuilder (org.opennms.netmgt.nb.Nms10205bNetworkBuilder)3 Nms17216NetworkBuilder (org.opennms.netmgt.nb.Nms17216NetworkBuilder)3 ArrayList (java.util.ArrayList)2 Date (java.util.Date)2 List (java.util.List)1 Set (java.util.Set)1 AbstractVertex (org.opennms.features.topology.api.topo.AbstractVertex)1 Vertex (org.opennms.features.topology.api.topo.Vertex)1 ReadyRunnable (org.opennms.netmgt.enlinkd.scheduler.ReadyRunnable)1 OnmsIpInterface (org.opennms.netmgt.model.OnmsIpInterface)1 OnmsMonitoringLocation (org.opennms.netmgt.model.monitoringLocations.OnmsMonitoringLocation)1