Skip to content
Snippets Groups Projects
Commit 2a796537 authored by Srinivasan Ramasubramanian's avatar Srinivasan Ramasubramanian
Browse files

New method to identify if a port is broadcastDomainPort or not.

parent e8894cbf
No related branches found
No related tags found
No related merge requests found
package net.floodlightcontroller.topology;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import org.openflow.util.HexString;
/**
*
* @author Srinivasan Ramasubramanian, Big Switch Networks
*
*/
public class BroadcastDomain {
private long id;
private Set<Long> clusters;
private Map<Long, Set<NodePortTuple>> ports;
public BroadcastDomain() {
id = 0;
clusters = new HashSet<Long>();
ports = new HashMap<Long, Set<NodePortTuple>>();
}
@Override
public int hashCode() {
return (int)(id ^ id>>>32);
}
@Override
public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
BroadcastDomain other = (BroadcastDomain) obj;
return (other.id == this.id);
}
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public Set<Long> getClusterIds() {
return clusters;
}
public Map<Long, Set<NodePortTuple>> getClusterPortMap() {
return ports;
}
public Set<NodePortTuple> getPortsInCluster(long c) {
return ports.get(c);
}
public Set<NodePortTuple> getPorts() {
if (clusters == null) return null;
Set<NodePortTuple> result = new HashSet<NodePortTuple>();
for(long c: clusters) {
if (ports.get(c) != null) {
result.addAll(ports.get(c));
}
}
if (result.isEmpty()) return null;
return result;
}
public void add(NodePortTuple npt, Long cid) {
clusters.add(cid);
Set<NodePortTuple> p = ports.get(cid);
if (p == null) {
p = new HashSet<NodePortTuple>();
ports.put(cid, p);
}
p.add(npt);
}
public String toString() {
StringBuffer sb = new StringBuffer("[BroadcastDomain:");;
for(Long c: clusters) {
for(NodePortTuple npt: ports.get(c)) {
String str = HexString.toHexString(npt.getNodeId());
sb.append("[");
sb.append(c);
sb.append(",");
sb.append(str);
sb.append(",");
sb.append(npt.getPortId());
sb.append("]");
}
}
sb.append("]");
return sb.toString();
}
}
......@@ -119,7 +119,7 @@ public class TopologyInstance {
for (short p: switchPorts.get(s)) {
NodePortTuple np = new NodePortTuple(s, p);
if (switchPortLinks.get(np) == null) continue;
if (broadcastDomainPorts.contains(np)) continue;
if (isBroadcastDomainPort(np)) continue;
for(Link l: switchPortLinks.get(np)) {
if (isBroadcastDomainLink(l)) continue;
Cluster c1 = switchClusterMap.get(l.getSrc());
......@@ -283,16 +283,6 @@ public class TopologyInstance {
return currIndex;
}
/*
public void addLinkToNodePair(Link l, long n1, long n2){
NodePair nodepair = new NodePair(n1, n2);
if (!links.containsKey(nodepair)) {
links.put(nodepair, new HashSet<Link>());
}
links.get(nodepair).add(l);
}
*/
public boolean isBroadcastDomainLink(Link l) {
NodePortTuple n1 = new NodePortTuple(l.getSrc(), l.getSrcPort());
NodePortTuple n2 = new NodePortTuple(l.getDst(), l.getDstPort());
......@@ -300,7 +290,9 @@ public class TopologyInstance {
broadcastDomainPorts.contains(n2));
}
public boolean isBroadcastDomainPort(NodePortTuple npt) {
return broadcastDomainPorts.contains(npt);
}
class NodeDist implements Comparable<NodeDist> {
private Long node;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment