Search in sources :

Example 46 with BroadcastDomain

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

the class EnhancedLinkdServiceImpl method delete.

@Override
public void delete(int nodeId) {
    m_lldpElementDao.deleteByNodeId(nodeId);
    m_lldpLinkDao.deleteByNodeId(nodeId);
    m_lldpElementDao.flush();
    m_lldpLinkDao.flush();
    m_cdpElementDao.deleteByNodeId(nodeId);
    m_cdpLinkDao.deleteByNodeId(nodeId);
    m_cdpElementDao.flush();
    m_cdpLinkDao.flush();
    m_ospfElementDao.deleteByNodeId(nodeId);
    m_ospfLinkDao.deleteByNodeId(nodeId);
    m_ospfElementDao.flush();
    m_ospfLinkDao.flush();
    m_isisElementDao.deleteByNodeId(nodeId);
    m_isisLinkDao.deleteByNodeId(nodeId);
    m_isisElementDao.flush();
    m_isisLinkDao.flush();
    m_ipNetToMediaDao.deleteBySourceNodeId(nodeId);
    m_ipNetToMediaDao.flush();
    m_bridgeElementDao.deleteByNodeId(nodeId);
    m_bridgeElementDao.flush();
    m_bridgeTopologyDao.delete(nodeId);
    m_bridgeStpLinkDao.deleteByNodeId(nodeId);
    m_bridgeStpLinkDao.flush();
    synchronized (m_domains) {
        for (BroadcastDomain domain : m_domains) {
            synchronized (domain) {
                if (domain.containBridgeId(nodeId)) {
                    domain.removeBridge(nodeId);
                    break;
                }
            }
        }
    }
}
Also used : BroadcastDomain(org.opennms.netmgt.model.topology.BroadcastDomain)

Example 47 with BroadcastDomain

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

the class NodeDiscoveryBridgeTopology method run.

@Override
public void run() {
    if (!m_linkd.getQueryManager().hasUpdatedBft(getNodeId())) {
        LOG.info("run: node: [{}], no bft.Exiting Bridge Topology Discovery", getNodeId());
        return;
    }
    List<BridgeMacLink> links = m_linkd.getQueryManager().getBridgeTopologyUpdateBFT(getNodeId());
    if (links == null || links.size() == 0) {
        LOG.info("run: node: [{}]. no updates macs found.", getNodeId());
        return;
    }
    Date now = new Date();
    Set<String> incomingSet = new HashSet<String>();
    synchronized (links) {
        for (BridgeMacLink link : links) {
            incomingSet.add(link.getMacAddress());
        }
    }
    LOG.debug("run: node: [{}]. macs found: {}", getNodeId(), incomingSet);
    LOG.info("run: node: [{}], getting broadcast domain. Start", getNodeId());
    for (BroadcastDomain domain : m_linkd.getQueryManager().getAllBroadcastDomains()) {
        LOG.debug("run: node: [{}], parsing domain with nodes: {}, macs: {}", getNodeId(), domain.getBridgeNodesOnDomain(), domain.getMacsOnDomain());
        Set<String> retainedSet = new HashSet<String>(domain.getMacsOnDomain());
        retainedSet.retainAll(incomingSet);
        LOG.debug("run: node: [{}], retained: {}", getNodeId(), retainedSet);
        // should contain at list 5 or 10% of the all size
        if (retainedSet.size() > DOMAIN_MATCH_MIN_SIZE || retainedSet.size() >= incomingSet.size() * DOMAIN_MATCH_MIN_RATIO) {
            if (LOG.isDebugEnabled()) {
                LOG.debug("run: node: [{}], domain {} found!", getNodeId(), domain.getBridgeNodesOnDomain());
            }
            m_domain = domain;
        // TODO: We should find the *best* domain, instead of using the last match
        }
    }
    if (m_domain == null) {
        LOG.debug("run: node: [{}] Creating a new Domain", getNodeId());
        m_domain = new BroadcastDomain();
        m_linkd.getQueryManager().save(m_domain);
    } else if (!m_domain.hasRootBridge()) {
        LOG.debug("run: node: [{}] Domain without root, clearing topology", getNodeId());
        m_domain.clearTopology();
    }
    LOG.info("run: node: [{}], getting broadcast domain. End", getNodeId());
    Map<Integer, List<BridgeMacLink>> nodeBftMap = m_linkd.getQueryManager().getUpdateBftMap();
    Set<Integer> nodeswithupdatedbftonbroadcastdomain = getAllNodesWithUpdatedBFTOnDomain(incomingSet, nodeBftMap);
    LOG.info("run: node: [{}], clean broadcast domains. Start", getNodeId());
    boolean clean = false;
    for (BroadcastDomain domain : m_linkd.getQueryManager().getAllBroadcastDomains()) {
        if (m_domain == domain)
            continue;
        if (LOG.isDebugEnabled()) {
            LOG.debug("run: node [{}]: cleaning broadcast domain {}.", getNodeId(), domain.getBridgeNodesOnDomain());
        }
        for (Integer curNodeId : nodeswithupdatedbftonbroadcastdomain) {
            if (domain.containBridgeId(curNodeId)) {
                if (LOG.isDebugEnabled()) {
                    LOG.debug("run: node [{}]: node [{}]: removing from broadcast domain {}!", getNodeId(), curNodeId, domain.getBridgeNodesOnDomain());
                }
                synchronized (domain) {
                    domain.clearTopologyForBridge(curNodeId);
                    domain.removeBridge(curNodeId);
                    m_linkd.getQueryManager().store(domain);
                    m_linkd.getQueryManager().reconcileBridgeTopology(domain, now);
                }
                clean = true;
            }
        }
    }
    if (clean) {
        m_linkd.getQueryManager().cleanBroadcastDomains();
    }
    LOG.info("run: node: [{}], clean broadcast domains. End", getNodeId());
    synchronized (m_domain) {
        m_notYetParsedBFTMap = new HashMap<Bridge, List<BridgeMacLink>>();
        for (Integer nodeid : nodeswithupdatedbftonbroadcastdomain) {
            sendStartEvent(nodeid);
            m_domain.addBridge(new Bridge(nodeid));
            LOG.debug("run: node: [{}], getting update bft for node [{}] on domain", getNodeId(), nodeid);
            List<BridgeMacLink> bft = m_linkd.getQueryManager().useBridgeTopologyUpdateBFT(nodeid);
            if (bft == null || bft.isEmpty()) {
                LOG.debug("run: node: [{}], no update bft for node [{}] on domain", getNodeId(), nodeid);
                continue;
            }
            m_notYetParsedBFTMap.put(m_domain.getBridge(nodeid), bft);
        }
        Set<Integer> nodetoberemovedondomain = new HashSet<Integer>();
        synchronized (nodeBftMap) {
            for (Integer nodeid : nodeBftMap.keySet()) {
                if (nodeswithupdatedbftonbroadcastdomain.contains(nodeid))
                    continue;
                LOG.info("run: node [{}]: bridge [{}] with updated bft. Not even more on broadcast domain {}: clear topology.", getNodeId(), nodeid, m_domain.getBridgeNodesOnDomain());
                nodetoberemovedondomain.add(nodeid);
            }
        }
        for (Integer nodeid : nodetoberemovedondomain) {
            m_domain.clearTopologyForBridge(nodeid);
            m_domain.removeBridge(nodeid);
        }
        m_linkd.getQueryManager().cleanBroadcastDomains();
        m_domain.setBridgeElements(m_linkd.getQueryManager().getBridgeElements(m_domain.getBridgeNodesOnDomain()));
        if (m_notYetParsedBFTMap.isEmpty()) {
            LOG.info("run: node: [{}], broadcast domain has no topology updates. No more action is needed.", getNodeId());
        } else {
            calculate();
        }
        LOG.info("run: node: [{}], saving Topology.", getNodeId());
        m_linkd.getQueryManager().store(m_domain);
        m_linkd.getQueryManager().reconcileBridgeTopology(m_domain, now);
        LOG.info("run: node: [{}], saved Topology.", getNodeId());
        for (Integer curNode : nodeswithupdatedbftonbroadcastdomain) {
            sendCompletedEvent(curNode);
        }
    }
}
Also used : Date(java.util.Date) BroadcastDomain(org.opennms.netmgt.model.topology.BroadcastDomain) ArrayList(java.util.ArrayList) List(java.util.List) BridgeMacLink(org.opennms.netmgt.model.BridgeMacLink) Bridge(org.opennms.netmgt.model.topology.Bridge) HashSet(java.util.HashSet)

Example 48 with BroadcastDomain

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

the class BroadcastDomainTest method testFiveSwitchTopologyEDCAB.

@Test
public void testFiveSwitchTopologyEDCAB() {
    FiveSwitchTopology topology = new FiveSwitchTopology();
    BroadcastDomain domain = new BroadcastDomain();
    domain.addBridge(new Bridge(topology.nodeAId));
    domain.addBridge(new Bridge(topology.nodeBId));
    domain.addBridge(new Bridge(topology.nodeCId));
    domain.addBridge(new Bridge(topology.nodeDId));
    domain.addBridge(new Bridge(topology.nodeEId));
    domain.setBridgeElements(topology.elemlist);
    NodeDiscoveryBridgeTopology ndbtE = new NodeDiscoveryBridgeTopology(linkd, new Node(topology.nodeEId, null, null, null, location));
    ndbtE.setDomain(domain);
    ndbtE.addUpdatedBFT(domain.getBridge(topology.nodeEId), topology.bftE);
    ndbtE.calculate();
    NodeDiscoveryBridgeTopology ndbtD = new NodeDiscoveryBridgeTopology(linkd, new Node(topology.nodeDId, null, null, null, location));
    ndbtD.setDomain(domain);
    ndbtD.addUpdatedBFT(domain.getBridge(topology.nodeDId), topology.bftD);
    ndbtD.calculate();
    NodeDiscoveryBridgeTopology ndbtC = new NodeDiscoveryBridgeTopology(linkd, new Node(topology.nodeCId, null, null, null, location));
    ndbtC.setDomain(domain);
    ndbtC.addUpdatedBFT(domain.getBridge(topology.nodeCId), topology.bftC);
    ndbtC.calculate();
    NodeDiscoveryBridgeTopology ndbtA = new NodeDiscoveryBridgeTopology(linkd, new Node(topology.nodeAId, null, null, null, location));
    ndbtA.setDomain(domain);
    ndbtA.addUpdatedBFT(domain.getBridge(topology.nodeAId), topology.bftA);
    ndbtA.calculate();
    NodeDiscoveryBridgeTopology ndbtB = new NodeDiscoveryBridgeTopology(linkd, new Node(topology.nodeBId, null, null, null, location));
    ndbtB.setDomain(domain);
    ndbtB.addUpdatedBFT(domain.getBridge(topology.nodeBId), topology.bftB);
    ndbtB.calculate();
    Bridge bridgeB = domain.getBridge(topology.nodeBId);
    domain.hierarchySetUp(bridgeB);
    topology.check(domain);
}
Also used : BroadcastDomain(org.opennms.netmgt.model.topology.BroadcastDomain) Bridge(org.opennms.netmgt.model.topology.Bridge) Test(org.junit.Test)

Example 49 with BroadcastDomain

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

the class BroadcastDomainTest method testFiveSwitchTopologyBEDCABEDAC.

@Test
public void testFiveSwitchTopologyBEDCABEDAC() {
    FiveSwitchTopology topology = new FiveSwitchTopology();
    BroadcastDomain domain = new BroadcastDomain();
    domain.addBridge(new Bridge(topology.nodeAId));
    domain.addBridge(new Bridge(topology.nodeBId));
    domain.addBridge(new Bridge(topology.nodeCId));
    domain.addBridge(new Bridge(topology.nodeDId));
    domain.addBridge(new Bridge(topology.nodeEId));
    domain.setBridgeElements(topology.elemlist);
    NodeDiscoveryBridgeTopology ndbtB = new NodeDiscoveryBridgeTopology(linkd, new Node(topology.nodeBId, null, null, null, location));
    ndbtB.setDomain(domain);
    ndbtB.addUpdatedBFT(domain.getBridge(topology.nodeBId), topology.bftB);
    ndbtB.calculate();
    NodeDiscoveryBridgeTopology ndbtE = new NodeDiscoveryBridgeTopology(linkd, new Node(topology.nodeEId, null, null, null, location));
    ndbtE.setDomain(domain);
    ndbtE.addUpdatedBFT(domain.getBridge(topology.nodeEId), topology.bftE);
    ndbtE.calculate();
    NodeDiscoveryBridgeTopology ndbtD = new NodeDiscoveryBridgeTopology(linkd, new Node(topology.nodeDId, null, null, null, location));
    ndbtD.setDomain(domain);
    ndbtD.addUpdatedBFT(domain.getBridge(topology.nodeDId), topology.bftD);
    ndbtD.calculate();
    NodeDiscoveryBridgeTopology ndbtC = new NodeDiscoveryBridgeTopology(linkd, new Node(topology.nodeCId, null, null, null, location));
    ndbtC.setDomain(domain);
    ndbtC.addUpdatedBFT(domain.getBridge(topology.nodeCId), topology.bftC);
    ndbtC.calculate();
    NodeDiscoveryBridgeTopology ndbtA = new NodeDiscoveryBridgeTopology(linkd, new Node(topology.nodeAId, null, null, null, location));
    ndbtA.setDomain(domain);
    ndbtA.addUpdatedBFT(domain.getBridge(topology.nodeAId), topology.bftA);
    ndbtA.calculate();
    topology.check(domain);
    ndbtB.addUpdatedBFT(domain.getBridge(topology.nodeBId), topology.bftB);
    ndbtB.calculate();
    topology.check(domain);
    ndbtE.addUpdatedBFT(domain.getBridge(topology.nodeEId), topology.bftE);
    ndbtE.calculate();
    topology.check(domain);
    ndbtD.addUpdatedBFT(domain.getBridge(topology.nodeDId), topology.bftD);
    ndbtD.calculate();
    topology.check(domain);
    ndbtA.addUpdatedBFT(domain.getBridge(topology.nodeAId), topology.bftA);
    ndbtA.calculate();
    topology.check(domain);
    ndbtC.addUpdatedBFT(domain.getBridge(topology.nodeCId), topology.bftC);
    ndbtC.calculate();
    topology.check(domain);
}
Also used : BroadcastDomain(org.opennms.netmgt.model.topology.BroadcastDomain) Bridge(org.opennms.netmgt.model.topology.Bridge) Test(org.junit.Test)

Example 50 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();
    domain.hierarchySetUp(domain.getBridge(topology.nodeAId));
    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)56 Test (org.junit.Test)48 Bridge (org.opennms.netmgt.model.topology.Bridge)45 BridgeMacLink (org.opennms.netmgt.model.BridgeMacLink)10 BridgeBridgeLink (org.opennms.netmgt.model.BridgeBridgeLink)8 SharedSegment (org.opennms.netmgt.model.topology.SharedSegment)8 OnmsNode (org.opennms.netmgt.model.OnmsNode)5 HashSet (java.util.HashSet)4 ArrayList (java.util.ArrayList)3 NetworkBuilder (org.opennms.netmgt.model.NetworkBuilder)3 Nms10205bNetworkBuilder (org.opennms.netmgt.nb.Nms10205bNetworkBuilder)3 Nms17216NetworkBuilder (org.opennms.netmgt.nb.Nms17216NetworkBuilder)3 List (java.util.List)2 Set (java.util.Set)2 OnmsMonitoringLocation (org.opennms.netmgt.model.monitoringLocations.OnmsMonitoringLocation)2 Date (java.util.Date)1 HashMap (java.util.HashMap)1 CopyOnWriteArraySet (java.util.concurrent.CopyOnWriteArraySet)1 AbstractVertex (org.opennms.features.topology.api.topo.AbstractVertex)1 Vertex (org.opennms.features.topology.api.topo.Vertex)1