Committed by
Pavlin Radoslavov
Javadoc and code cleanup for SDN-IP
Change-Id: I4b2cd853cb2c91ace2c710b215a7b2dca9301c28
Showing
6 changed files
with
65 additions
and
60 deletions
... | @@ -15,6 +15,8 @@ | ... | @@ -15,6 +15,8 @@ |
15 | */ | 15 | */ |
16 | package org.onosproject.sdnip; | 16 | package org.onosproject.sdnip; |
17 | 17 | ||
18 | +import static com.google.common.base.Preconditions.checkArgument; | ||
19 | + | ||
18 | import java.util.Collection; | 20 | import java.util.Collection; |
19 | import java.util.HashMap; | 21 | import java.util.HashMap; |
20 | import java.util.LinkedList; | 22 | import java.util.LinkedList; |
... | @@ -27,6 +29,7 @@ import java.util.concurrent.Executors; | ... | @@ -27,6 +29,7 @@ import java.util.concurrent.Executors; |
27 | import java.util.concurrent.Semaphore; | 29 | import java.util.concurrent.Semaphore; |
28 | 30 | ||
29 | import org.apache.commons.lang3.tuple.Pair; | 31 | import org.apache.commons.lang3.tuple.Pair; |
32 | +import org.onlab.packet.Ip4Prefix; | ||
30 | import org.onosproject.core.ApplicationId; | 33 | import org.onosproject.core.ApplicationId; |
31 | import org.onosproject.net.flow.criteria.Criteria.IPCriterion; | 34 | import org.onosproject.net.flow.criteria.Criteria.IPCriterion; |
32 | import org.onosproject.net.flow.criteria.Criterion; | 35 | import org.onosproject.net.flow.criteria.Criterion; |
... | @@ -36,14 +39,15 @@ import org.onosproject.net.intent.IntentService; | ... | @@ -36,14 +39,15 @@ import org.onosproject.net.intent.IntentService; |
36 | import org.onosproject.net.intent.IntentState; | 39 | import org.onosproject.net.intent.IntentState; |
37 | import org.onosproject.net.intent.MultiPointToSinglePointIntent; | 40 | import org.onosproject.net.intent.MultiPointToSinglePointIntent; |
38 | import org.onosproject.net.intent.PointToPointIntent; | 41 | import org.onosproject.net.intent.PointToPointIntent; |
39 | -import org.onlab.packet.Ip4Prefix; | ||
40 | import org.slf4j.Logger; | 42 | import org.slf4j.Logger; |
41 | import org.slf4j.LoggerFactory; | 43 | import org.slf4j.LoggerFactory; |
42 | 44 | ||
43 | import com.google.common.util.concurrent.ThreadFactoryBuilder; | 45 | import com.google.common.util.concurrent.ThreadFactoryBuilder; |
44 | 46 | ||
45 | -import static com.google.common.base.Preconditions.checkArgument; | 47 | +/** |
46 | - | 48 | + * Synchronizes intents between the in-memory intent store and the |
49 | + * IntentService. | ||
50 | + */ | ||
47 | public class IntentSynchronizer { | 51 | public class IntentSynchronizer { |
48 | private static final Logger log = | 52 | private static final Logger log = |
49 | LoggerFactory.getLogger(IntentSynchronizer.class); | 53 | LoggerFactory.getLogger(IntentSynchronizer.class); |
... | @@ -148,6 +152,11 @@ public class IntentSynchronizer { | ... | @@ -148,6 +152,11 @@ public class IntentSynchronizer { |
148 | } | 152 | } |
149 | } | 153 | } |
150 | 154 | ||
155 | + /** | ||
156 | + * Signals the synchronizer that the SDN-IP leadership has changed. | ||
157 | + * | ||
158 | + * @param isLeader true if this instance is now the leader, otherwise false | ||
159 | + */ | ||
151 | public void leaderChanged(boolean isLeader) { | 160 | public void leaderChanged(boolean isLeader) { |
152 | log.debug("SDN-IP Leader changed: {}", isLeader); | 161 | log.debug("SDN-IP Leader changed: {}", isLeader); |
153 | 162 | ... | ... |
... | @@ -19,6 +19,10 @@ import java.util.ArrayList; | ... | @@ -19,6 +19,10 @@ import java.util.ArrayList; |
19 | import java.util.Collection; | 19 | import java.util.Collection; |
20 | import java.util.List; | 20 | import java.util.List; |
21 | 21 | ||
22 | +import org.onlab.packet.Ethernet; | ||
23 | +import org.onlab.packet.IPv4; | ||
24 | +import org.onlab.packet.IpAddress; | ||
25 | +import org.onlab.packet.IpPrefix; | ||
22 | import org.onosproject.core.ApplicationId; | 26 | import org.onosproject.core.ApplicationId; |
23 | import org.onosproject.net.ConnectPoint; | 27 | import org.onosproject.net.ConnectPoint; |
24 | import org.onosproject.net.flow.DefaultTrafficSelector; | 28 | import org.onosproject.net.flow.DefaultTrafficSelector; |
... | @@ -32,10 +36,6 @@ import org.onosproject.sdnip.config.BgpSpeaker; | ... | @@ -32,10 +36,6 @@ import org.onosproject.sdnip.config.BgpSpeaker; |
32 | import org.onosproject.sdnip.config.Interface; | 36 | import org.onosproject.sdnip.config.Interface; |
33 | import org.onosproject.sdnip.config.InterfaceAddress; | 37 | import org.onosproject.sdnip.config.InterfaceAddress; |
34 | import org.onosproject.sdnip.config.SdnIpConfigurationService; | 38 | import org.onosproject.sdnip.config.SdnIpConfigurationService; |
35 | -import org.onlab.packet.Ethernet; | ||
36 | -import org.onlab.packet.IPv4; | ||
37 | -import org.onlab.packet.IpAddress; | ||
38 | -import org.onlab.packet.IpPrefix; | ||
39 | import org.slf4j.Logger; | 39 | import org.slf4j.Logger; |
40 | import org.slf4j.LoggerFactory; | 40 | import org.slf4j.LoggerFactory; |
41 | 41 | ||
... | @@ -75,20 +75,12 @@ public class PeerConnectivityManager { | ... | @@ -75,20 +75,12 @@ public class PeerConnectivityManager { |
75 | * Starts the peer connectivity manager. | 75 | * Starts the peer connectivity manager. |
76 | */ | 76 | */ |
77 | public void start() { | 77 | public void start() { |
78 | - // TODO are any of these errors? | ||
79 | if (interfaceService.getInterfaces().isEmpty()) { | 78 | if (interfaceService.getInterfaces().isEmpty()) { |
80 | - | 79 | + log.warn("No interfaces found in configuration file"); |
81 | - log.warn("The interface in configuration file is empty. " | ||
82 | - + "Thus, the SDN-IP application can not be started."); | ||
83 | } else if (configService.getBgpPeers().isEmpty()) { | 80 | } else if (configService.getBgpPeers().isEmpty()) { |
84 | - | 81 | + log.warn("No BGP peers found in configuration file"); |
85 | - log.warn("The BGP peer in configuration file is empty." | 82 | + } else if (configService.getBgpSpeakers().isEmpty()) { |
86 | - + "Thus, the SDN-IP application can not be started."); | 83 | + log.error("No BGP speakers found in configuration file"); |
87 | - } else if (configService.getBgpSpeakers() == null) { | ||
88 | - | ||
89 | - log.error("The BGP speaker in configuration file is empty. " | ||
90 | - + "Thus, the SDN-IP application can not be started."); | ||
91 | - return; | ||
92 | } | 84 | } |
93 | 85 | ||
94 | setUpConnectivity(); | 86 | setUpConnectivity(); |
... | @@ -174,8 +166,7 @@ public class PeerConnectivityManager { | ... | @@ -174,8 +166,7 @@ public class PeerConnectivityManager { |
174 | 166 | ||
175 | TrafficSelector selector; | 167 | TrafficSelector selector; |
176 | 168 | ||
177 | - // install intent for BGP path from BGPd to BGP peer matching | 169 | + // Path from BGP speaker to BGP peer matching destination TCP port 179 |
178 | - // destination TCP port 179 | ||
179 | selector = buildSelector(IPv4.PROTOCOL_TCP, | 170 | selector = buildSelector(IPv4.PROTOCOL_TCP, |
180 | bgpdAddress, | 171 | bgpdAddress, |
181 | bgpdPeerAddress, | 172 | bgpdPeerAddress, |
... | @@ -185,8 +176,7 @@ public class PeerConnectivityManager { | ... | @@ -185,8 +176,7 @@ public class PeerConnectivityManager { |
185 | intents.add(new PointToPointIntent(appId, selector, treatment, | 176 | intents.add(new PointToPointIntent(appId, selector, treatment, |
186 | bgpdConnectPoint, bgpdPeerConnectPoint)); | 177 | bgpdConnectPoint, bgpdPeerConnectPoint)); |
187 | 178 | ||
188 | - // install intent for BGP path from BGPd to BGP peer matching | 179 | + // Path from BGP speaker to BGP peer matching source TCP port 179 |
189 | - // source TCP port 179 | ||
190 | selector = buildSelector(IPv4.PROTOCOL_TCP, | 180 | selector = buildSelector(IPv4.PROTOCOL_TCP, |
191 | bgpdAddress, | 181 | bgpdAddress, |
192 | bgpdPeerAddress, | 182 | bgpdPeerAddress, |
... | @@ -196,8 +186,7 @@ public class PeerConnectivityManager { | ... | @@ -196,8 +186,7 @@ public class PeerConnectivityManager { |
196 | intents.add(new PointToPointIntent(appId, selector, treatment, | 186 | intents.add(new PointToPointIntent(appId, selector, treatment, |
197 | bgpdConnectPoint, bgpdPeerConnectPoint)); | 187 | bgpdConnectPoint, bgpdPeerConnectPoint)); |
198 | 188 | ||
199 | - // install intent for reversed BGP path from BGP peer to BGPd | 189 | + // Path from BGP peer to BGP speaker matching destination TCP port 179 |
200 | - // matching destination TCP port 179 | ||
201 | selector = buildSelector(IPv4.PROTOCOL_TCP, | 190 | selector = buildSelector(IPv4.PROTOCOL_TCP, |
202 | bgpdPeerAddress, | 191 | bgpdPeerAddress, |
203 | bgpdAddress, | 192 | bgpdAddress, |
... | @@ -207,8 +196,7 @@ public class PeerConnectivityManager { | ... | @@ -207,8 +196,7 @@ public class PeerConnectivityManager { |
207 | intents.add(new PointToPointIntent(appId, selector, treatment, | 196 | intents.add(new PointToPointIntent(appId, selector, treatment, |
208 | bgpdPeerConnectPoint, bgpdConnectPoint)); | 197 | bgpdPeerConnectPoint, bgpdConnectPoint)); |
209 | 198 | ||
210 | - // install intent for reversed BGP path from BGP peer to BGPd | 199 | + // Path from BGP peer to BGP speaker matching source TCP port 179 |
211 | - // matching source TCP port 179 | ||
212 | selector = buildSelector(IPv4.PROTOCOL_TCP, | 200 | selector = buildSelector(IPv4.PROTOCOL_TCP, |
213 | bgpdPeerAddress, | 201 | bgpdPeerAddress, |
214 | bgpdAddress, | 202 | bgpdAddress, |
... | @@ -218,7 +206,7 @@ public class PeerConnectivityManager { | ... | @@ -218,7 +206,7 @@ public class PeerConnectivityManager { |
218 | intents.add(new PointToPointIntent(appId, selector, treatment, | 206 | intents.add(new PointToPointIntent(appId, selector, treatment, |
219 | bgpdPeerConnectPoint, bgpdConnectPoint)); | 207 | bgpdPeerConnectPoint, bgpdConnectPoint)); |
220 | 208 | ||
221 | - // install intent for ICMP path from BGPd to BGP peer | 209 | + // ICMP path from BGP speaker to BGP peer |
222 | selector = buildSelector(IPv4.PROTOCOL_ICMP, | 210 | selector = buildSelector(IPv4.PROTOCOL_ICMP, |
223 | bgpdAddress, | 211 | bgpdAddress, |
224 | bgpdPeerAddress, | 212 | bgpdPeerAddress, |
... | @@ -228,7 +216,7 @@ public class PeerConnectivityManager { | ... | @@ -228,7 +216,7 @@ public class PeerConnectivityManager { |
228 | intents.add(new PointToPointIntent(appId, selector, treatment, | 216 | intents.add(new PointToPointIntent(appId, selector, treatment, |
229 | bgpdConnectPoint, bgpdPeerConnectPoint)); | 217 | bgpdConnectPoint, bgpdPeerConnectPoint)); |
230 | 218 | ||
231 | - // install intent for reversed ICMP path from BGP peer to BGPd | 219 | + // ICMP path from BGP peer to BGP speaker |
232 | selector = buildSelector(IPv4.PROTOCOL_ICMP, | 220 | selector = buildSelector(IPv4.PROTOCOL_ICMP, |
233 | bgpdPeerAddress, | 221 | bgpdPeerAddress, |
234 | bgpdAddress, | 222 | bgpdAddress, | ... | ... |
... | @@ -180,6 +180,13 @@ public class SdnIp implements SdnIpService { | ... | @@ -180,6 +180,13 @@ public class SdnIp implements SdnIpService { |
180 | intentSynchronizer.leaderChanged(isPrimary); | 180 | intentSynchronizer.leaderChanged(isPrimary); |
181 | } | 181 | } |
182 | 182 | ||
183 | + /** | ||
184 | + * Converts DPIDs of the form xx:xx:xx:xx:xx:xx:xx to OpenFlow provider | ||
185 | + * device URIs. | ||
186 | + * | ||
187 | + * @param dpid the DPID string to convert | ||
188 | + * @return the URI string for this device | ||
189 | + */ | ||
183 | static String dpidToUri(String dpid) { | 190 | static String dpidToUri(String dpid) { |
184 | return "of:" + dpid.replace(":", ""); | 191 | return "of:" + dpid.replace(":", ""); |
185 | } | 192 | } | ... | ... |
... | @@ -20,8 +20,7 @@ import java.util.Map; | ... | @@ -20,8 +20,7 @@ import java.util.Map; |
20 | import org.onlab.packet.IpAddress; | 20 | import org.onlab.packet.IpAddress; |
21 | 21 | ||
22 | /** | 22 | /** |
23 | - * Provides information about the layer 3 properties of the network. | 23 | + * Provides information about the BGP elements configured in the network. |
24 | - * This is based on IP addresses configured on ports in the network. | ||
25 | */ | 24 | */ |
26 | public interface SdnIpConfigurationService { | 25 | public interface SdnIpConfigurationService { |
27 | 26 | ... | ... |
... | @@ -15,12 +15,29 @@ | ... | @@ -15,12 +15,29 @@ |
15 | */ | 15 | */ |
16 | package org.onosproject.sdnip; | 16 | package org.onosproject.sdnip; |
17 | 17 | ||
18 | -import com.google.common.collect.Sets; | 18 | +import static org.easymock.EasyMock.createMock; |
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 | + | ||
19 | import org.junit.Before; | 31 | import org.junit.Before; |
20 | import org.junit.Ignore; | 32 | import org.junit.Ignore; |
21 | import org.junit.Test; | 33 | import org.junit.Test; |
22 | import org.onlab.junit.TestUtils; | 34 | import org.onlab.junit.TestUtils; |
23 | import org.onlab.junit.TestUtils.TestUtilsException; | 35 | import org.onlab.junit.TestUtils.TestUtilsException; |
36 | +import org.onlab.packet.Ethernet; | ||
37 | +import org.onlab.packet.IPv4; | ||
38 | +import org.onlab.packet.IpAddress; | ||
39 | +import org.onlab.packet.IpPrefix; | ||
40 | +import org.onlab.packet.MacAddress; | ||
24 | import org.onosproject.core.ApplicationId; | 41 | import org.onosproject.core.ApplicationId; |
25 | import org.onosproject.net.ConnectPoint; | 42 | import org.onosproject.net.ConnectPoint; |
26 | import org.onosproject.net.DeviceId; | 43 | import org.onosproject.net.DeviceId; |
... | @@ -41,23 +58,11 @@ import org.onosproject.sdnip.config.BgpSpeaker; | ... | @@ -41,23 +58,11 @@ import org.onosproject.sdnip.config.BgpSpeaker; |
41 | import org.onosproject.sdnip.config.Interface; | 58 | import org.onosproject.sdnip.config.Interface; |
42 | import org.onosproject.sdnip.config.InterfaceAddress; | 59 | import org.onosproject.sdnip.config.InterfaceAddress; |
43 | import org.onosproject.sdnip.config.SdnIpConfigurationService; | 60 | import org.onosproject.sdnip.config.SdnIpConfigurationService; |
44 | -import org.onlab.packet.Ethernet; | ||
45 | -import org.onlab.packet.IPv4; | ||
46 | -import org.onlab.packet.IpAddress; | ||
47 | -import org.onlab.packet.IpPrefix; | ||
48 | -import org.onlab.packet.MacAddress; | ||
49 | - | ||
50 | -import java.util.ArrayList; | ||
51 | -import java.util.Collections; | ||
52 | -import java.util.HashMap; | ||
53 | -import java.util.LinkedList; | ||
54 | -import java.util.List; | ||
55 | -import java.util.Map; | ||
56 | 61 | ||
57 | -import static org.easymock.EasyMock.*; | 62 | +import com.google.common.collect.Sets; |
58 | 63 | ||
59 | /** | 64 | /** |
60 | - * Unit tests for PeerConnectivityManager interface. | 65 | + * Unit tests for PeerConnectivityManager. |
61 | */ | 66 | */ |
62 | public class PeerConnectivityManagerTest extends AbstractIntentTest { | 67 | public class PeerConnectivityManagerTest extends AbstractIntentTest { |
63 | 68 | ||
... | @@ -647,10 +652,12 @@ public class PeerConnectivityManagerTest extends AbstractIntentTest { | ... | @@ -647,10 +652,12 @@ public class PeerConnectivityManagerTest extends AbstractIntentTest { |
647 | expect(configInfoService.getBgpPeers()).andReturn( | 652 | expect(configInfoService.getBgpPeers()).andReturn( |
648 | peers).anyTimes(); | 653 | peers).anyTimes(); |
649 | expect(configInfoService.getBgpSpeakers()).andReturn( | 654 | expect(configInfoService.getBgpSpeakers()).andReturn( |
650 | - null).anyTimes(); | 655 | + Collections.emptyMap()).anyTimes(); |
651 | replay(configInfoService); | 656 | replay(configInfoService); |
652 | 657 | ||
653 | reset(intentService); | 658 | reset(intentService); |
659 | + IntentOperations.Builder builder = IntentOperations.builder(APPID); | ||
660 | + intentService.execute(builder.build()); | ||
654 | replay(intentService); | 661 | replay(intentService); |
655 | peerConnectivityManager.start(); | 662 | peerConnectivityManager.start(); |
656 | verify(intentService); | 663 | verify(intentService); | ... | ... |
... | @@ -35,6 +35,13 @@ import org.junit.Before; | ... | @@ -35,6 +35,13 @@ import org.junit.Before; |
35 | import org.junit.Test; | 35 | import org.junit.Test; |
36 | import org.onlab.junit.TestUtils; | 36 | import org.onlab.junit.TestUtils; |
37 | import org.onlab.junit.TestUtils.TestUtilsException; | 37 | import org.onlab.junit.TestUtils.TestUtilsException; |
38 | +import org.onlab.packet.Ethernet; | ||
39 | +import org.onlab.packet.Ip4Address; | ||
40 | +import org.onlab.packet.Ip4Prefix; | ||
41 | +import org.onlab.packet.IpAddress; | ||
42 | +import org.onlab.packet.IpPrefix; | ||
43 | +import org.onlab.packet.MacAddress; | ||
44 | +import org.onlab.packet.VlanId; | ||
38 | import org.onosproject.core.ApplicationId; | 45 | import org.onosproject.core.ApplicationId; |
39 | import org.onosproject.net.ConnectPoint; | 46 | import org.onosproject.net.ConnectPoint; |
40 | import org.onosproject.net.DefaultHost; | 47 | import org.onosproject.net.DefaultHost; |
... | @@ -50,23 +57,16 @@ import org.onosproject.net.flow.TrafficTreatment; | ... | @@ -50,23 +57,16 @@ import org.onosproject.net.flow.TrafficTreatment; |
50 | import org.onosproject.net.host.HostListener; | 57 | import org.onosproject.net.host.HostListener; |
51 | import org.onosproject.net.host.HostService; | 58 | import org.onosproject.net.host.HostService; |
52 | import org.onosproject.net.host.InterfaceIpAddress; | 59 | import org.onosproject.net.host.InterfaceIpAddress; |
60 | +import org.onosproject.net.intent.AbstractIntentTest; | ||
53 | import org.onosproject.net.intent.Intent; | 61 | import org.onosproject.net.intent.Intent; |
54 | import org.onosproject.net.intent.IntentOperations; | 62 | import org.onosproject.net.intent.IntentOperations; |
55 | import org.onosproject.net.intent.IntentService; | 63 | import org.onosproject.net.intent.IntentService; |
56 | import org.onosproject.net.intent.MultiPointToSinglePointIntent; | 64 | import org.onosproject.net.intent.MultiPointToSinglePointIntent; |
57 | -import org.onosproject.net.intent.AbstractIntentTest; | ||
58 | import org.onosproject.net.provider.ProviderId; | 65 | import org.onosproject.net.provider.ProviderId; |
59 | import org.onosproject.sdnip.IntentSynchronizer.IntentKey; | 66 | import org.onosproject.sdnip.IntentSynchronizer.IntentKey; |
60 | import org.onosproject.sdnip.config.BgpPeer; | 67 | import org.onosproject.sdnip.config.BgpPeer; |
61 | import org.onosproject.sdnip.config.Interface; | 68 | import org.onosproject.sdnip.config.Interface; |
62 | import org.onosproject.sdnip.config.SdnIpConfigurationService; | 69 | import org.onosproject.sdnip.config.SdnIpConfigurationService; |
63 | -import org.onlab.packet.Ethernet; | ||
64 | -import org.onlab.packet.IpAddress; | ||
65 | -import org.onlab.packet.Ip4Address; | ||
66 | -import org.onlab.packet.IpPrefix; | ||
67 | -import org.onlab.packet.Ip4Prefix; | ||
68 | -import org.onlab.packet.MacAddress; | ||
69 | -import org.onlab.packet.VlanId; | ||
70 | 70 | ||
71 | import com.google.common.collect.Sets; | 71 | import com.google.common.collect.Sets; |
72 | 72 | ||
... | @@ -302,11 +302,6 @@ public class RouterTest extends AbstractIntentTest { | ... | @@ -302,11 +302,6 @@ public class RouterTest extends AbstractIntentTest { |
302 | Intent addedIntent = | 302 | Intent addedIntent = |
303 | intentSynchronizer.getRouteIntents().iterator().next(); | 303 | intentSynchronizer.getRouteIntents().iterator().next(); |
304 | 304 | ||
305 | - // Construct the existing route entry | ||
306 | - RouteEntry routeEntry = new RouteEntry( | ||
307 | - Ip4Prefix.valueOf("1.1.1.0/24"), | ||
308 | - Ip4Address.valueOf("192.168.10.1")); | ||
309 | - | ||
310 | // Start to construct a new route entry and new intent | 305 | // Start to construct a new route entry and new intent |
311 | RouteEntry routeEntryUpdate = new RouteEntry( | 306 | RouteEntry routeEntryUpdate = new RouteEntry( |
312 | Ip4Prefix.valueOf("1.1.1.0/24"), | 307 | Ip4Prefix.valueOf("1.1.1.0/24"), | ... | ... |
-
Please register or login to post a comment