Skip to content
Snippets Groups Projects
Commit 53570832 authored by abat's avatar abat
Browse files

Merge into master from pull request #156:

get link notification from topology instead of linkDiscovery. (https://github.com/floodlight/floodlight/pull/156)
parents 473585c3 c0ae7278
No related branches found
No related tags found
No related merge requests found
...@@ -36,6 +36,18 @@ public interface ILinkDiscovery { ...@@ -36,6 +36,18 @@ public interface ILinkDiscovery {
dstPortState, type, operation); dstPortState, type, operation);
} }
public LDUpdate(LDUpdate old) {
this.src = old.src;
this.srcPort = old.srcPort;
this.srcPortState = old.srcPortState;
this.dst = old.dst;
this.dstPort = old.dstPort;
this.dstPortState = old.dstPortState;
this.srcType = old.srcType;
this.type = old.type;
this.operation = old.operation;
}
// For updtedSwitch(sw) // For updtedSwitch(sw)
public LDUpdate(long switchId, SwitchType stype) { public LDUpdate(long switchId, SwitchType stype) {
this.operation = UpdateOperation.SWITCH_UPDATED; this.operation = UpdateOperation.SWITCH_UPDATED;
...@@ -79,6 +91,10 @@ public interface ILinkDiscovery { ...@@ -79,6 +91,10 @@ public interface ILinkDiscovery {
return operation; return operation;
} }
public void setOperation(UpdateOperation operation) {
this.operation = operation;
}
@Override @Override
public String toString() { public String toString() {
return "LDUpdate [src=" + src + ", srcPort=" + srcPort return "LDUpdate [src=" + src + ", srcPort=" + srcPort
......
...@@ -3,6 +3,7 @@ package net.floodlightcontroller.topology; ...@@ -3,6 +3,7 @@ package net.floodlightcontroller.topology;
import java.util.Set; import java.util.Set;
import net.floodlightcontroller.core.module.IFloodlightService; import net.floodlightcontroller.core.module.IFloodlightService;
import net.floodlightcontroller.linkdiscovery.ILinkDiscovery.LDUpdate;
public interface ITopologyService extends IFloodlightService { public interface ITopologyService extends IFloodlightService {
...@@ -182,4 +183,11 @@ public interface ITopologyService extends IFloodlightService { ...@@ -182,4 +183,11 @@ public interface ITopologyService extends IFloodlightService {
* @return * @return
*/ */
public Set<NodePortTuple> getBlockedPorts(); public Set<NodePortTuple> getBlockedPorts();
/**
* Returns a set of link updates, which had been applied
* in computing the new topology.
* @return
*/
public Set<LDUpdate> getAppliedLinkUpdates();
} }
...@@ -83,13 +83,13 @@ public class TopologyManager implements ...@@ -83,13 +83,13 @@ public class TopologyManager implements
protected ILinkDiscoveryService linkDiscovery; protected ILinkDiscoveryService linkDiscovery;
protected IThreadPoolService threadPool; protected IThreadPoolService threadPool;
protected IFloodlightProviderService floodlightProvider; protected IFloodlightProviderService floodlightProvider;
protected ICounterStoreService counterStore;
protected IRestApiService restApi; protected IRestApiService restApi;
// Modules that listen to our updates // Modules that listen to our updates
protected ArrayList<ITopologyListener> topologyAware; protected ArrayList<ITopologyListener> topologyAware;
protected BlockingQueue<LDUpdate> ldUpdates; protected BlockingQueue<LDUpdate> ldUpdates;
protected Set<LDUpdate> appliedUpdates;
protected TopologyInstance currentInstance; protected TopologyInstance currentInstance;
protected TopologyInstance currentInstanceWithoutTunnels; protected TopologyInstance currentInstanceWithoutTunnels;
protected SingletonTask newInstanceTask; protected SingletonTask newInstanceTask;
...@@ -428,6 +428,10 @@ public class TopologyManager implements ...@@ -428,6 +428,10 @@ public class TopologyManager implements
return blockedPorts; return blockedPorts;
} }
@Override
public Set<LDUpdate> getAppliedLinkUpdates() {
return appliedUpdates;
}
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
...@@ -580,8 +584,6 @@ public class TopologyManager implements ...@@ -580,8 +584,6 @@ public class TopologyManager implements
threadPool = context.getServiceImpl(IThreadPoolService.class); threadPool = context.getServiceImpl(IThreadPoolService.class);
floodlightProvider = floodlightProvider =
context.getServiceImpl(IFloodlightProviderService.class); context.getServiceImpl(IFloodlightProviderService.class);
counterStore =
context.getServiceImpl(ICounterStoreService.class);
restApi = context.getServiceImpl(IRestApiService.class); restApi = context.getServiceImpl(IRestApiService.class);
switchPorts = new HashMap<Long,Set<Short>>(); switchPorts = new HashMap<Long,Set<Short>>();
...@@ -590,7 +592,7 @@ public class TopologyManager implements ...@@ -590,7 +592,7 @@ public class TopologyManager implements
tunnelLinks = new HashMap<NodePortTuple, Set<Link>>(); tunnelLinks = new HashMap<NodePortTuple, Set<Link>>();
topologyAware = new ArrayList<ITopologyListener>(); topologyAware = new ArrayList<ITopologyListener>();
ldUpdates = new LinkedBlockingQueue<LDUpdate>(); ldUpdates = new LinkedBlockingQueue<LDUpdate>();
appliedUpdates = new HashSet<LDUpdate>();
} }
@Override @Override
...@@ -779,10 +781,14 @@ public class TopologyManager implements ...@@ -779,10 +781,14 @@ public class TopologyManager implements
public void applyUpdates() { public void applyUpdates() {
appliedUpdates.clear();
LDUpdate update = null; LDUpdate update = null;
while (ldUpdates.peek() != null) { while (ldUpdates.peek() != null) {
boolean updateApplied = false;
LDUpdate newUpdate = null;
try { try {
update = ldUpdates.take(); update = ldUpdates.take();
newUpdate = new LDUpdate(update);
} catch (Exception e) { } catch (Exception e) {
log.error("Error reading link discovery update.", e); log.error("Error reading link discovery update.", e);
} }
...@@ -801,13 +807,23 @@ public class TopologyManager implements ...@@ -801,13 +807,23 @@ public class TopologyManager implements
addOrUpdateLink(update.getSrc(), update.getSrcPort(), addOrUpdateLink(update.getSrc(), update.getSrcPort(),
update.getDst(), update.getDstPort(), update.getDst(), update.getDstPort(),
update.getType()); update.getType());
updateApplied = true;
} else { } else {
removeLink(update.getSrc(), update.getSrcPort(), removeLink(update.getSrc(), update.getSrcPort(),
update.getDst(), update.getDstPort()); update.getDst(), update.getDstPort());
newUpdate = new LDUpdate(update);
// set the update operation to remove
newUpdate.setOperation(UpdateOperation.REMOVE);
updateApplied = true;
} }
} else if (update.getOperation() == UpdateOperation.REMOVE) { } else if (update.getOperation() == UpdateOperation.REMOVE) {
removeLink(update.getSrc(), update.getSrcPort(), removeLink(update.getSrc(), update.getSrcPort(),
update.getDst(), update.getDstPort()); update.getDst(), update.getDstPort());
updateApplied = true;
}
if (updateApplied) {
appliedUpdates.add(newUpdate);
} }
} }
} }
...@@ -986,6 +1002,7 @@ public class TopologyManager implements ...@@ -986,6 +1002,7 @@ public class TopologyManager implements
switchPortLinks.clear(); switchPortLinks.clear();
portBroadcastDomainLinks.clear(); portBroadcastDomainLinks.clear();
tunnelLinks.clear(); tunnelLinks.clear();
appliedUpdates.clear();
} }
/** /**
...@@ -993,10 +1010,7 @@ public class TopologyManager implements ...@@ -993,10 +1010,7 @@ public class TopologyManager implements
* send out updates. * send out updates.
*/ */
private void clearCurrentTopology() { private void clearCurrentTopology() {
switchPorts.clear(); this.clear();
switchPortLinks.clear();
portBroadcastDomainLinks.clear();
tunnelLinks.clear();
createNewInstance(); createNewInstance();
} }
......
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