Committed by
Jonathan Hart
ONOS-1438: Improved the routing rule population process for link add and failure…
…; computes the routes changed from the link changes and populates the rules only for the routes. Change-Id: Id4dbd80da37b333f2c19bc97333472dc8031481b
Showing
4 changed files
with
36 additions
and
8 deletions
This diff is collapsed. Click to expand it.
... | @@ -139,6 +139,7 @@ public class IpHandler { | ... | @@ -139,6 +139,7 @@ public class IpHandler { |
139 | OutboundPacket packet = new DefaultOutboundPacket(deviceId, | 139 | OutboundPacket packet = new DefaultOutboundPacket(deviceId, |
140 | treatment, ByteBuffer.wrap(eth.serialize())); | 140 | treatment, ByteBuffer.wrap(eth.serialize())); |
141 | srManager.packetService.emit(packet); | 141 | srManager.packetService.emit(packet); |
142 | + ipPacketQueue.get(destIpAddress).remove(ipPacket); | ||
142 | } | 143 | } |
143 | } | 144 | } |
144 | } | 145 | } | ... | ... |
... | @@ -40,6 +40,7 @@ import java.util.ArrayList; | ... | @@ -40,6 +40,7 @@ import java.util.ArrayList; |
40 | import java.util.Collection; | 40 | import java.util.Collection; |
41 | import java.util.List; | 41 | import java.util.List; |
42 | import java.util.Set; | 42 | import java.util.Set; |
43 | +import java.util.concurrent.atomic.AtomicLong; | ||
43 | 44 | ||
44 | import static com.google.common.base.Preconditions.checkNotNull; | 45 | import static com.google.common.base.Preconditions.checkNotNull; |
45 | 46 | ||
... | @@ -47,8 +48,9 @@ public class RoutingRulePopulator { | ... | @@ -47,8 +48,9 @@ public class RoutingRulePopulator { |
47 | 48 | ||
48 | private static final Logger log = LoggerFactory.getLogger(RoutingRulePopulator.class); | 49 | private static final Logger log = LoggerFactory.getLogger(RoutingRulePopulator.class); |
49 | 50 | ||
50 | - private SegmentRoutingManager srManager; | 51 | + private final SegmentRoutingManager srManager; |
51 | - private NetworkConfigHandler config; | 52 | + private final NetworkConfigHandler config; |
53 | + private AtomicLong rulePopulationCounter; | ||
52 | 54 | ||
53 | /** | 55 | /** |
54 | * Creates a RoutingRulePopulator object. | 56 | * Creates a RoutingRulePopulator object. |
... | @@ -58,6 +60,21 @@ public class RoutingRulePopulator { | ... | @@ -58,6 +60,21 @@ public class RoutingRulePopulator { |
58 | public RoutingRulePopulator(SegmentRoutingManager srManager) { | 60 | public RoutingRulePopulator(SegmentRoutingManager srManager) { |
59 | this.srManager = srManager; | 61 | this.srManager = srManager; |
60 | this.config = checkNotNull(srManager.networkConfigHandler); | 62 | this.config = checkNotNull(srManager.networkConfigHandler); |
63 | + this.rulePopulationCounter = new AtomicLong(0); | ||
64 | + } | ||
65 | + | ||
66 | + /** | ||
67 | + * Resets the population counter. | ||
68 | + */ | ||
69 | + public void resetCounter() { | ||
70 | + rulePopulationCounter.set(0); | ||
71 | + } | ||
72 | + | ||
73 | + /** | ||
74 | + * Returns the number of rules populated. | ||
75 | + */ | ||
76 | + public long getCounter() { | ||
77 | + return rulePopulationCounter.get(); | ||
61 | } | 78 | } |
62 | 79 | ||
63 | /** | 80 | /** |
... | @@ -87,6 +104,7 @@ public class RoutingRulePopulator { | ... | @@ -87,6 +104,7 @@ public class RoutingRulePopulator { |
87 | srManager.appId, 600, false, FlowRule.Type.IP); | 104 | srManager.appId, 600, false, FlowRule.Type.IP); |
88 | 105 | ||
89 | srManager.flowRuleService.applyFlowRules(f); | 106 | srManager.flowRuleService.applyFlowRules(f); |
107 | + rulePopulationCounter.incrementAndGet(); | ||
90 | log.debug("Flow rule {} is set to switch {}", f, deviceId); | 108 | log.debug("Flow rule {} is set to switch {}", f, deviceId); |
91 | } | 109 | } |
92 | 110 | ||
... | @@ -162,6 +180,7 @@ public class RoutingRulePopulator { | ... | @@ -162,6 +180,7 @@ public class RoutingRulePopulator { |
162 | srManager.appId, 600, false, FlowRule.Type.IP); | 180 | srManager.appId, 600, false, FlowRule.Type.IP); |
163 | 181 | ||
164 | srManager.flowRuleService.applyFlowRules(f); | 182 | srManager.flowRuleService.applyFlowRules(f); |
183 | + rulePopulationCounter.incrementAndGet(); | ||
165 | log.debug("IP flow rule {} is set to switch {}", f, deviceId); | 184 | log.debug("IP flow rule {} is set to switch {}", f, deviceId); |
166 | 185 | ||
167 | return true; | 186 | return true; |
... | @@ -216,6 +235,7 @@ public class RoutingRulePopulator { | ... | @@ -216,6 +235,7 @@ public class RoutingRulePopulator { |
216 | FlowRule f = new DefaultFlowRule(deviceId, selector, treatment, 100, | 235 | FlowRule f = new DefaultFlowRule(deviceId, selector, treatment, 100, |
217 | srManager.appId, 600, false, FlowRule.Type.MPLS); | 236 | srManager.appId, 600, false, FlowRule.Type.MPLS); |
218 | srManager.flowRuleService.applyFlowRules(f); | 237 | srManager.flowRuleService.applyFlowRules(f); |
238 | + rulePopulationCounter.incrementAndGet(); | ||
219 | log.debug("MPLS rule {} is set to {}", f, deviceId); | 239 | log.debug("MPLS rule {} is set to {}", f, deviceId); |
220 | } | 240 | } |
221 | 241 | ... | ... |
... | @@ -151,8 +151,7 @@ public class SegmentRoutingManager { | ... | @@ -151,8 +151,7 @@ public class SegmentRoutingManager { |
151 | groupHandler.createGroups(); | 151 | groupHandler.createGroups(); |
152 | groupHandlerMap.put(device.id(), groupHandler); | 152 | groupHandlerMap.put(device.id(), groupHandler); |
153 | log.debug("Initiating default group handling for {}", device.id()); | 153 | log.debug("Initiating default group handling for {}", device.id()); |
154 | - | 154 | + defaultRoutingHandler.populateTtpRules(device.id()); |
155 | - defaultRoutingHandler.startPopulationProcess(); | ||
156 | } else { | 155 | } else { |
157 | log.debug("Activate: Local role {} " | 156 | log.debug("Activate: Local role {} " |
158 | + "is not MASTER for device {}", | 157 | + "is not MASTER for device {}", |
... | @@ -162,6 +161,8 @@ public class SegmentRoutingManager { | ... | @@ -162,6 +161,8 @@ public class SegmentRoutingManager { |
162 | } | 161 | } |
163 | } | 162 | } |
164 | 163 | ||
164 | + defaultRoutingHandler.startPopulationProcess(); | ||
165 | + | ||
165 | log.info("Started"); | 166 | log.info("Started"); |
166 | } | 167 | } |
167 | 168 | ||
... | @@ -239,6 +240,8 @@ public class SegmentRoutingManager { | ... | @@ -239,6 +240,8 @@ public class SegmentRoutingManager { |
239 | switch (event.type()) { | 240 | switch (event.type()) { |
240 | case DEVICE_ADDED: | 241 | case DEVICE_ADDED: |
241 | case PORT_REMOVED: | 242 | case PORT_REMOVED: |
243 | + case DEVICE_UPDATED: | ||
244 | + case DEVICE_AVAILABILITY_CHANGED: | ||
242 | scheduleEventHandlerIfNotScheduled(event); | 245 | scheduleEventHandlerIfNotScheduled(event); |
243 | break; | 246 | break; |
244 | default: | 247 | default: |
... | @@ -294,8 +297,12 @@ public class SegmentRoutingManager { | ... | @@ -294,8 +297,12 @@ public class SegmentRoutingManager { |
294 | processLinkRemoved((Link) event.subject()); | 297 | processLinkRemoved((Link) event.subject()); |
295 | } else if (event.type() == GroupEvent.Type.GROUP_ADDED) { | 298 | } else if (event.type() == GroupEvent.Type.GROUP_ADDED) { |
296 | processGroupAdded((Group) event.subject()); | 299 | processGroupAdded((Group) event.subject()); |
297 | - } else if (event.type() == DeviceEvent.Type.DEVICE_ADDED) { | 300 | + } else if (event.type() == DeviceEvent.Type.DEVICE_ADDED || |
298 | - processDeviceAdded((Device) event.subject()); | 301 | + event.type() == DeviceEvent.Type.DEVICE_AVAILABILITY_CHANGED || |
302 | + event.type() == DeviceEvent.Type.DEVICE_UPDATED) { | ||
303 | + if (deviceService.isAvailable(((Device) event.subject()).id())) { | ||
304 | + processDeviceAdded((Device) event.subject()); | ||
305 | + } | ||
299 | } else if (event.type() == DeviceEvent.Type.PORT_REMOVED) { | 306 | } else if (event.type() == DeviceEvent.Type.PORT_REMOVED) { |
300 | processPortRemoved((Device) event.subject(), | 307 | processPortRemoved((Device) event.subject(), |
301 | ((DeviceEvent) event).port()); | 308 | ((DeviceEvent) event).port()); |
... | @@ -321,12 +328,12 @@ public class SegmentRoutingManager { | ... | @@ -321,12 +328,12 @@ public class SegmentRoutingManager { |
321 | groupHandler.linkUp(link); | 328 | groupHandler.linkUp(link); |
322 | } | 329 | } |
323 | } | 330 | } |
324 | - defaultRoutingHandler.startPopulationProcess(); | 331 | + defaultRoutingHandler.populateRoutingRulesForLinkStatusChange(null); |
325 | } | 332 | } |
326 | 333 | ||
327 | private void processLinkRemoved(Link link) { | 334 | private void processLinkRemoved(Link link) { |
328 | log.debug("A link {} was removed", link.toString()); | 335 | log.debug("A link {} was removed", link.toString()); |
329 | - defaultRoutingHandler.startPopulationProcess(); | 336 | + defaultRoutingHandler.populateRoutingRulesForLinkStatusChange(link); |
330 | } | 337 | } |
331 | 338 | ||
332 | 339 | ... | ... |
-
Please register or login to post a comment