Fix for optical re-reoute
Change-Id: Iad3ca0e175cb76f66ac276981f4e36bb580566c8
Showing
6 changed files
with
52 additions
and
6 deletions
... | @@ -206,6 +206,9 @@ public class OpticalPathProvisioner { | ... | @@ -206,6 +206,9 @@ public class OpticalPathProvisioner { |
206 | private static class OpticalLinkWeight implements LinkWeight { | 206 | private static class OpticalLinkWeight implements LinkWeight { |
207 | @Override | 207 | @Override |
208 | public double weight(TopologyEdge edge) { | 208 | public double weight(TopologyEdge edge) { |
209 | + if (edge.link().state() == Link.State.INACTIVE) { | ||
210 | + return -1; // ignore inactive links | ||
211 | + } | ||
209 | if (isOpticalLink(edge.link())) { | 212 | if (isOpticalLink(edge.link())) { |
210 | return 1000.0; // optical links | 213 | return 1000.0; // optical links |
211 | } else { | 214 | } else { | ... | ... |
... | @@ -37,7 +37,7 @@ public class OpticalPathIntent extends Intent { | ... | @@ -37,7 +37,7 @@ public class OpticalPathIntent extends Intent { |
37 | ConnectPoint src, | 37 | ConnectPoint src, |
38 | ConnectPoint dst, | 38 | ConnectPoint dst, |
39 | Path path) { | 39 | Path path) { |
40 | - super(id(OpticalPathIntent.class, src, dst), | 40 | + super(id(OpticalPathIntent.class, src, dst, path), |
41 | appId, | 41 | appId, |
42 | ImmutableSet.<NetworkResource>copyOf(path.links())); | 42 | ImmutableSet.<NetworkResource>copyOf(path.links())); |
43 | this.src = src; | 43 | this.src = src; |
... | @@ -78,6 +78,7 @@ public class OpticalPathIntent extends Intent { | ... | @@ -78,6 +78,7 @@ public class OpticalPathIntent extends Intent { |
78 | .toString(); | 78 | .toString(); |
79 | } | 79 | } |
80 | 80 | ||
81 | + | ||
81 | public Collection<Link> requiredLinks() { | 82 | public Collection<Link> requiredLinks() { |
82 | return path.links(); | 83 | return path.links(); |
83 | } | 84 | } | ... | ... |
... | @@ -45,6 +45,7 @@ import static com.google.common.collect.Multimaps.synchronizedSetMultimap; | ... | @@ -45,6 +45,7 @@ import static com.google.common.collect.Multimaps.synchronizedSetMultimap; |
45 | import static java.util.concurrent.Executors.newSingleThreadExecutor; | 45 | import static java.util.concurrent.Executors.newSingleThreadExecutor; |
46 | import static org.onlab.onos.net.LinkKey.linkKey; | 46 | import static org.onlab.onos.net.LinkKey.linkKey; |
47 | import static org.onlab.onos.net.link.LinkEvent.Type.LINK_REMOVED; | 47 | import static org.onlab.onos.net.link.LinkEvent.Type.LINK_REMOVED; |
48 | +import static org.onlab.onos.net.link.LinkEvent.Type.LINK_UPDATED; | ||
48 | import static org.onlab.util.Tools.namedThreads; | 49 | import static org.onlab.util.Tools.namedThreads; |
49 | import static org.slf4j.LoggerFactory.getLogger; | 50 | import static org.slf4j.LoggerFactory.getLogger; |
50 | 51 | ||
... | @@ -152,13 +153,18 @@ public class ObjectiveTracker implements ObjectiveTrackerService { | ... | @@ -152,13 +153,18 @@ public class ObjectiveTracker implements ObjectiveTrackerService { |
152 | for (Event reason : event.reasons()) { | 153 | for (Event reason : event.reasons()) { |
153 | if (reason instanceof LinkEvent) { | 154 | if (reason instanceof LinkEvent) { |
154 | LinkEvent linkEvent = (LinkEvent) reason; | 155 | LinkEvent linkEvent = (LinkEvent) reason; |
155 | - if (linkEvent.type() == LINK_REMOVED) { | 156 | + if (linkEvent.type() == LINK_REMOVED |
157 | + || (linkEvent.type() == LINK_UPDATED && | ||
158 | + linkEvent.subject().isDurable())) { | ||
156 | final LinkKey linkKey = linkKey(linkEvent.subject()); | 159 | final LinkKey linkKey = linkKey(linkEvent.subject()); |
157 | Set<IntentId> intentIds = intentsByLink.get(linkKey); | 160 | Set<IntentId> intentIds = intentsByLink.get(linkKey); |
158 | log.debug("recompile triggered by LinkDown {} {}", linkKey, intentIds); | 161 | log.debug("recompile triggered by LinkDown {} {}", linkKey, intentIds); |
159 | toBeRecompiled.addAll(intentIds); | 162 | toBeRecompiled.addAll(intentIds); |
160 | } | 163 | } |
161 | - recompileOnly = recompileOnly && linkEvent.type() == LINK_REMOVED; | 164 | + recompileOnly = recompileOnly && |
165 | + (linkEvent.type() == LINK_REMOVED || | ||
166 | + (linkEvent.type() == LINK_UPDATED && | ||
167 | + linkEvent.subject().isDurable())); | ||
162 | } | 168 | } |
163 | } | 169 | } |
164 | 170 | ... | ... |
... | @@ -79,6 +79,9 @@ public class OpticalConnectivityIntentCompiler implements IntentCompiler<Optical | ... | @@ -79,6 +79,9 @@ public class OpticalConnectivityIntentCompiler implements IntentCompiler<Optical |
79 | LinkWeight weight = new LinkWeight() { | 79 | LinkWeight weight = new LinkWeight() { |
80 | @Override | 80 | @Override |
81 | public double weight(TopologyEdge edge) { | 81 | public double weight(TopologyEdge edge) { |
82 | + if (edge.link().state() == Link.State.INACTIVE) { | ||
83 | + return -1; | ||
84 | + } | ||
82 | return edge.link().type() == Link.Type.OPTICAL ? +1 : -1; | 85 | return edge.link().type() == Link.Type.OPTICAL ? +1 : -1; |
83 | } | 86 | } |
84 | }; | 87 | }; |
... | @@ -86,7 +89,8 @@ public class OpticalConnectivityIntentCompiler implements IntentCompiler<Optical | ... | @@ -86,7 +89,8 @@ public class OpticalConnectivityIntentCompiler implements IntentCompiler<Optical |
86 | Set<Path> paths = topologyService.getPaths(topology, start.deviceId(), | 89 | Set<Path> paths = topologyService.getPaths(topology, start.deviceId(), |
87 | end.deviceId(), weight); | 90 | end.deviceId(), weight); |
88 | if (paths.isEmpty()) { | 91 | if (paths.isEmpty()) { |
89 | - throw new PathNotFoundException("No fiber path from " + start + " to " + end); | 92 | + throw new PathNotFoundException("No Optical path found from " + |
93 | + start + " to " + end); | ||
90 | } | 94 | } |
91 | 95 | ||
92 | // TODO: let's be more intelligent about this eventually | 96 | // TODO: let's be more intelligent about this eventually | ... | ... |
... | @@ -256,8 +256,19 @@ public class LinkManager | ... | @@ -256,8 +256,19 @@ public class LinkManager |
256 | } | 256 | } |
257 | 257 | ||
258 | // Removes all links in the specified set and emits appropriate events. | 258 | // Removes all links in the specified set and emits appropriate events. |
259 | - private void removeLinks(Set<Link> links, boolean isSoftRemove) { | 259 | + private void removeLinks(Set<Link> links, boolean isSoftRemove) { |
260 | for (Link link : links) { | 260 | for (Link link : links) { |
261 | + if (!deviceService.getDevice(link.src().deviceId()).type().equals( | ||
262 | + deviceService.getDevice(link.dst().deviceId()).type())) { | ||
263 | + //TODO this is aweful. need to be fixed so that we don't down | ||
264 | + // configured links. perhaps add a mechanism to figure out the | ||
265 | + // state of this link | ||
266 | + log.info("Ignoring removal of link as device types are " + | ||
267 | + "different {} {} ", | ||
268 | + link.src() , | ||
269 | + link.dst()); | ||
270 | + continue; | ||
271 | + } | ||
261 | LinkEvent event = isSoftRemove ? | 272 | LinkEvent event = isSoftRemove ? |
262 | store.removeOrDownLink(link.src(), link.dst()) : | 273 | store.removeOrDownLink(link.src(), link.dst()) : |
263 | store.removeLink(link.src(), link.dst()); | 274 | store.removeLink(link.src(), link.dst()); | ... | ... |
... | @@ -21,6 +21,7 @@ import org.junit.Before; | ... | @@ -21,6 +21,7 @@ import org.junit.Before; |
21 | import org.junit.Test; | 21 | import org.junit.Test; |
22 | import org.onlab.onos.event.Event; | 22 | import org.onlab.onos.event.Event; |
23 | import org.onlab.onos.net.ConnectPoint; | 23 | import org.onlab.onos.net.ConnectPoint; |
24 | +import org.onlab.onos.net.DefaultDevice; | ||
24 | import org.onlab.onos.net.Device; | 25 | import org.onlab.onos.net.Device; |
25 | import org.onlab.onos.net.DeviceId; | 26 | import org.onlab.onos.net.DeviceId; |
26 | import org.onlab.onos.net.Link; | 27 | import org.onlab.onos.net.Link; |
... | @@ -41,8 +42,10 @@ import org.onlab.onos.net.device.impl.DeviceManager; | ... | @@ -41,8 +42,10 @@ import org.onlab.onos.net.device.impl.DeviceManager; |
41 | import org.onlab.onos.store.trivial.impl.SimpleLinkStore; | 42 | import org.onlab.onos.store.trivial.impl.SimpleLinkStore; |
42 | 43 | ||
43 | import java.util.ArrayList; | 44 | import java.util.ArrayList; |
45 | +import java.util.HashMap; | ||
44 | import java.util.Iterator; | 46 | import java.util.Iterator; |
45 | import java.util.List; | 47 | import java.util.List; |
48 | +import java.util.Map; | ||
46 | import java.util.Set; | 49 | import java.util.Set; |
47 | 50 | ||
48 | import static org.junit.Assert.*; | 51 | import static org.junit.Assert.*; |
... | @@ -60,11 +63,17 @@ public class LinkManagerTest { | ... | @@ -60,11 +63,17 @@ public class LinkManagerTest { |
60 | private static final DeviceId DID1 = deviceId("of:foo"); | 63 | private static final DeviceId DID1 = deviceId("of:foo"); |
61 | private static final DeviceId DID2 = deviceId("of:bar"); | 64 | private static final DeviceId DID2 = deviceId("of:bar"); |
62 | private static final DeviceId DID3 = deviceId("of:goo"); | 65 | private static final DeviceId DID3 = deviceId("of:goo"); |
66 | + private static final Device DEV1 = new DefaultDevice( | ||
67 | + PID, DID1, Device.Type.SWITCH, "", "", "", "", null); | ||
68 | + private static final Device DEV2 = new DefaultDevice( | ||
69 | + PID, DID2, Device.Type.SWITCH, "", "", "", "", null); | ||
70 | + private static final Device DEV3 = new DefaultDevice( | ||
71 | + PID, DID2, Device.Type.SWITCH, "", "", "", "", null); | ||
63 | 72 | ||
64 | private static final PortNumber P1 = PortNumber.portNumber(1); | 73 | private static final PortNumber P1 = PortNumber.portNumber(1); |
65 | private static final PortNumber P2 = PortNumber.portNumber(2); | 74 | private static final PortNumber P2 = PortNumber.portNumber(2); |
66 | private static final PortNumber P3 = PortNumber.portNumber(3); | 75 | private static final PortNumber P3 = PortNumber.portNumber(3); |
67 | - | 76 | + private static final Map<DeviceId, Device> DEVICEIDMAP = new HashMap<>(); |
68 | 77 | ||
69 | private LinkManager mgr; | 78 | private LinkManager mgr; |
70 | 79 | ||
... | @@ -76,6 +85,7 @@ public class LinkManagerTest { | ... | @@ -76,6 +85,7 @@ public class LinkManagerTest { |
76 | protected TestListener listener = new TestListener(); | 85 | protected TestListener listener = new TestListener(); |
77 | protected DeviceManager devmgr = new TestDeviceManager(); | 86 | protected DeviceManager devmgr = new TestDeviceManager(); |
78 | 87 | ||
88 | + | ||
79 | @Before | 89 | @Before |
80 | public void setUp() { | 90 | public void setUp() { |
81 | mgr = new LinkManager(); | 91 | mgr = new LinkManager(); |
... | @@ -87,6 +97,10 @@ public class LinkManagerTest { | ... | @@ -87,6 +97,10 @@ public class LinkManagerTest { |
87 | mgr.deviceService = devmgr; | 97 | mgr.deviceService = devmgr; |
88 | mgr.activate(); | 98 | mgr.activate(); |
89 | 99 | ||
100 | + DEVICEIDMAP.put(DID1, DEV1); | ||
101 | + DEVICEIDMAP.put(DID2, DEV2); | ||
102 | + DEVICEIDMAP.put(DID3, DEV3); | ||
103 | + | ||
90 | service.addListener(listener); | 104 | service.addListener(listener); |
91 | 105 | ||
92 | provider = new TestProvider(); | 106 | provider = new TestProvider(); |
... | @@ -276,10 +290,17 @@ public class LinkManagerTest { | ... | @@ -276,10 +290,17 @@ public class LinkManagerTest { |
276 | } | 290 | } |
277 | 291 | ||
278 | private static class TestDeviceManager extends DeviceManager { | 292 | private static class TestDeviceManager extends DeviceManager { |
293 | + | ||
279 | @Override | 294 | @Override |
280 | public MastershipRole getRole(DeviceId deviceId) { | 295 | public MastershipRole getRole(DeviceId deviceId) { |
281 | return MastershipRole.MASTER; | 296 | return MastershipRole.MASTER; |
282 | } | 297 | } |
298 | + | ||
299 | + @Override | ||
300 | + public Device getDevice(DeviceId deviceId) { | ||
301 | + return DEVICEIDMAP.get(deviceId); | ||
302 | + } | ||
303 | + | ||
283 | } | 304 | } |
284 | 305 | ||
285 | } | 306 | } | ... | ... |
-
Please register or login to post a comment