Search in sources :

Example 36 with BroadcastDomain

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

the class BroadcastDomainTest method testBThenCA.

@Test
public void testBThenCA() {
    ABCTopology topology = new ABCTopology();
    BroadcastDomain domain = new BroadcastDomain();
    domain.addBridge(new Bridge(topology.nodeBId));
    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.nodeBId), topology.bftB);
    ndbt.calculate();
    domain.addBridge(new Bridge(topology.nodeCId));
    domain.addBridge(new Bridge(topology.nodeAId));
    domain.setBridgeElements(topology.elemlist);
    ndbt.addUpdatedBFT(domain.getBridge(topology.nodeCId), topology.bftC);
    ndbt.addUpdatedBFT(domain.getBridge(topology.nodeAId), topology.bftA);
    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)

Example 37 with BroadcastDomain

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

the class BroadcastDomainTest method testFiveSwitchTopologyBCADE.

@Test
public void testFiveSwitchTopologyBCADE() {
    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 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 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 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();
    topology.check(domain);
}
Also used : BroadcastDomain(org.opennms.netmgt.model.topology.BroadcastDomain) Bridge(org.opennms.netmgt.model.topology.Bridge) Test(org.junit.Test)

Example 38 with BroadcastDomain

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

the class EnLinkdIT method testLoadFourLevelTopology.

/*
     * 1400=
     *      [1544, 1534]
     *             1534=
     *                   [1364, 405, 1310]}
     *                    1364=
     *                          [2965, 5022]
     */
@Test
public void testLoadFourLevelTopology() {
    final OnmsMonitoringLocation location = new OnmsMonitoringLocation(MonitoringLocationDao.DEFAULT_MONITORING_LOCATION_ID, MonitoringLocationDao.DEFAULT_MONITORING_LOCATION_ID);
    OnmsNode lnode1400 = new OnmsNode();
    lnode1400.setId(1400);
    lnode1400.setForeignSource("linkd");
    lnode1400.setForeignId("lnode1400");
    lnode1400.setLabel("lnode1400");
    lnode1400.setLocation(location);
    OnmsNode lnode1544 = new OnmsNode();
    lnode1544.setId(1544);
    lnode1544.setForeignSource("linkd");
    lnode1544.setForeignId("lnode1544");
    lnode1544.setLabel("lnode1544");
    lnode1544.setLocation(location);
    OnmsNode lnode1534 = new OnmsNode();
    lnode1534.setId(1534);
    lnode1534.setForeignSource("linkd");
    lnode1534.setForeignId("lnode1534");
    lnode1534.setLabel("lnode1534");
    lnode1534.setLocation(location);
    OnmsNode lnode1364 = new OnmsNode();
    lnode1364.setId(1364);
    lnode1364.setForeignSource("linkd");
    lnode1364.setForeignId("lnode1364");
    lnode1364.setLabel("lnode1364");
    lnode1364.setLocation(location);
    OnmsNode lnode1310 = new OnmsNode();
    lnode1310.setId(1310);
    lnode1310.setForeignSource("linkd");
    lnode1310.setForeignId("lnode1310");
    lnode1310.setLabel("lnode1310");
    lnode1310.setLocation(location);
    OnmsNode lnode405 = new OnmsNode();
    lnode405.setId(405);
    lnode405.setForeignSource("linkd");
    lnode405.setForeignId("lnode405");
    lnode405.setLabel("lnode405");
    lnode405.setLocation(location);
    OnmsNode lnode2965 = new OnmsNode();
    lnode2965.setId(2965);
    lnode2965.setForeignSource("linkd");
    lnode2965.setForeignId("lnode2965");
    lnode2965.setLabel("lnode2965");
    lnode2965.setLocation(location);
    OnmsNode lnode5022 = new OnmsNode();
    lnode5022.setId(5022);
    lnode5022.setForeignSource("linkd");
    lnode5022.setForeignId("lnode5022");
    lnode5022.setLabel("lnode5022");
    lnode5022.setLocation(location);
    m_nodeDao.save(lnode1400);
    m_nodeDao.save(lnode1544);
    m_nodeDao.save(lnode1534);
    m_nodeDao.save(lnode1364);
    m_nodeDao.save(lnode1310);
    m_nodeDao.save(lnode405);
    m_nodeDao.save(lnode2965);
    m_nodeDao.save(lnode5022);
    OnmsNode node1400 = m_nodeDao.findByForeignId("linkd", "lnode1400");
    OnmsNode node1544 = m_nodeDao.findByForeignId("linkd", "lnode1544");
    OnmsNode node1534 = m_nodeDao.findByForeignId("linkd", "lnode1534");
    OnmsNode node1364 = m_nodeDao.findByForeignId("linkd", "lnode1364");
    OnmsNode node1310 = m_nodeDao.findByForeignId("linkd", "lnode1310");
    OnmsNode node405 = m_nodeDao.findByForeignId("linkd", "lnode405");
    OnmsNode node2965 = m_nodeDao.findByForeignId("linkd", "lnode2965");
    OnmsNode node5022 = m_nodeDao.findByForeignId("linkd", "lnode5022");
    BridgeBridgeLink link7 = new BridgeBridgeLink();
    link7.setNode(node5022);
    link7.setBridgePort(4);
    link7.setDesignatedNode(node2965);
    link7.setDesignatedPort(5);
    link7.setBridgeBridgeLinkLastPollTime(link7.getBridgeBridgeLinkCreateTime());
    m_bridgeBridgeLinkDao.save(link7);
    m_bridgeBridgeLinkDao.flush();
    BridgeBridgeLink link1 = new BridgeBridgeLink();
    link1.setNode(node1544);
    link1.setBridgePort(15);
    link1.setDesignatedNode(node1400);
    link1.setDesignatedPort(1);
    link1.setBridgeBridgeLinkLastPollTime(link1.getBridgeBridgeLinkCreateTime());
    m_bridgeBridgeLinkDao.save(link1);
    m_bridgeBridgeLinkDao.flush();
    BridgeBridgeLink link3 = new BridgeBridgeLink();
    link3.setNode(node1310);
    link3.setBridgePort(1);
    link3.setDesignatedNode(node1534);
    link3.setDesignatedPort(1);
    link3.setBridgeBridgeLinkLastPollTime(link3.getBridgeBridgeLinkCreateTime());
    m_bridgeBridgeLinkDao.save(link3);
    m_bridgeBridgeLinkDao.flush();
    BridgeBridgeLink link4 = new BridgeBridgeLink();
    link4.setNode(node1364);
    link4.setBridgePort(24);
    link4.setDesignatedNode(node1534);
    link4.setDesignatedPort(4);
    link4.setBridgeBridgeLinkLastPollTime(link4.getBridgeBridgeLinkCreateTime());
    m_bridgeBridgeLinkDao.save(link4);
    m_bridgeBridgeLinkDao.flush();
    BridgeBridgeLink link2 = new BridgeBridgeLink();
    link2.setNode(node1534);
    link2.setBridgePort(11);
    link2.setDesignatedNode(node1400);
    link2.setDesignatedPort(11);
    link2.setBridgeBridgeLinkLastPollTime(link2.getBridgeBridgeLinkCreateTime());
    m_bridgeBridgeLinkDao.save(link2);
    m_bridgeBridgeLinkDao.flush();
    BridgeBridgeLink link6 = new BridgeBridgeLink();
    link6.setNode(node2965);
    link6.setBridgePort(2);
    link6.setDesignatedNode(node1364);
    link6.setDesignatedPort(5);
    link6.setBridgeBridgeLinkLastPollTime(link6.getBridgeBridgeLinkCreateTime());
    m_bridgeBridgeLinkDao.save(link6);
    m_bridgeBridgeLinkDao.flush();
    BridgeBridgeLink link5 = new BridgeBridgeLink();
    link5.setNode(node405);
    link5.setBridgePort(1);
    link5.setDesignatedNode(node1534);
    link5.setDesignatedPort(1);
    link5.setBridgeBridgeLinkLastPollTime(link5.getBridgeBridgeLinkCreateTime());
    m_bridgeBridgeLinkDao.save(link5);
    m_bridgeBridgeLinkDao.flush();
    assertEquals(0, m_bridgeMacLinkDao.countAll());
    assertEquals(7, m_bridgeBridgeLinkDao.countAll());
    assertNotNull(m_bridgeTopologyDao);
    m_linkd.getQueryManager().loadBridgeTopology();
    assertEquals(1, m_linkd.getQueryManager().getAllBroadcastDomains().size());
    BroadcastDomain fourlevelDomain = m_linkd.getQueryManager().getAllBroadcastDomains().iterator().next();
    assertEquals(8, fourlevelDomain.getBridgeNodesOnDomain().size());
    System.err.println(fourlevelDomain.printTopology());
}
Also used : OnmsNode(org.opennms.netmgt.model.OnmsNode) BroadcastDomain(org.opennms.netmgt.model.topology.BroadcastDomain) BridgeBridgeLink(org.opennms.netmgt.model.BridgeBridgeLink) OnmsMonitoringLocation(org.opennms.netmgt.model.monitoringLocations.OnmsMonitoringLocation) Test(org.junit.Test)

Example 39 with BroadcastDomain

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

the class EnLinkdIT method testDeleteBridgeC.

@Test
public void testDeleteBridgeC() {
    ABCTopology topology = new ABCTopology();
    NetworkBuilder nb = new NetworkBuilder();
    nb.addNode("nodeA").setForeignSource("linkd").setForeignId("nodeA").setSysObjectId("0.0").setSysName("nodeA").setType(NodeType.ACTIVE);
    nb.addInterface("10.0.1.1").setIsSnmpPrimary("P").setIsManaged("M");
    m_nodeDao.save(nb.getCurrentNode());
    nb.addNode("nodeB").setForeignSource("linkd").setForeignId("nodeB").setSysObjectId("0.0").setSysName("nodeB").setType(NodeType.ACTIVE);
    nb.addInterface("10.0.1.2").setIsSnmpPrimary("P").setIsManaged("M");
    m_nodeDao.save(nb.getCurrentNode());
    nb.addNode("nodeC").setForeignSource("linkd").setForeignId("nodeC").setSysObjectId("0.0").setSysName("nodeC").setType(NodeType.ACTIVE);
    nb.addInterface("10.0.1.3").setIsSnmpPrimary("P").setIsManaged("M");
    m_nodeDao.save(nb.getCurrentNode());
    OnmsNode nodeA = m_nodeDao.findByForeignId("linkd", "nodeA");
    OnmsNode nodeB = m_nodeDao.findByForeignId("linkd", "nodeB");
    OnmsNode nodeC = m_nodeDao.findByForeignId("linkd", "nodeC");
    topology.nodeAId = nodeA.getId();
    topology.nodeBId = nodeB.getId();
    topology.nodeCId = nodeC.getId();
    topology.nodeA = nodeA;
    topology.nodeB = nodeB;
    topology.nodeC = nodeC;
    BridgeBridgeLink ablink = new BridgeBridgeLink();
    ablink.setNode(nodeA);
    ablink.setBridgePort(topology.portAB);
    ablink.setDesignatedNode(nodeB);
    ablink.setDesignatedPort(topology.portBA);
    ablink.setBridgeBridgeLinkLastPollTime(ablink.getBridgeBridgeLinkCreateTime());
    m_bridgeBridgeLinkDao.save(ablink);
    BridgeBridgeLink bclink = new BridgeBridgeLink();
    bclink.setNode(nodeC);
    bclink.setBridgePort(topology.portCB);
    bclink.setDesignatedNode(nodeB);
    bclink.setDesignatedPort(topology.portBC);
    bclink.setBridgeBridgeLinkLastPollTime(ablink.getBridgeBridgeLinkCreateTime());
    m_bridgeBridgeLinkDao.save(bclink);
    BridgeMacLink mac1 = new BridgeMacLink();
    mac1.setNode(nodeA);
    mac1.setBridgePort(topology.portA);
    mac1.setMacAddress(topology.mac1);
    mac1.setBridgeMacLinkLastPollTime(mac1.getBridgeMacLinkCreateTime());
    m_bridgeMacLinkDao.save(mac1);
    BridgeMacLink mac2 = new BridgeMacLink();
    mac2.setNode(nodeB);
    mac2.setBridgePort(topology.portB);
    mac2.setMacAddress(topology.mac2);
    mac2.setBridgeMacLinkLastPollTime(mac2.getBridgeMacLinkCreateTime());
    m_bridgeMacLinkDao.save(mac2);
    BridgeMacLink mac3 = new BridgeMacLink();
    mac3.setNode(nodeC);
    mac3.setBridgePort(topology.portC);
    mac3.setMacAddress(topology.mac3);
    mac3.setBridgeMacLinkLastPollTime(mac3.getBridgeMacLinkCreateTime());
    m_bridgeMacLinkDao.save(mac3);
    m_bridgeMacLinkDao.flush();
    m_bridgeBridgeLinkDao.flush();
    assertEquals(3, m_bridgeMacLinkDao.countAll());
    assertEquals(2, m_bridgeBridgeLinkDao.countAll());
    assertNotNull(m_bridgeTopologyDao);
    m_linkd.getQueryManager().loadBridgeTopology();
    assertEquals(1, m_linkd.getQueryManager().getAllBroadcastDomains().size());
    BroadcastDomain nodeAbd = m_linkd.getQueryManager().getBroadcastDomain(nodeA.getId().intValue());
    assertNotNull(nodeAbd);
    BroadcastDomain nodeBbd = m_linkd.getQueryManager().getBroadcastDomain(nodeB.getId().intValue());
    assertNotNull(nodeBbd);
    assertEquals(nodeAbd, nodeBbd);
    BroadcastDomain nodeCbd = m_linkd.getQueryManager().getBroadcastDomain(nodeC.getId().intValue());
    assertNotNull(nodeCbd);
    assertEquals(nodeAbd, nodeCbd);
    assertTrue(nodeAbd.hasRootBridge());
    assertEquals(nodeAbd.getRootBridgeId().intValue(), nodeB.getId().intValue());
    assertTrue(nodeAbd.containBridgeId(nodeA.getId()));
    assertTrue(nodeAbd.containBridgeId(nodeB.getId()));
    assertTrue(nodeAbd.containBridgeId(nodeC.getId()));
    nodeAbd.hierarchySetUp(nodeAbd.getBridge(nodeA.getId()));
    assertNotNull(nodeAbd.getRootBridgeId());
    topology.check(nodeAbd);
    m_linkd.deleteNode(nodeC.getId());
    assertEquals(1, m_linkd.getQueryManager().getAllBroadcastDomains().size());
    BroadcastDomain domain = m_linkd.getQueryManager().getAllBroadcastDomains().iterator().next();
    topology.checkAB(domain);
}
Also used : Nms10205bNetworkBuilder(org.opennms.netmgt.nb.Nms10205bNetworkBuilder) Nms17216NetworkBuilder(org.opennms.netmgt.nb.Nms17216NetworkBuilder) NetworkBuilder(org.opennms.netmgt.model.NetworkBuilder) OnmsNode(org.opennms.netmgt.model.OnmsNode) BroadcastDomain(org.opennms.netmgt.model.topology.BroadcastDomain) BridgeBridgeLink(org.opennms.netmgt.model.BridgeBridgeLink) BridgeMacLink(org.opennms.netmgt.model.BridgeMacLink) Test(org.junit.Test)

Example 40 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)

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