use of org.opennms.netmgt.model.BridgeMacLink in project opennms by OpenNMS.
the class BroadcastDomain method calculateBFT.
public List<BridgeMacLink> calculateBFT(Bridge bridge) {
Map<Integer, Set<String>> bft = new HashMap<Integer, Set<String>>();
Integer bridgeId = bridge.getId();
List<BridgeMacLink> links = new ArrayList<BridgeMacLink>();
OnmsNode node = new OnmsNode();
node.setId(bridgeId);
for (SharedSegment segment : getTopology()) {
Set<String> macs = segment.getMacsOnSegment();
if (macs == null || macs.isEmpty())
continue;
Integer bridgeport = goUp(segment, bridge, 0);
if (!bft.containsKey(bridgeport))
bft.put(bridgeport, new HashSet<String>());
bft.get(bridgeport).addAll(macs);
}
for (Integer bridgePort : bft.keySet()) {
for (String mac : bft.get(bridgePort)) {
BridgeMacLink link = new BridgeMacLink();
link.setNode(node);
link.setBridgePort(bridgePort);
link.setMacAddress(mac);
link.setBridgeDot1qTpFdbStatus(BridgeDot1qTpFdbStatus.DOT1D_TP_FDB_STATUS_LEARNED);
links.add(link);
}
}
return links;
}
use of org.opennms.netmgt.model.BridgeMacLink in project opennms by OpenNMS.
the class EnhancedLinkdServiceImpl method store.
@Override
public void store(int nodeId, List<BridgeMacLink> bft) {
Map<BridgeMacLinkHash, BridgeMacLink> effectiveBFT = new HashMap<BridgeMacLinkHash, BridgeMacLink>();
for (BridgeMacLink link : bft) {
OnmsNode node = new OnmsNode();
node.setId(nodeId);
link.setNode(node);
effectiveBFT.put(new BridgeMacLinkHash(link), link);
}
m_nodetoBroadcastDomainMap.put(nodeId, new ArrayList<BridgeMacLink>(effectiveBFT.values()));
}
use of org.opennms.netmgt.model.BridgeMacLink in project opennms by OpenNMS.
the class NodeDiscoveryBridgeTopology method getAllNodesWithUpdatedBFTOnDomain.
private Set<Integer> getAllNodesWithUpdatedBFTOnDomain(Set<String> incomingSet, Map<Integer, List<BridgeMacLink>> nodeBftMap) {
Set<Integer> nodeswithupdatedbftonbroadcastdomain = new HashSet<Integer>();
nodeswithupdatedbftonbroadcastdomain.add(getNodeId());
LOG.info("run: node: [{}], getting nodes with updated bft on broadcast domain. Start", getNodeId());
for (Integer curNodeId : nodeBftMap.keySet()) {
if (curNodeId.intValue() == getNodeId())
continue;
Set<String> retainedSet = new HashSet<String>();
for (BridgeMacLink link : nodeBftMap.get(curNodeId)) {
retainedSet.add(link.getMacAddress());
}
LOG.debug("run: node: [{}], parsing updated bft node: [{}], macs {}", getNodeId(), curNodeId, retainedSet);
retainedSet.retainAll(incomingSet);
LOG.debug("run: node: [{}], node: [{}] - common mac address set: {}", getNodeId(), curNodeId, retainedSet);
if (retainedSet.size() > 10 || retainedSet.size() >= incomingSet.size() * 0.1) {
nodeswithupdatedbftonbroadcastdomain.add(curNodeId);
LOG.debug("run: node: [{}], node: [{}] - put on same broadcast domain, common macs: {} ", getNodeId(), curNodeId, retainedSet);
}
}
LOG.info("run: node: [{}], getting nodes with updated bft on broadcast domain. End", getNodeId());
return nodeswithupdatedbftonbroadcastdomain;
}
use of org.opennms.netmgt.model.BridgeMacLink in project opennms by OpenNMS.
the class NodeDiscoveryBridgeTopology method loadFirstLevelSharedSegment.
private void loadFirstLevelSharedSegment(List<BridgeMacLink> electedRootBFT) {
Map<Integer, SharedSegment> rootleafs = new HashMap<Integer, SharedSegment>();
for (BridgeMacLink link : electedRootBFT) {
if (link.getBridgeDot1qTpFdbStatus() != BridgeDot1qTpFdbStatus.DOT1D_TP_FDB_STATUS_LEARNED)
continue;
if (rootleafs.containsKey(link.getBridgePort()))
rootleafs.get(link.getBridgePort()).add(link);
else
rootleafs.put(link.getBridgePort(), new SharedSegment(m_domain, link));
}
for (SharedSegment rootleaf : rootleafs.values()) {
LOG.debug("calculate: node [{}]: add shared segment[designated bridge:[{}]," + "designated port:{}, macs: {}]", getNodeId(), rootleaf.getDesignatedBridge(), rootleaf.getDesignatedPort(), rootleaf.getMacsOnSegment());
m_domain.add(rootleaf);
}
}
use of org.opennms.netmgt.model.BridgeMacLink in project opennms by OpenNMS.
the class NodeDiscoveryBridgeTopology method calculate.
protected void calculate() {
LOG.debug("calculate: node[{}]: Print Topology {}", getNodeId(), m_domain.printTopology());
LOG.info("calculate: node: [{}]: start: broadcast domain {} topology calculation.", getNodeId(), m_domain.getBridgeNodesOnDomain());
Bridge electedRoot = m_domain.electRootBridge();
if (electedRoot == null && m_domain.hasRootBridge()) {
LOG.debug("calculate: node [{}]: electRootBridge: mantaining old root bridge: {}", getNodeId(), m_domain.getRootBridgeId());
electedRoot = m_domain.getRootBridge();
} else if (electedRoot == null) {
// no spanning tree root?
// why I'm here?
// not root bridge defined (this mean no calculation yet done...
// so checking the best into not parsed
int size = 0;
Bridge rootBridge = null;
for (Bridge bridge : m_notYetParsedBFTMap.keySet()) {
LOG.debug("calculate: node [{}]: bridge [{}]: max bft size \"{}\" in topology", getNodeId(), bridge.getId(), m_notYetParsedBFTMap.get(bridge).size());
if (size < m_notYetParsedBFTMap.get(bridge).size()) {
rootBridge = bridge;
size = m_notYetParsedBFTMap.get(bridge).size();
}
}
if (rootBridge != null) {
LOG.debug("calculate: node [{}]: bridge [{}]: elected root with max bft size \"{}\" in topology", getNodeId(), rootBridge.getId(), size);
electedRoot = rootBridge;
}
}
if (electedRoot == null) {
electedRoot = m_domain.getBridges().iterator().next();
LOG.debug("calculate: node [{}]: electRootBridge: first root bridge: {}", getNodeId(), electedRoot.getId());
}
if (electedRoot == null || electedRoot.getId() == null) {
LOG.error("calculate: [{}]: electedRootBridge should not be null", getNodeId());
return;
}
List<BridgeMacLink> rootBft = m_notYetParsedBFTMap.remove(electedRoot);
if (m_domain.hasRootBridge() && m_domain.getRootBridge().getId() == electedRoot.getId() && rootBft == null) {
LOG.debug("calculate: node [{}]: elected root bridge: [{}], old root bridge. no updated bft", getNodeId(), electedRoot.getId());
rootBft = m_domain.calculateRootBFT();
} else if (m_domain.hasRootBridge() && m_domain.getRootBridge().getId() == electedRoot.getId() && rootBft != null) {
LOG.debug("calculate: node [{}]: elected root bridge: [{}], old root bridge. updated bft", getNodeId(), electedRoot.getId());
if (m_domain.getTopology().isEmpty()) {
LOG.debug("calculate: node [{}]: elected root bridge: [{}], clean topology found. Adding root shared segments", getNodeId(), electedRoot.getId());
loadFirstLevelSharedSegment(rootBft);
}
} else if (rootBft != null) {
LOG.debug("calculate: node [{}]: elected root bridge: [{}], new root. updated bft", getNodeId(), electedRoot.getId());
if (m_domain.getTopology().isEmpty()) {
LOG.debug("calculate: node [{}]: new elected root bridge: [{}], is the first bridge in topology. Adding root shared segments", getNodeId(), electedRoot.getId());
loadFirstLevelSharedSegment(rootBft);
electedRoot.setRootBridge(true);
electedRoot.setRootPort(null);
} else {
m_domain.clearTopologyForBridge(electedRoot.getId());
calculate(m_domain.getRootBridge(), m_domain.calculateRootBFT(), electedRoot, rootBft);
m_domain.hierarchySetUp(electedRoot);
}
} else {
LOG.debug("calculate: node [{}]: elected root bridge: [{}], is new root bridge with old bft", getNodeId(), electedRoot.getId());
m_domain.hierarchySetUp(electedRoot);
rootBft = m_domain.calculateRootBFT();
}
LOG.debug("calculate: node[{}]: Root Bridge [{}] elected.", getNodeId(), electedRoot.getId(), m_domain.printTopology());
for (Bridge xBridge : m_notYetParsedBFTMap.keySet()) {
m_domain.clearTopologyForBridge(xBridge.getId());
LOG.debug("calculate: node[{}]: Removed bridge: [{}].", getNodeId(), xBridge.getId());
}
LOG.debug("calculate: node[{}]: Print Topology {}", getNodeId(), m_domain.printTopology());
Set<Bridge> nodetobeparsed = new HashSet<Bridge>(m_notYetParsedBFTMap.keySet());
for (Bridge xBridge : nodetobeparsed) {
LOG.info("calculate: node: [{}]: bridge [{}]: calculate topology: start.", getNodeId(), xBridge.getId());
calculate(electedRoot, rootBft, xBridge, new ArrayList<BridgeMacLink>(m_notYetParsedBFTMap.remove(xBridge)));
LOG.info("calculate: node: [{}]: bridge [{}]: calculate topology: stop.", getNodeId(), xBridge.getId());
}
LOG.info("calculate: node: [{}]: stop: broadcast domain {} topology calculated.", getNodeId(), m_domain.getBridgeNodesOnDomain());
LOG.debug("calculate: node[{}]: Print Topology {}", getNodeId(), m_domain.printTopology());
}
Aggregations