Committed by
Gerrit Code Review
Remove default flow rules for ROADMs. Fix LinkResource NPE. Single instance provisions optical path.
Change-Id: Iacbd41403ecd0c0df240d09026253c4b761a1d6a
Showing
5 changed files
with
61 additions
and
29 deletions
| ... | @@ -20,8 +20,11 @@ import org.apache.felix.scr.annotations.Activate; | ... | @@ -20,8 +20,11 @@ import org.apache.felix.scr.annotations.Activate; |
| 20 | import org.apache.felix.scr.annotations.Component; | 20 | import org.apache.felix.scr.annotations.Component; |
| 21 | import org.apache.felix.scr.annotations.Reference; | 21 | import org.apache.felix.scr.annotations.Reference; |
| 22 | import org.apache.felix.scr.annotations.ReferenceCardinality; | 22 | import org.apache.felix.scr.annotations.ReferenceCardinality; |
| 23 | +import org.onosproject.cluster.ClusterService; | ||
| 24 | +import org.onosproject.cluster.NodeId; | ||
| 23 | import org.onosproject.core.ApplicationId; | 25 | import org.onosproject.core.ApplicationId; |
| 24 | import org.onosproject.core.CoreService; | 26 | import org.onosproject.core.CoreService; |
| 27 | +import org.onosproject.mastership.MastershipService; | ||
| 25 | import org.onosproject.net.ConnectPoint; | 28 | import org.onosproject.net.ConnectPoint; |
| 26 | import org.onosproject.net.Host; | 29 | import org.onosproject.net.Host; |
| 27 | import org.onosproject.net.Link; | 30 | import org.onosproject.net.Link; |
| ... | @@ -74,6 +77,12 @@ public class OpticalPathProvisioner { | ... | @@ -74,6 +77,12 @@ public class OpticalPathProvisioner { |
| 74 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | 77 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
| 75 | protected HostService hostService; | 78 | protected HostService hostService; |
| 76 | 79 | ||
| 80 | + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | ||
| 81 | + protected MastershipService mastershipService; | ||
| 82 | + | ||
| 83 | + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | ||
| 84 | + protected ClusterService clusterService; | ||
| 85 | + | ||
| 77 | private ApplicationId appId; | 86 | private ApplicationId appId; |
| 78 | 87 | ||
| 79 | // TODO use a shared map for distributed operation | 88 | // TODO use a shared map for distributed operation |
| ... | @@ -89,11 +98,10 @@ public class OpticalPathProvisioner { | ... | @@ -89,11 +98,10 @@ public class OpticalPathProvisioner { |
| 89 | 98 | ||
| 90 | @Activate | 99 | @Activate |
| 91 | protected void activate() { | 100 | protected void activate() { |
| 92 | - // TODO elect a leader and have one instance do the provisioning | ||
| 93 | intentService.addListener(pathProvisioner); | 101 | intentService.addListener(pathProvisioner); |
| 94 | appId = coreService.registerApplication("org.onosproject.optical"); | 102 | appId = coreService.registerApplication("org.onosproject.optical"); |
| 95 | initTport(); | 103 | initTport(); |
| 96 | - log.info("Starting optical path provisoning..."); | 104 | + log.info("Starting optical path provisioning..."); |
| 97 | } | 105 | } |
| 98 | 106 | ||
| 99 | protected void initTport() { | 107 | protected void initTport() { |
| ... | @@ -178,17 +186,27 @@ public class OpticalPathProvisioner { | ... | @@ -178,17 +186,27 @@ public class OpticalPathProvisioner { |
| 178 | // Low speed LLDP may cause multiple calls which are not expected | 186 | // Low speed LLDP may cause multiple calls which are not expected |
| 179 | 187 | ||
| 180 | if (!IntentState.FAILED.equals(intentService.getIntentState(intent.key()))) { | 188 | if (!IntentState.FAILED.equals(intentService.getIntentState(intent.key()))) { |
| 181 | - return; | 189 | + return; |
| 182 | } | 190 | } |
| 183 | 191 | ||
| 192 | + NodeId localNode = clusterService.getLocalNode().id(); | ||
| 193 | + | ||
| 184 | List<Intent> intents = Lists.newArrayList(); | 194 | List<Intent> intents = Lists.newArrayList(); |
| 185 | if (intent instanceof HostToHostIntent) { | 195 | if (intent instanceof HostToHostIntent) { |
| 186 | HostToHostIntent hostToHostIntent = (HostToHostIntent) intent; | 196 | HostToHostIntent hostToHostIntent = (HostToHostIntent) intent; |
| 197 | + | ||
| 187 | Host one = hostService.getHost(hostToHostIntent.one()); | 198 | Host one = hostService.getHost(hostToHostIntent.one()); |
| 188 | Host two = hostService.getHost(hostToHostIntent.two()); | 199 | Host two = hostService.getHost(hostToHostIntent.two()); |
| 189 | if (one == null || two == null) { | 200 | if (one == null || two == null) { |
| 190 | return; //FIXME | 201 | return; //FIXME |
| 191 | } | 202 | } |
| 203 | + | ||
| 204 | + // Ignore if we're not the master for the intent's origin device | ||
| 205 | + NodeId sourceMaster = mastershipService.getMasterFor(one.location().deviceId()); | ||
| 206 | + if (!localNode.equals(sourceMaster)) { | ||
| 207 | + return; | ||
| 208 | + } | ||
| 209 | + | ||
| 192 | // provision both directions | 210 | // provision both directions |
| 193 | intents.addAll(getOpticalPath(one.location(), two.location())); | 211 | intents.addAll(getOpticalPath(one.location(), two.location())); |
| 194 | // note: bi-directional intent is set up | 212 | // note: bi-directional intent is set up |
| ... | @@ -196,6 +214,13 @@ public class OpticalPathProvisioner { | ... | @@ -196,6 +214,13 @@ public class OpticalPathProvisioner { |
| 196 | //intents.addAll(getOpticalPath(two.location(), one.location())); | 214 | //intents.addAll(getOpticalPath(two.location(), one.location())); |
| 197 | } else if (intent instanceof PointToPointIntent) { | 215 | } else if (intent instanceof PointToPointIntent) { |
| 198 | PointToPointIntent p2pIntent = (PointToPointIntent) intent; | 216 | PointToPointIntent p2pIntent = (PointToPointIntent) intent; |
| 217 | + | ||
| 218 | + // Ignore if we're not the master for the intent's origin device | ||
| 219 | + NodeId sourceMaster = mastershipService.getMasterFor(p2pIntent.ingressPoint().deviceId()); | ||
| 220 | + if (!localNode.equals(sourceMaster)) { | ||
| 221 | + return; | ||
| 222 | + } | ||
| 223 | + | ||
| 199 | intents.addAll(getOpticalPath(p2pIntent.ingressPoint(), p2pIntent.egressPoint())); | 224 | intents.addAll(getOpticalPath(p2pIntent.ingressPoint(), p2pIntent.egressPoint())); |
| 200 | } else { | 225 | } else { |
| 201 | log.info("Unsupported intent type: {}", intent.getClass()); | 226 | log.info("Unsupported intent type: {}", intent.getClass()); | ... | ... |
| ... | @@ -220,6 +220,11 @@ implements PacketService, PacketProviderRegistry { | ... | @@ -220,6 +220,11 @@ implements PacketService, PacketProviderRegistry { |
| 220 | * @param request the packet request | 220 | * @param request the packet request |
| 221 | */ | 221 | */ |
| 222 | private void pushRule(Device device, PacketRequest request) { | 222 | private void pushRule(Device device, PacketRequest request) { |
| 223 | + // Everything is pre-provisioned on ROADMs | ||
| 224 | + if (device.type().equals(Device.Type.ROADM)) { | ||
| 225 | + return; | ||
| 226 | + } | ||
| 227 | + | ||
| 223 | TrafficTreatment treatment = DefaultTrafficTreatment.builder() | 228 | TrafficTreatment treatment = DefaultTrafficTreatment.builder() |
| 224 | .punt() | 229 | .punt() |
| 225 | .build(); | 230 | .build(); | ... | ... |
| ... | @@ -15,17 +15,6 @@ | ... | @@ -15,17 +15,6 @@ |
| 15 | */ | 15 | */ |
| 16 | package org.onosproject.net.resource.impl; | 16 | package org.onosproject.net.resource.impl; |
| 17 | 17 | ||
| 18 | -import static com.google.common.base.Preconditions.checkArgument; | ||
| 19 | -import static com.google.common.base.Preconditions.checkNotNull; | ||
| 20 | -import static org.slf4j.LoggerFactory.getLogger; | ||
| 21 | - | ||
| 22 | -import java.util.Collections; | ||
| 23 | -import java.util.HashMap; | ||
| 24 | -import java.util.HashSet; | ||
| 25 | -import java.util.Iterator; | ||
| 26 | -import java.util.Map; | ||
| 27 | -import java.util.Set; | ||
| 28 | - | ||
| 29 | import org.apache.felix.scr.annotations.Activate; | 18 | import org.apache.felix.scr.annotations.Activate; |
| 30 | import org.apache.felix.scr.annotations.Component; | 19 | import org.apache.felix.scr.annotations.Component; |
| 31 | import org.apache.felix.scr.annotations.Deactivate; | 20 | import org.apache.felix.scr.annotations.Deactivate; |
| ... | @@ -57,6 +46,17 @@ import org.onosproject.net.resource.ResourceRequest; | ... | @@ -57,6 +46,17 @@ import org.onosproject.net.resource.ResourceRequest; |
| 57 | import org.onosproject.net.resource.ResourceType; | 46 | import org.onosproject.net.resource.ResourceType; |
| 58 | import org.slf4j.Logger; | 47 | import org.slf4j.Logger; |
| 59 | 48 | ||
| 49 | +import java.util.Collections; | ||
| 50 | +import java.util.HashMap; | ||
| 51 | +import java.util.HashSet; | ||
| 52 | +import java.util.Iterator; | ||
| 53 | +import java.util.Map; | ||
| 54 | +import java.util.Set; | ||
| 55 | + | ||
| 56 | +import static com.google.common.base.Preconditions.checkArgument; | ||
| 57 | +import static com.google.common.base.Preconditions.checkNotNull; | ||
| 58 | +import static org.slf4j.LoggerFactory.getLogger; | ||
| 59 | + | ||
| 60 | /** | 60 | /** |
| 61 | * Provides basic implementation of link resources allocation. | 61 | * Provides basic implementation of link resources allocation. |
| 62 | */ | 62 | */ |
| ... | @@ -197,7 +197,10 @@ public class LinkResourceManager implements LinkResourceService { | ... | @@ -197,7 +197,10 @@ public class LinkResourceManager implements LinkResourceService { |
| 197 | Map<Link, Set<ResourceAllocation>> allocations = new HashMap<>(); | 197 | Map<Link, Set<ResourceAllocation>> allocations = new HashMap<>(); |
| 198 | for (Link link : req.links()) { | 198 | for (Link link : req.links()) { |
| 199 | allocations.put(link, new HashSet<ResourceAllocation>(allocs)); | 199 | allocations.put(link, new HashSet<ResourceAllocation>(allocs)); |
| 200 | - allocations.get(link).addAll(allocsPerLink.get(link)); | 200 | + Set<ResourceAllocation> linkAllocs = allocsPerLink.get(link); |
| 201 | + if (linkAllocs != null) { | ||
| 202 | + allocations.get(link).addAll(linkAllocs); | ||
| 203 | + } | ||
| 201 | } | 204 | } |
| 202 | LinkResourceAllocations result = | 205 | LinkResourceAllocations result = |
| 203 | new DefaultLinkResourceAllocations(req, allocations); | 206 | new DefaultLinkResourceAllocations(req, allocations); | ... | ... |
| ... | @@ -90,7 +90,7 @@ public class LLDPLinkProvider extends AbstractProvider implements LinkProvider { | ... | @@ -90,7 +90,7 @@ public class LLDPLinkProvider extends AbstractProvider implements LinkProvider { |
| 90 | protected DeviceService deviceService; | 90 | protected DeviceService deviceService; |
| 91 | 91 | ||
| 92 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | 92 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
| 93 | - protected PacketService packetSevice; | 93 | + protected PacketService packetService; |
| 94 | 94 | ||
| 95 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | 95 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
| 96 | protected MastershipService masterService; | 96 | protected MastershipService masterService; |
| ... | @@ -143,7 +143,7 @@ public class LLDPLinkProvider extends AbstractProvider implements LinkProvider { | ... | @@ -143,7 +143,7 @@ public class LLDPLinkProvider extends AbstractProvider implements LinkProvider { |
| 143 | 143 | ||
| 144 | providerService = providerRegistry.register(this); | 144 | providerService = providerRegistry.register(this); |
| 145 | deviceService.addListener(listener); | 145 | deviceService.addListener(listener); |
| 146 | - packetSevice.addProcessor(listener, 0); | 146 | + packetService.addProcessor(listener, 0); |
| 147 | masterService.addListener(roleListener); | 147 | masterService.addListener(roleListener); |
| 148 | 148 | ||
| 149 | LinkDiscovery ld; | 149 | LinkDiscovery ld; |
| ... | @@ -152,7 +152,7 @@ public class LLDPLinkProvider extends AbstractProvider implements LinkProvider { | ... | @@ -152,7 +152,7 @@ public class LLDPLinkProvider extends AbstractProvider implements LinkProvider { |
| 152 | log.debug("LinkDiscovery from {} disabled by configuration", device.id()); | 152 | log.debug("LinkDiscovery from {} disabled by configuration", device.id()); |
| 153 | continue; | 153 | continue; |
| 154 | } | 154 | } |
| 155 | - ld = new LinkDiscovery(device, packetSevice, masterService, | 155 | + ld = new LinkDiscovery(device, packetService, masterService, |
| 156 | providerService, useBDDP); | 156 | providerService, useBDDP); |
| 157 | discoverers.put(device.id(), ld); | 157 | discoverers.put(device.id(), ld); |
| 158 | for (Port p : deviceService.getPorts(device.id())) { | 158 | for (Port p : deviceService.getPorts(device.id())) { |
| ... | @@ -186,7 +186,7 @@ public class LLDPLinkProvider extends AbstractProvider implements LinkProvider { | ... | @@ -186,7 +186,7 @@ public class LLDPLinkProvider extends AbstractProvider implements LinkProvider { |
| 186 | } | 186 | } |
| 187 | providerRegistry.unregister(this); | 187 | providerRegistry.unregister(this); |
| 188 | deviceService.removeListener(listener); | 188 | deviceService.removeListener(listener); |
| 189 | - packetSevice.removeProcessor(listener); | 189 | + packetService.removeProcessor(listener); |
| 190 | masterService.removeListener(roleListener); | 190 | masterService.removeListener(roleListener); |
| 191 | providerService = null; | 191 | providerService = null; |
| 192 | 192 | ||
| ... | @@ -237,14 +237,14 @@ public class LLDPLinkProvider extends AbstractProvider implements LinkProvider { | ... | @@ -237,14 +237,14 @@ public class LLDPLinkProvider extends AbstractProvider implements LinkProvider { |
| 237 | private void requestPackets() { | 237 | private void requestPackets() { |
| 238 | TrafficSelector.Builder lldpSelector = DefaultTrafficSelector.builder(); | 238 | TrafficSelector.Builder lldpSelector = DefaultTrafficSelector.builder(); |
| 239 | lldpSelector.matchEthType(Ethernet.TYPE_LLDP); | 239 | lldpSelector.matchEthType(Ethernet.TYPE_LLDP); |
| 240 | - packetSevice.requestPackets(lldpSelector.build(), | 240 | + packetService.requestPackets(lldpSelector.build(), |
| 241 | - PacketPriority.CONTROL, appId); | 241 | + PacketPriority.CONTROL, appId); |
| 242 | 242 | ||
| 243 | if (useBDDP) { | 243 | if (useBDDP) { |
| 244 | TrafficSelector.Builder bddpSelector = DefaultTrafficSelector.builder(); | 244 | TrafficSelector.Builder bddpSelector = DefaultTrafficSelector.builder(); |
| 245 | bddpSelector.matchEthType(Ethernet.TYPE_BSN); | 245 | bddpSelector.matchEthType(Ethernet.TYPE_BSN); |
| 246 | - packetSevice.requestPackets(bddpSelector.build(), | 246 | + packetService.requestPackets(bddpSelector.build(), |
| 247 | - PacketPriority.CONTROL, appId); | 247 | + PacketPriority.CONTROL, appId); |
| 248 | } | 248 | } |
| 249 | } | 249 | } |
| 250 | 250 | ||
| ... | @@ -273,7 +273,7 @@ public class LLDPLinkProvider extends AbstractProvider implements LinkProvider { | ... | @@ -273,7 +273,7 @@ public class LLDPLinkProvider extends AbstractProvider implements LinkProvider { |
| 273 | log.debug("Device mastership changed ({}) {}", | 273 | log.debug("Device mastership changed ({}) {}", |
| 274 | event.type(), deviceId); | 274 | event.type(), deviceId); |
| 275 | discoverers.put(deviceId, new LinkDiscovery(device, | 275 | discoverers.put(deviceId, new LinkDiscovery(device, |
| 276 | - packetSevice, masterService, providerService, | 276 | + packetService, masterService, providerService, |
| 277 | useBDDP)); | 277 | useBDDP)); |
| 278 | } | 278 | } |
| 279 | } | 279 | } |
| ... | @@ -307,8 +307,7 @@ public class LLDPLinkProvider extends AbstractProvider implements LinkProvider { | ... | @@ -307,8 +307,7 @@ public class LLDPLinkProvider extends AbstractProvider implements LinkProvider { |
| 307 | log.debug("Device added ({}) {}", event.type(), | 307 | log.debug("Device added ({}) {}", event.type(), |
| 308 | deviceId); | 308 | deviceId); |
| 309 | discoverers.put(deviceId, new LinkDiscovery(device, | 309 | discoverers.put(deviceId, new LinkDiscovery(device, |
| 310 | - packetSevice, masterService, providerService, | 310 | + packetService, masterService, providerService, useBDDP)); |
| 311 | - useBDDP)); | ||
| 312 | } else { | 311 | } else { |
| 313 | if (ld.isStopped()) { | 312 | if (ld.isStopped()) { |
| 314 | log.debug("Device restarted ({}) {}", event.type(), | 313 | log.debug("Device restarted ({}) {}", event.type(), |
| ... | @@ -412,7 +411,7 @@ public class LLDPLinkProvider extends AbstractProvider implements LinkProvider { | ... | @@ -412,7 +411,7 @@ public class LLDPLinkProvider extends AbstractProvider implements LinkProvider { |
| 412 | DeviceId did = dev.id(); | 411 | DeviceId did = dev.id(); |
| 413 | synchronized (discoverers) { | 412 | synchronized (discoverers) { |
| 414 | if (!discoverers.containsKey(did)) { | 413 | if (!discoverers.containsKey(did)) { |
| 415 | - ld = new LinkDiscovery(dev, packetSevice, | 414 | + ld = new LinkDiscovery(dev, packetService, |
| 416 | masterService, providerService, useBDDP); | 415 | masterService, providerService, useBDDP); |
| 417 | discoverers.put(did, ld); | 416 | discoverers.put(did, ld); |
| 418 | for (Port p : deviceService.getPorts(did)) { | 417 | for (Port p : deviceService.getPorts(did)) { | ... | ... |
| ... | @@ -112,7 +112,7 @@ public class LLDPLinkProviderTest { | ... | @@ -112,7 +112,7 @@ public class LLDPLinkProviderTest { |
| 112 | provider.coreService = coreService; | 112 | provider.coreService = coreService; |
| 113 | 113 | ||
| 114 | provider.deviceService = deviceService; | 114 | provider.deviceService = deviceService; |
| 115 | - provider.packetSevice = packetService; | 115 | + provider.packetService = packetService; |
| 116 | provider.providerRegistry = linkService; | 116 | provider.providerRegistry = linkService; |
| 117 | provider.masterService = masterService; | 117 | provider.masterService = masterService; |
| 118 | 118 | ||
| ... | @@ -204,7 +204,7 @@ public class LLDPLinkProviderTest { | ... | @@ -204,7 +204,7 @@ public class LLDPLinkProviderTest { |
| 204 | provider.coreService = null; | 204 | provider.coreService = null; |
| 205 | provider.providerRegistry = null; | 205 | provider.providerRegistry = null; |
| 206 | provider.deviceService = null; | 206 | provider.deviceService = null; |
| 207 | - provider.packetSevice = null; | 207 | + provider.packetService = null; |
| 208 | } | 208 | } |
| 209 | 209 | ||
| 210 | private DeviceEvent deviceEvent(DeviceEvent.Type type, DeviceId did) { | 210 | private DeviceEvent deviceEvent(DeviceEvent.Type type, DeviceId did) { | ... | ... |
-
Please register or login to post a comment