Create a formal interface between the RIB and FIB.
* IntentSynchronizer implements a more generalized FibListener interface * Updates to the FIB are signalled with FibUpdate to any FibListeners * generateRouteIntent logic has been pushed down into the IntentSynchronizer Change-Id: I6f0ccfd52ee4e16ce9974af5ee549d4ede6c2d0e
Showing
11 changed files
with
400 additions
and
144 deletions
1 | +/* | ||
2 | + * Copyright 2015 Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | +package org.onosproject.sdnip; | ||
17 | + | ||
18 | +import org.onlab.packet.IpAddress; | ||
19 | +import org.onlab.packet.IpPrefix; | ||
20 | +import org.onlab.packet.MacAddress; | ||
21 | + | ||
22 | +/** | ||
23 | + * An entry in the Forwarding Information Base (FIB). | ||
24 | + */ | ||
25 | +public class FibEntry { | ||
26 | + | ||
27 | + private final IpPrefix prefix; | ||
28 | + private final IpAddress nextHopIp; | ||
29 | + private final MacAddress nextHopMac; | ||
30 | + | ||
31 | + /** | ||
32 | + * Creates a new FIB entry. | ||
33 | + * | ||
34 | + * @param prefix IP prefix of the FIB entry | ||
35 | + * @param nextHopIp IP address of the next hop | ||
36 | + * @param nextHopMac MAC address of the next hop | ||
37 | + */ | ||
38 | + public FibEntry(IpPrefix prefix, IpAddress nextHopIp, MacAddress nextHopMac) { | ||
39 | + this.prefix = prefix; | ||
40 | + this.nextHopIp = nextHopIp; | ||
41 | + this.nextHopMac = nextHopMac; | ||
42 | + } | ||
43 | + | ||
44 | + /** | ||
45 | + * Returns the IP prefix of the FIB entry. | ||
46 | + * | ||
47 | + * @return the IP prefix | ||
48 | + */ | ||
49 | + public IpPrefix prefix() { | ||
50 | + return prefix; | ||
51 | + } | ||
52 | + | ||
53 | + /** | ||
54 | + * Returns the IP address of the next hop. | ||
55 | + * | ||
56 | + * @return the IP address | ||
57 | + */ | ||
58 | + public IpAddress nextHopIp() { | ||
59 | + return nextHopIp; | ||
60 | + } | ||
61 | + | ||
62 | + /** | ||
63 | + * Returns the MAC address of the next hop. | ||
64 | + * | ||
65 | + * @return the MAC address | ||
66 | + */ | ||
67 | + public MacAddress nextHopMac() { | ||
68 | + return nextHopMac; | ||
69 | + } | ||
70 | +} |
1 | +/* | ||
2 | + * Copyright 2015 Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | +package org.onosproject.sdnip; | ||
17 | + | ||
18 | +import java.util.Collection; | ||
19 | + | ||
20 | +/** | ||
21 | + * A component that is able to process Forwarding Information Base (FIB) updates. | ||
22 | + */ | ||
23 | +public interface FibListener { | ||
24 | + | ||
25 | + /** | ||
26 | + * Signals the FIB component of changes to the FIB. | ||
27 | + * | ||
28 | + * @param updates FIB updates of the UDPATE type | ||
29 | + * @param withdraws FIB updates of the WITHDRAW type | ||
30 | + */ | ||
31 | + // TODO this interface should use only one collection when we have the new | ||
32 | + // intent key API | ||
33 | + void update(Collection<FibUpdate> updates, Collection<FibUpdate> withdraws); | ||
34 | + | ||
35 | +} |
1 | +/* | ||
2 | + * Copyright 2015 Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | +package org.onosproject.sdnip; | ||
17 | + | ||
18 | +/** | ||
19 | + * Represents a change to the Forwarding Information Base (FIB). | ||
20 | + */ | ||
21 | +public class FibUpdate { | ||
22 | + | ||
23 | + /** | ||
24 | + * Specifies the type of the FIB update. | ||
25 | + */ | ||
26 | + public enum Type { | ||
27 | + /** | ||
28 | + * The update contains a new or updated FIB entry for a prefix. | ||
29 | + */ | ||
30 | + UPDATE, | ||
31 | + | ||
32 | + /** | ||
33 | + * The update signals that a prefix should be removed from the FIB. | ||
34 | + */ | ||
35 | + DELETE | ||
36 | + } | ||
37 | + | ||
38 | + private final Type type; | ||
39 | + private final FibEntry entry; | ||
40 | + | ||
41 | + /** | ||
42 | + * Creates a new FIB update. | ||
43 | + * | ||
44 | + * @param type type of the update | ||
45 | + * @param entry FIB entry describing the update | ||
46 | + */ | ||
47 | + public FibUpdate(Type type, FibEntry entry) { | ||
48 | + this.type = type; | ||
49 | + this.entry = entry; | ||
50 | + } | ||
51 | + | ||
52 | + /** | ||
53 | + * Returns the type of the update. | ||
54 | + * | ||
55 | + * @return update type | ||
56 | + */ | ||
57 | + public Type type() { | ||
58 | + return type; | ||
59 | + } | ||
60 | + | ||
61 | + /** | ||
62 | + * Returns the FIB entry which contains update information. | ||
63 | + * | ||
64 | + * @return the FIB entry | ||
65 | + */ | ||
66 | + public FibEntry entry() { | ||
67 | + return entry; | ||
68 | + } | ||
69 | +} |
... | @@ -15,22 +15,19 @@ | ... | @@ -15,22 +15,19 @@ |
15 | */ | 15 | */ |
16 | package org.onosproject.sdnip; | 16 | package org.onosproject.sdnip; |
17 | 17 | ||
18 | -import static com.google.common.base.Preconditions.checkArgument; | 18 | +import com.google.common.util.concurrent.ThreadFactoryBuilder; |
19 | - | 19 | +import org.onlab.packet.Ethernet; |
20 | -import java.util.Collection; | 20 | +import org.onlab.packet.Ip4Address; |
21 | -import java.util.HashMap; | 21 | +import org.onlab.packet.IpAddress; |
22 | -import java.util.LinkedList; | ||
23 | -import java.util.List; | ||
24 | -import java.util.Map; | ||
25 | -import java.util.Objects; | ||
26 | -import java.util.concurrent.ConcurrentHashMap; | ||
27 | -import java.util.concurrent.ExecutorService; | ||
28 | -import java.util.concurrent.Executors; | ||
29 | -import java.util.concurrent.Semaphore; | ||
30 | - | ||
31 | -import org.apache.commons.lang3.tuple.Pair; | ||
32 | import org.onlab.packet.IpPrefix; | 22 | import org.onlab.packet.IpPrefix; |
23 | +import org.onlab.packet.MacAddress; | ||
24 | +import org.onlab.packet.VlanId; | ||
33 | import org.onosproject.core.ApplicationId; | 25 | import org.onosproject.core.ApplicationId; |
26 | +import org.onosproject.net.ConnectPoint; | ||
27 | +import org.onosproject.net.flow.DefaultTrafficSelector; | ||
28 | +import org.onosproject.net.flow.DefaultTrafficTreatment; | ||
29 | +import org.onosproject.net.flow.TrafficSelector; | ||
30 | +import org.onosproject.net.flow.TrafficTreatment; | ||
34 | import org.onosproject.net.flow.criteria.Criteria.IPCriterion; | 31 | import org.onosproject.net.flow.criteria.Criteria.IPCriterion; |
35 | import org.onosproject.net.flow.criteria.Criterion; | 32 | import org.onosproject.net.flow.criteria.Criterion; |
36 | import org.onosproject.net.intent.Intent; | 33 | import org.onosproject.net.intent.Intent; |
... | @@ -39,16 +36,32 @@ import org.onosproject.net.intent.IntentService; | ... | @@ -39,16 +36,32 @@ import org.onosproject.net.intent.IntentService; |
39 | import org.onosproject.net.intent.IntentState; | 36 | import org.onosproject.net.intent.IntentState; |
40 | import org.onosproject.net.intent.MultiPointToSinglePointIntent; | 37 | import org.onosproject.net.intent.MultiPointToSinglePointIntent; |
41 | import org.onosproject.net.intent.PointToPointIntent; | 38 | import org.onosproject.net.intent.PointToPointIntent; |
39 | +import org.onosproject.sdnip.config.BgpPeer; | ||
40 | +import org.onosproject.sdnip.config.Interface; | ||
41 | +import org.onosproject.sdnip.config.SdnIpConfigurationService; | ||
42 | import org.slf4j.Logger; | 42 | import org.slf4j.Logger; |
43 | import org.slf4j.LoggerFactory; | 43 | import org.slf4j.LoggerFactory; |
44 | 44 | ||
45 | -import com.google.common.util.concurrent.ThreadFactoryBuilder; | 45 | +import java.util.Collection; |
46 | +import java.util.HashMap; | ||
47 | +import java.util.HashSet; | ||
48 | +import java.util.LinkedList; | ||
49 | +import java.util.List; | ||
50 | +import java.util.Map; | ||
51 | +import java.util.Objects; | ||
52 | +import java.util.Set; | ||
53 | +import java.util.concurrent.ConcurrentHashMap; | ||
54 | +import java.util.concurrent.ExecutorService; | ||
55 | +import java.util.concurrent.Executors; | ||
56 | +import java.util.concurrent.Semaphore; | ||
57 | + | ||
58 | +import static com.google.common.base.Preconditions.checkArgument; | ||
46 | 59 | ||
47 | /** | 60 | /** |
48 | * Synchronizes intents between the in-memory intent store and the | 61 | * Synchronizes intents between the in-memory intent store and the |
49 | * IntentService. | 62 | * IntentService. |
50 | */ | 63 | */ |
51 | -public class IntentSynchronizer { | 64 | +public class IntentSynchronizer implements FibListener { |
52 | private static final Logger log = | 65 | private static final Logger log = |
53 | LoggerFactory.getLogger(IntentSynchronizer.class); | 66 | LoggerFactory.getLogger(IntentSynchronizer.class); |
54 | 67 | ||
... | @@ -65,18 +78,28 @@ public class IntentSynchronizer { | ... | @@ -65,18 +78,28 @@ public class IntentSynchronizer { |
65 | private volatile boolean isElectedLeader = false; | 78 | private volatile boolean isElectedLeader = false; |
66 | private volatile boolean isActivatedLeader = false; | 79 | private volatile boolean isActivatedLeader = false; |
67 | 80 | ||
81 | + private final SdnIpConfigurationService configService; | ||
82 | + private final InterfaceService interfaceService; | ||
83 | + | ||
68 | /** | 84 | /** |
69 | * Class constructor. | 85 | * Class constructor. |
70 | * | 86 | * |
71 | * @param appId the Application ID | 87 | * @param appId the Application ID |
72 | * @param intentService the intent service | 88 | * @param intentService the intent service |
89 | + * @param configService the SDN-IP configuration service | ||
90 | + * @param interfaceService the interface service | ||
73 | */ | 91 | */ |
74 | - IntentSynchronizer(ApplicationId appId, IntentService intentService) { | 92 | + IntentSynchronizer(ApplicationId appId, IntentService intentService, |
93 | + SdnIpConfigurationService configService, | ||
94 | + InterfaceService interfaceService) { | ||
75 | this.appId = appId; | 95 | this.appId = appId; |
76 | this.intentService = intentService; | 96 | this.intentService = intentService; |
77 | peerIntents = new ConcurrentHashMap<>(); | 97 | peerIntents = new ConcurrentHashMap<>(); |
78 | routeIntents = new ConcurrentHashMap<>(); | 98 | routeIntents = new ConcurrentHashMap<>(); |
79 | 99 | ||
100 | + this.configService = configService; | ||
101 | + this.interfaceService = interfaceService; | ||
102 | + | ||
80 | bgpIntentsSynchronizerExecutor = Executors.newSingleThreadExecutor( | 103 | bgpIntentsSynchronizerExecutor = Executors.newSingleThreadExecutor( |
81 | new ThreadFactoryBuilder() | 104 | new ThreadFactoryBuilder() |
82 | .setNameFormat("sdnip-intents-synchronizer-%d").build()); | 105 | .setNameFormat("sdnip-intents-synchronizer-%d").build()); |
... | @@ -244,16 +267,85 @@ public class IntentSynchronizer { | ... | @@ -244,16 +267,85 @@ public class IntentSynchronizer { |
244 | } | 267 | } |
245 | 268 | ||
246 | /** | 269 | /** |
247 | - * Updates multi-point-to-single-point route intents. | 270 | + * Generates a route intent for a prefix, the next hop IP address, and |
271 | + * the next hop MAC address. | ||
272 | + * <p/> | ||
273 | + * This method will find the egress interface for the intent. | ||
274 | + * Intent will match dst IP prefix and rewrite dst MAC address at all other | ||
275 | + * border switches, then forward packets according to dst MAC address. | ||
248 | * | 276 | * |
249 | - * @param submitIntents the intents to submit | 277 | + * @param prefix IP prefix of the route to add |
250 | - * @param withdrawPrefixes the IPv4 or IPv6 matching prefixes for the | 278 | + * @param nextHopIpAddress IP address of the next hop |
251 | - * intents to withdraw | 279 | + * @param nextHopMacAddress MAC address of the next hop |
280 | + * @return the generated intent, or null if no intent should be submitted | ||
252 | */ | 281 | */ |
253 | - void updateRouteIntents( | 282 | + private MultiPointToSinglePointIntent generateRouteIntent( |
254 | - Collection<Pair<IpPrefix, MultiPointToSinglePointIntent>> submitIntents, | 283 | + IpPrefix prefix, |
255 | - Collection<IpPrefix> withdrawPrefixes) { | 284 | + IpAddress nextHopIpAddress, |
285 | + MacAddress nextHopMacAddress) { | ||
286 | + | ||
287 | + // Find the attachment point (egress interface) of the next hop | ||
288 | + Interface egressInterface; | ||
289 | + if (configService.getBgpPeers().containsKey(nextHopIpAddress)) { | ||
290 | + // Route to a peer | ||
291 | + log.debug("Route to peer {}", nextHopIpAddress); | ||
292 | + BgpPeer peer = | ||
293 | + configService.getBgpPeers().get(nextHopIpAddress); | ||
294 | + egressInterface = | ||
295 | + interfaceService.getInterface(peer.connectPoint()); | ||
296 | + } else { | ||
297 | + // Route to non-peer | ||
298 | + log.debug("Route to non-peer {}", nextHopIpAddress); | ||
299 | + egressInterface = | ||
300 | + interfaceService.getMatchingInterface(nextHopIpAddress); | ||
301 | + if (egressInterface == null) { | ||
302 | + log.warn("No outgoing interface found for {}", | ||
303 | + nextHopIpAddress); | ||
304 | + return null; | ||
305 | + } | ||
306 | + } | ||
307 | + | ||
308 | + // | ||
309 | + // Generate the intent itself | ||
310 | + // | ||
311 | + Set<ConnectPoint> ingressPorts = new HashSet<>(); | ||
312 | + ConnectPoint egressPort = egressInterface.connectPoint(); | ||
313 | + log.debug("Generating intent for prefix {}, next hop mac {}", | ||
314 | + prefix, nextHopMacAddress); | ||
315 | + | ||
316 | + for (Interface intf : interfaceService.getInterfaces()) { | ||
317 | + if (!intf.connectPoint().equals(egressInterface.connectPoint())) { | ||
318 | + ConnectPoint srcPort = intf.connectPoint(); | ||
319 | + ingressPorts.add(srcPort); | ||
320 | + } | ||
321 | + } | ||
322 | + | ||
323 | + // Match the destination IP prefix at the first hop | ||
324 | + TrafficSelector.Builder selector = DefaultTrafficSelector.builder(); | ||
325 | + if (prefix.version() == Ip4Address.VERSION) { | ||
326 | + selector.matchEthType(Ethernet.TYPE_IPV4); | ||
327 | + } else { | ||
328 | + selector.matchEthType(Ethernet.TYPE_IPV6); | ||
329 | + } | ||
330 | + selector.matchIPDst(prefix); | ||
331 | + | ||
332 | + // Rewrite the destination MAC address | ||
333 | + TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder() | ||
334 | + .setEthDst(nextHopMacAddress); | ||
335 | + if (!egressInterface.vlan().equals(VlanId.NONE)) { | ||
336 | + treatment.setVlanId(egressInterface.vlan()); | ||
337 | + // If we set VLAN ID, we have to make sure a VLAN tag exists. | ||
338 | + // TODO support no VLAN -> VLAN routing | ||
339 | + selector.matchVlanId(VlanId.ANY); | ||
340 | + } | ||
341 | + | ||
342 | + return new MultiPointToSinglePointIntent(appId, selector.build(), | ||
343 | + treatment.build(), | ||
344 | + ingressPorts, egressPort); | ||
345 | + } | ||
256 | 346 | ||
347 | + @Override | ||
348 | + public void update(Collection<FibUpdate> updates, Collection<FibUpdate> withdraws) { | ||
257 | // | 349 | // |
258 | // NOTE: Semantically, we MUST withdraw existing intents before | 350 | // NOTE: Semantically, we MUST withdraw existing intents before |
259 | // submitting new intents. | 351 | // submitting new intents. |
... | @@ -262,14 +354,19 @@ public class IntentSynchronizer { | ... | @@ -262,14 +354,19 @@ public class IntentSynchronizer { |
262 | MultiPointToSinglePointIntent intent; | 354 | MultiPointToSinglePointIntent intent; |
263 | 355 | ||
264 | log.debug("SDN-IP submitting intents = {} withdrawing = {}", | 356 | log.debug("SDN-IP submitting intents = {} withdrawing = {}", |
265 | - submitIntents.size(), withdrawPrefixes.size()); | 357 | + updates.size(), withdraws.size()); |
266 | 358 | ||
267 | // | 359 | // |
268 | // Prepare the Intent batch operations for the intents to withdraw | 360 | // Prepare the Intent batch operations for the intents to withdraw |
269 | // | 361 | // |
270 | IntentOperations.Builder withdrawBuilder = | 362 | IntentOperations.Builder withdrawBuilder = |
271 | IntentOperations.builder(appId); | 363 | IntentOperations.builder(appId); |
272 | - for (IpPrefix prefix : withdrawPrefixes) { | 364 | + for (FibUpdate withdraw : withdraws) { |
365 | + checkArgument(withdraw.type() == FibUpdate.Type.DELETE, | ||
366 | + "FibUpdate with wrong type in withdraws list"); | ||
367 | + | ||
368 | + IpPrefix prefix = withdraw.entry().prefix(); | ||
369 | + | ||
273 | intent = routeIntents.remove(prefix); | 370 | intent = routeIntents.remove(prefix); |
274 | if (intent == null) { | 371 | if (intent == null) { |
275 | log.trace("SDN-IP No intent in routeIntents to delete " + | 372 | log.trace("SDN-IP No intent in routeIntents to delete " + |
... | @@ -287,10 +384,21 @@ public class IntentSynchronizer { | ... | @@ -287,10 +384,21 @@ public class IntentSynchronizer { |
287 | // | 384 | // |
288 | IntentOperations.Builder submitBuilder = | 385 | IntentOperations.Builder submitBuilder = |
289 | IntentOperations.builder(appId); | 386 | IntentOperations.builder(appId); |
290 | - for (Pair<IpPrefix, MultiPointToSinglePointIntent> pair : | 387 | + for (FibUpdate update : updates) { |
291 | - submitIntents) { | 388 | + checkArgument(update.type() == FibUpdate.Type.UPDATE, |
292 | - IpPrefix prefix = pair.getLeft(); | 389 | + "FibUpdate with wrong type in updates list"); |
293 | - intent = pair.getRight(); | 390 | + |
391 | + IpPrefix prefix = update.entry().prefix(); | ||
392 | + intent = generateRouteIntent(prefix, update.entry().nextHopIp(), | ||
393 | + update.entry().nextHopMac()); | ||
394 | + | ||
395 | + if (intent == null) { | ||
396 | + // This preserves the old semantics - if an intent can't be | ||
397 | + // generated, we don't do anything with that prefix. But | ||
398 | + // perhaps we should withdraw the old intent anyway? | ||
399 | + continue; | ||
400 | + } | ||
401 | + | ||
294 | MultiPointToSinglePointIntent oldIntent = | 402 | MultiPointToSinglePointIntent oldIntent = |
295 | routeIntents.put(prefix, intent); | 403 | routeIntents.put(prefix, intent); |
296 | if (isElectedLeader && isActivatedLeader) { | 404 | if (isElectedLeader && isActivatedLeader) { | ... | ... |
This diff is collapsed. Click to expand it.
... | @@ -15,11 +15,6 @@ | ... | @@ -15,11 +15,6 @@ |
15 | */ | 15 | */ |
16 | package org.onosproject.sdnip; | 16 | package org.onosproject.sdnip; |
17 | 17 | ||
18 | -import static org.slf4j.LoggerFactory.getLogger; | ||
19 | - | ||
20 | -import java.util.Collection; | ||
21 | -import java.util.Dictionary; | ||
22 | - | ||
23 | import org.apache.felix.scr.annotations.Activate; | 18 | import org.apache.felix.scr.annotations.Activate; |
24 | import org.apache.felix.scr.annotations.Component; | 19 | import org.apache.felix.scr.annotations.Component; |
25 | import org.apache.felix.scr.annotations.Deactivate; | 20 | import org.apache.felix.scr.annotations.Deactivate; |
... | @@ -44,6 +39,11 @@ import org.onosproject.sdnip.config.SdnIpConfigurationReader; | ... | @@ -44,6 +39,11 @@ import org.onosproject.sdnip.config.SdnIpConfigurationReader; |
44 | import org.osgi.service.component.ComponentContext; | 39 | import org.osgi.service.component.ComponentContext; |
45 | import org.slf4j.Logger; | 40 | import org.slf4j.Logger; |
46 | 41 | ||
42 | +import java.util.Collection; | ||
43 | +import java.util.Dictionary; | ||
44 | + | ||
45 | +import static org.slf4j.LoggerFactory.getLogger; | ||
46 | + | ||
47 | /** | 47 | /** |
48 | * Component for the SDN-IP peering application. | 48 | * Component for the SDN-IP peering application. |
49 | */ | 49 | */ |
... | @@ -104,7 +104,8 @@ public class SdnIp implements SdnIpService { | ... | @@ -104,7 +104,8 @@ public class SdnIp implements SdnIpService { |
104 | InterfaceService interfaceService = | 104 | InterfaceService interfaceService = |
105 | new HostToInterfaceAdaptor(hostService); | 105 | new HostToInterfaceAdaptor(hostService); |
106 | 106 | ||
107 | - intentSynchronizer = new IntentSynchronizer(appId, intentService); | 107 | + intentSynchronizer = new IntentSynchronizer(appId, intentService, |
108 | + config, interfaceService); | ||
108 | intentSynchronizer.start(); | 109 | intentSynchronizer.start(); |
109 | 110 | ||
110 | peerConnectivity = new PeerConnectivityManager(appId, | 111 | peerConnectivity = new PeerConnectivityManager(appId, |
... | @@ -113,8 +114,7 @@ public class SdnIp implements SdnIpService { | ... | @@ -113,8 +114,7 @@ public class SdnIp implements SdnIpService { |
113 | interfaceService); | 114 | interfaceService); |
114 | peerConnectivity.start(); | 115 | peerConnectivity.start(); |
115 | 116 | ||
116 | - router = new Router(appId, intentSynchronizer, config, | 117 | + router = new Router(intentSynchronizer, hostService); |
117 | - interfaceService, hostService); | ||
118 | router.start(); | 118 | router.start(); |
119 | 119 | ||
120 | leadershipService.addListener(leadershipEventListener); | 120 | leadershipService.addListener(leadershipEventListener); | ... | ... |
... | @@ -15,23 +15,10 @@ | ... | @@ -15,23 +15,10 @@ |
15 | */ | 15 | */ |
16 | package org.onosproject.sdnip; | 16 | package org.onosproject.sdnip; |
17 | 17 | ||
18 | -import static org.easymock.EasyMock.anyObject; | 18 | +import com.google.common.collect.Sets; |
19 | -import static org.easymock.EasyMock.createMock; | 19 | +import com.googlecode.concurrenttrees.radix.node.concrete.DefaultByteArrayNodeFactory; |
20 | -import static org.easymock.EasyMock.expect; | 20 | +import com.googlecode.concurrenttrees.radixinverted.ConcurrentInvertedRadixTree; |
21 | -import static org.easymock.EasyMock.expectLastCall; | 21 | +import com.googlecode.concurrenttrees.radixinverted.InvertedRadixTree; |
22 | -import static org.easymock.EasyMock.replay; | ||
23 | -import static org.easymock.EasyMock.reset; | ||
24 | -import static org.easymock.EasyMock.verify; | ||
25 | -import static org.hamcrest.Matchers.is; | ||
26 | -import static org.junit.Assert.assertEquals; | ||
27 | -import static org.junit.Assert.assertFalse; | ||
28 | -import static org.junit.Assert.assertThat; | ||
29 | -import static org.junit.Assert.assertTrue; | ||
30 | - | ||
31 | -import java.util.HashSet; | ||
32 | -import java.util.Set; | ||
33 | -import java.util.concurrent.ConcurrentHashMap; | ||
34 | - | ||
35 | import org.junit.Before; | 22 | import org.junit.Before; |
36 | import org.junit.Test; | 23 | import org.junit.Test; |
37 | import org.onlab.junit.TestUtils; | 24 | import org.onlab.junit.TestUtils; |
... | @@ -67,10 +54,16 @@ import org.onosproject.net.intent.MultiPointToSinglePointIntent; | ... | @@ -67,10 +54,16 @@ import org.onosproject.net.intent.MultiPointToSinglePointIntent; |
67 | import org.onosproject.net.provider.ProviderId; | 54 | import org.onosproject.net.provider.ProviderId; |
68 | import org.onosproject.sdnip.config.Interface; | 55 | import org.onosproject.sdnip.config.Interface; |
69 | 56 | ||
70 | -import com.google.common.collect.Sets; | 57 | +import java.util.HashSet; |
71 | -import com.googlecode.concurrenttrees.radix.node.concrete.DefaultByteArrayNodeFactory; | 58 | +import java.util.Set; |
72 | -import com.googlecode.concurrenttrees.radixinverted.ConcurrentInvertedRadixTree; | 59 | +import java.util.concurrent.ConcurrentHashMap; |
73 | -import com.googlecode.concurrenttrees.radixinverted.InvertedRadixTree; | 60 | + |
61 | +import static org.easymock.EasyMock.*; | ||
62 | +import static org.hamcrest.Matchers.is; | ||
63 | +import static org.junit.Assert.assertEquals; | ||
64 | +import static org.junit.Assert.assertFalse; | ||
65 | +import static org.junit.Assert.assertThat; | ||
66 | +import static org.junit.Assert.assertTrue; | ||
74 | 67 | ||
75 | /** | 68 | /** |
76 | * This class tests the intent synchronization function in the | 69 | * This class tests the intent synchronization function in the |
... | @@ -116,9 +109,9 @@ public class IntentSyncTest extends AbstractIntentTest { | ... | @@ -116,9 +109,9 @@ public class IntentSyncTest extends AbstractIntentTest { |
116 | setUpHostService(); | 109 | setUpHostService(); |
117 | intentService = createMock(IntentService.class); | 110 | intentService = createMock(IntentService.class); |
118 | 111 | ||
119 | - intentSynchronizer = new IntentSynchronizer(APPID, intentService); | 112 | + intentSynchronizer = new IntentSynchronizer(APPID, intentService, |
120 | - router = new Router(APPID, intentSynchronizer, null, interfaceService, | 113 | + null, interfaceService); |
121 | - hostService); | 114 | + router = new Router(intentSynchronizer, hostService); |
122 | } | 115 | } |
123 | 116 | ||
124 | /** | 117 | /** | ... | ... |
... | @@ -15,19 +15,7 @@ | ... | @@ -15,19 +15,7 @@ |
15 | */ | 15 | */ |
16 | package org.onosproject.sdnip; | 16 | package org.onosproject.sdnip; |
17 | 17 | ||
18 | -import static org.easymock.EasyMock.createMock; | 18 | +import com.google.common.collect.Sets; |
19 | -import static org.easymock.EasyMock.expect; | ||
20 | -import static org.easymock.EasyMock.replay; | ||
21 | -import static org.easymock.EasyMock.reset; | ||
22 | -import static org.easymock.EasyMock.verify; | ||
23 | - | ||
24 | -import java.util.ArrayList; | ||
25 | -import java.util.Collections; | ||
26 | -import java.util.HashMap; | ||
27 | -import java.util.LinkedList; | ||
28 | -import java.util.List; | ||
29 | -import java.util.Map; | ||
30 | - | ||
31 | import org.junit.Before; | 19 | import org.junit.Before; |
32 | import org.junit.Ignore; | 20 | import org.junit.Ignore; |
33 | import org.junit.Test; | 21 | import org.junit.Test; |
... | @@ -60,7 +48,14 @@ import org.onosproject.sdnip.config.Interface; | ... | @@ -60,7 +48,14 @@ import org.onosproject.sdnip.config.Interface; |
60 | import org.onosproject.sdnip.config.InterfaceAddress; | 48 | import org.onosproject.sdnip.config.InterfaceAddress; |
61 | import org.onosproject.sdnip.config.SdnIpConfigurationService; | 49 | import org.onosproject.sdnip.config.SdnIpConfigurationService; |
62 | 50 | ||
63 | -import com.google.common.collect.Sets; | 51 | +import java.util.ArrayList; |
52 | +import java.util.Collections; | ||
53 | +import java.util.HashMap; | ||
54 | +import java.util.LinkedList; | ||
55 | +import java.util.List; | ||
56 | +import java.util.Map; | ||
57 | + | ||
58 | +import static org.easymock.EasyMock.*; | ||
64 | 59 | ||
65 | /** | 60 | /** |
66 | * Unit tests for PeerConnectivityManager. | 61 | * Unit tests for PeerConnectivityManager. |
... | @@ -552,7 +547,9 @@ public class PeerConnectivityManagerTest extends AbstractIntentTest { | ... | @@ -552,7 +547,9 @@ public class PeerConnectivityManagerTest extends AbstractIntentTest { |
552 | intentService = createMock(IntentService.class); | 547 | intentService = createMock(IntentService.class); |
553 | replay(intentService); | 548 | replay(intentService); |
554 | 549 | ||
555 | - intentSynchronizer = new IntentSynchronizer(APPID, intentService); | 550 | + intentSynchronizer = new IntentSynchronizer(APPID, intentService, |
551 | + configInfoService, | ||
552 | + interfaceService); | ||
556 | intentSynchronizer.leaderChanged(true); | 553 | intentSynchronizer.leaderChanged(true); |
557 | TestUtils.setField(intentSynchronizer, "isActivatedLeader", true); | 554 | TestUtils.setField(intentSynchronizer, "isActivatedLeader", true); |
558 | 555 | ... | ... |
... | @@ -15,22 +15,10 @@ | ... | @@ -15,22 +15,10 @@ |
15 | */ | 15 | */ |
16 | package org.onosproject.sdnip; | 16 | package org.onosproject.sdnip; |
17 | 17 | ||
18 | -import static org.easymock.EasyMock.anyObject; | 18 | +import com.google.common.collect.Sets; |
19 | -import static org.easymock.EasyMock.createMock; | 19 | +import com.googlecode.concurrenttrees.radix.node.concrete.DefaultByteArrayNodeFactory; |
20 | -import static org.easymock.EasyMock.expect; | 20 | +import com.googlecode.concurrenttrees.radixinverted.ConcurrentInvertedRadixTree; |
21 | -import static org.easymock.EasyMock.replay; | 21 | +import com.googlecode.concurrenttrees.radixinverted.InvertedRadixTree; |
22 | -import static org.easymock.EasyMock.reset; | ||
23 | -import static org.easymock.EasyMock.verify; | ||
24 | -import static org.junit.Assert.assertEquals; | ||
25 | -import static org.junit.Assert.assertTrue; | ||
26 | - | ||
27 | -import java.util.Collections; | ||
28 | -import java.util.HashMap; | ||
29 | -import java.util.HashSet; | ||
30 | -import java.util.Map; | ||
31 | -import java.util.Set; | ||
32 | -import java.util.concurrent.ConcurrentHashMap; | ||
33 | - | ||
34 | import org.junit.Before; | 22 | import org.junit.Before; |
35 | import org.junit.Test; | 23 | import org.junit.Test; |
36 | import org.onlab.junit.TestUtils; | 24 | import org.onlab.junit.TestUtils; |
... | @@ -69,10 +57,16 @@ import org.onosproject.sdnip.config.BgpPeer; | ... | @@ -69,10 +57,16 @@ import org.onosproject.sdnip.config.BgpPeer; |
69 | import org.onosproject.sdnip.config.Interface; | 57 | import org.onosproject.sdnip.config.Interface; |
70 | import org.onosproject.sdnip.config.SdnIpConfigurationService; | 58 | import org.onosproject.sdnip.config.SdnIpConfigurationService; |
71 | 59 | ||
72 | -import com.google.common.collect.Sets; | 60 | +import java.util.Collections; |
73 | -import com.googlecode.concurrenttrees.radix.node.concrete.DefaultByteArrayNodeFactory; | 61 | +import java.util.HashMap; |
74 | -import com.googlecode.concurrenttrees.radixinverted.ConcurrentInvertedRadixTree; | 62 | +import java.util.HashSet; |
75 | -import com.googlecode.concurrenttrees.radixinverted.InvertedRadixTree; | 63 | +import java.util.Map; |
64 | +import java.util.Set; | ||
65 | +import java.util.concurrent.ConcurrentHashMap; | ||
66 | + | ||
67 | +import static org.easymock.EasyMock.*; | ||
68 | +import static org.junit.Assert.assertEquals; | ||
69 | +import static org.junit.Assert.assertTrue; | ||
76 | 70 | ||
77 | /** | 71 | /** |
78 | * This class tests adding a route, updating a route, deleting a route, and | 72 | * This class tests adding a route, updating a route, deleting a route, and |
... | @@ -122,9 +116,10 @@ public class RouterAsyncArpTest extends AbstractIntentTest { | ... | @@ -122,9 +116,10 @@ public class RouterAsyncArpTest extends AbstractIntentTest { |
122 | hostService = createMock(HostService.class); | 116 | hostService = createMock(HostService.class); |
123 | intentService = createMock(IntentService.class); | 117 | intentService = createMock(IntentService.class); |
124 | 118 | ||
125 | - intentSynchronizer = new IntentSynchronizer(APPID, intentService); | 119 | + intentSynchronizer = new IntentSynchronizer(APPID, intentService, |
126 | - router = new Router(APPID, intentSynchronizer, | 120 | + sdnIpConfigService, |
127 | - sdnIpConfigService, interfaceService, hostService); | 121 | + interfaceService); |
122 | + router = new Router(intentSynchronizer, hostService); | ||
128 | internalHostListener = router.new InternalHostListener(); | 123 | internalHostListener = router.new InternalHostListener(); |
129 | } | 124 | } |
130 | 125 | ... | ... |
... | @@ -15,22 +15,7 @@ | ... | @@ -15,22 +15,7 @@ |
15 | */ | 15 | */ |
16 | package org.onosproject.sdnip; | 16 | package org.onosproject.sdnip; |
17 | 17 | ||
18 | -import static org.easymock.EasyMock.anyObject; | 18 | +import com.google.common.collect.Sets; |
19 | -import static org.easymock.EasyMock.createMock; | ||
20 | -import static org.easymock.EasyMock.expect; | ||
21 | -import static org.easymock.EasyMock.expectLastCall; | ||
22 | -import static org.easymock.EasyMock.replay; | ||
23 | -import static org.easymock.EasyMock.reset; | ||
24 | -import static org.easymock.EasyMock.verify; | ||
25 | -import static org.junit.Assert.assertEquals; | ||
26 | -import static org.junit.Assert.assertTrue; | ||
27 | - | ||
28 | -import java.util.Collections; | ||
29 | -import java.util.HashMap; | ||
30 | -import java.util.HashSet; | ||
31 | -import java.util.Map; | ||
32 | -import java.util.Set; | ||
33 | - | ||
34 | import org.junit.Before; | 19 | import org.junit.Before; |
35 | import org.junit.Test; | 20 | import org.junit.Test; |
36 | import org.onlab.junit.TestUtils; | 21 | import org.onlab.junit.TestUtils; |
... | @@ -68,7 +53,15 @@ import org.onosproject.sdnip.config.BgpPeer; | ... | @@ -68,7 +53,15 @@ import org.onosproject.sdnip.config.BgpPeer; |
68 | import org.onosproject.sdnip.config.Interface; | 53 | import org.onosproject.sdnip.config.Interface; |
69 | import org.onosproject.sdnip.config.SdnIpConfigurationService; | 54 | import org.onosproject.sdnip.config.SdnIpConfigurationService; |
70 | 55 | ||
71 | -import com.google.common.collect.Sets; | 56 | +import java.util.Collections; |
57 | +import java.util.HashMap; | ||
58 | +import java.util.HashSet; | ||
59 | +import java.util.Map; | ||
60 | +import java.util.Set; | ||
61 | + | ||
62 | +import static org.easymock.EasyMock.*; | ||
63 | +import static org.junit.Assert.assertEquals; | ||
64 | +import static org.junit.Assert.assertTrue; | ||
72 | 65 | ||
73 | /** | 66 | /** |
74 | * This class tests adding a route, updating a route, deleting a route, | 67 | * This class tests adding a route, updating a route, deleting a route, |
... | @@ -125,9 +118,10 @@ public class RouterTest extends AbstractIntentTest { | ... | @@ -125,9 +118,10 @@ public class RouterTest extends AbstractIntentTest { |
125 | 118 | ||
126 | intentService = createMock(IntentService.class); | 119 | intentService = createMock(IntentService.class); |
127 | 120 | ||
128 | - intentSynchronizer = new IntentSynchronizer(APPID, intentService); | 121 | + intentSynchronizer = new IntentSynchronizer(APPID, intentService, |
129 | - router = new Router(APPID, intentSynchronizer, sdnIpConfigService, | 122 | + sdnIpConfigService, |
130 | - interfaceService, hostService); | 123 | + interfaceService); |
124 | + router = new Router(intentSynchronizer, hostService); | ||
131 | } | 125 | } |
132 | 126 | ||
133 | /** | 127 | /** | ... | ... |
... | @@ -15,26 +15,7 @@ | ... | @@ -15,26 +15,7 @@ |
15 | */ | 15 | */ |
16 | package org.onosproject.sdnip; | 16 | package org.onosproject.sdnip; |
17 | 17 | ||
18 | -import static org.easymock.EasyMock.createMock; | 18 | +import com.google.common.collect.Sets; |
19 | -import static org.easymock.EasyMock.expect; | ||
20 | -import static org.easymock.EasyMock.expectLastCall; | ||
21 | -import static org.easymock.EasyMock.replay; | ||
22 | -import static org.easymock.EasyMock.reset; | ||
23 | -import static org.easymock.EasyMock.verify; | ||
24 | -import static org.junit.Assert.assertEquals; | ||
25 | -import static org.junit.Assert.assertNotNull; | ||
26 | - | ||
27 | -import java.nio.ByteBuffer; | ||
28 | -import java.util.ArrayList; | ||
29 | -import java.util.HashMap; | ||
30 | -import java.util.HashSet; | ||
31 | -import java.util.List; | ||
32 | -import java.util.Map; | ||
33 | -import java.util.Random; | ||
34 | -import java.util.Set; | ||
35 | -import java.util.concurrent.CountDownLatch; | ||
36 | -import java.util.concurrent.TimeUnit; | ||
37 | - | ||
38 | import org.easymock.IAnswer; | 19 | import org.easymock.IAnswer; |
39 | import org.junit.Before; | 20 | import org.junit.Before; |
40 | import org.junit.Test; | 21 | import org.junit.Test; |
... | @@ -66,7 +47,20 @@ import org.onosproject.sdnip.config.BgpPeer; | ... | @@ -66,7 +47,20 @@ import org.onosproject.sdnip.config.BgpPeer; |
66 | import org.onosproject.sdnip.config.Interface; | 47 | import org.onosproject.sdnip.config.Interface; |
67 | import org.onosproject.sdnip.config.SdnIpConfigurationService; | 48 | import org.onosproject.sdnip.config.SdnIpConfigurationService; |
68 | 49 | ||
69 | -import com.google.common.collect.Sets; | 50 | +import java.nio.ByteBuffer; |
51 | +import java.util.ArrayList; | ||
52 | +import java.util.HashMap; | ||
53 | +import java.util.HashSet; | ||
54 | +import java.util.List; | ||
55 | +import java.util.Map; | ||
56 | +import java.util.Random; | ||
57 | +import java.util.Set; | ||
58 | +import java.util.concurrent.CountDownLatch; | ||
59 | +import java.util.concurrent.TimeUnit; | ||
60 | + | ||
61 | +import static org.easymock.EasyMock.*; | ||
62 | +import static org.junit.Assert.assertEquals; | ||
63 | +import static org.junit.Assert.assertNotNull; | ||
70 | 64 | ||
71 | /** | 65 | /** |
72 | * Integration tests for the SDN-IP application. | 66 | * Integration tests for the SDN-IP application. |
... | @@ -130,9 +124,10 @@ public class SdnIpTest extends AbstractIntentTest { | ... | @@ -130,9 +124,10 @@ public class SdnIpTest extends AbstractIntentTest { |
130 | intentService = createMock(IntentService.class); | 124 | intentService = createMock(IntentService.class); |
131 | random = new Random(); | 125 | random = new Random(); |
132 | 126 | ||
133 | - intentSynchronizer = new IntentSynchronizer(APPID, intentService); | 127 | + intentSynchronizer = new IntentSynchronizer(APPID, intentService, |
134 | - router = new Router(APPID, intentSynchronizer, sdnIpConfigService, | 128 | + sdnIpConfigService, |
135 | - interfaceService, hostService); | 129 | + interfaceService); |
130 | + router = new Router(intentSynchronizer, hostService); | ||
136 | } | 131 | } |
137 | 132 | ||
138 | /** | 133 | /** | ... | ... |
-
Please register or login to post a comment