[ONOS-3643] Update VTNRSC's bug: when delete vm, the sfc'data is error.
Change-Id: Ib9357c2792b51270e935c2f1205c2311e9988793
Showing
4 changed files
with
107 additions
and
83 deletions
... | @@ -20,6 +20,7 @@ import java.util.Iterator; | ... | @@ -20,6 +20,7 @@ import java.util.Iterator; |
20 | import org.onlab.packet.MacAddress; | 20 | import org.onlab.packet.MacAddress; |
21 | import org.onosproject.net.Device; | 21 | import org.onosproject.net.Device; |
22 | import org.onosproject.net.DeviceId; | 22 | import org.onosproject.net.DeviceId; |
23 | +import org.onosproject.net.Host; | ||
23 | import org.onosproject.net.HostId; | 24 | import org.onosproject.net.HostId; |
24 | import org.onosproject.vtnrsc.SegmentationId; | 25 | import org.onosproject.vtnrsc.SegmentationId; |
25 | import org.onosproject.vtnrsc.TenantId; | 26 | import org.onosproject.vtnrsc.TenantId; |
... | @@ -69,4 +70,14 @@ public class VtnRscManagerTestImpl implements VtnRscService { | ... | @@ -69,4 +70,14 @@ public class VtnRscManagerTestImpl implements VtnRscService { |
69 | public DeviceId getSFToSFFMaping(VirtualPortId portId) { | 70 | public DeviceId getSFToSFFMaping(VirtualPortId portId) { |
70 | return DeviceId.deviceId("www.google.com"); | 71 | return DeviceId.deviceId("www.google.com"); |
71 | } | 72 | } |
73 | + | ||
74 | + @Override | ||
75 | + public void addDeviceIdOfOvsMap(VirtualPortId virtualPortId, | ||
76 | + TenantId tenantId, DeviceId deviceId) { | ||
77 | + } | ||
78 | + | ||
79 | + @Override | ||
80 | + public void removeDeviceIdOfOvsMap(Host host, TenantId tenantId, | ||
81 | + DeviceId deviceId) { | ||
82 | + } | ||
72 | } | 83 | } | ... | ... |
... | @@ -372,6 +372,7 @@ public class VTNManager implements VTNService { | ... | @@ -372,6 +372,7 @@ public class VTNManager implements VTNService { |
372 | log.error("The ifaceId of Host is null"); | 372 | log.error("The ifaceId of Host is null"); |
373 | return; | 373 | return; |
374 | } | 374 | } |
375 | + programSffAndClassifierHost(host, Objective.Operation.ADD); | ||
375 | // apply L2 openflow rules | 376 | // apply L2 openflow rules |
376 | applyHostMonitoredL2Rules(host, Objective.Operation.ADD); | 377 | applyHostMonitoredL2Rules(host, Objective.Operation.ADD); |
377 | // apply L3 openflow rules | 378 | // apply L3 openflow rules |
... | @@ -389,6 +390,7 @@ public class VTNManager implements VTNService { | ... | @@ -389,6 +390,7 @@ public class VTNManager implements VTNService { |
389 | log.error("The ifaceId of Host is null"); | 390 | log.error("The ifaceId of Host is null"); |
390 | return; | 391 | return; |
391 | } | 392 | } |
393 | + programSffAndClassifierHost(host, Objective.Operation.REMOVE); | ||
392 | // apply L2 openflow rules | 394 | // apply L2 openflow rules |
393 | applyHostMonitoredL2Rules(host, Objective.Operation.REMOVE); | 395 | applyHostMonitoredL2Rules(host, Objective.Operation.REMOVE); |
394 | // apply L3 openflow rules | 396 | // apply L3 openflow rules |
... | @@ -478,6 +480,22 @@ public class VTNManager implements VTNService { | ... | @@ -478,6 +480,22 @@ public class VTNManager implements VTNService { |
478 | } | 480 | } |
479 | } | 481 | } |
480 | 482 | ||
483 | + private void programSffAndClassifierHost(Host host, Objective.Operation type) { | ||
484 | + DeviceId deviceId = host.location().deviceId(); | ||
485 | + String ifaceId = host.annotations().value(IFACEID); | ||
486 | + VirtualPortId virtualPortId = VirtualPortId.portId(ifaceId); | ||
487 | + VirtualPort virtualPort = virtualPortService.getPort(virtualPortId); | ||
488 | + if (virtualPort == null) { | ||
489 | + virtualPort = VtnData.getPort(vPortStore, virtualPortId); | ||
490 | + } | ||
491 | + TenantId tenantId = virtualPort.tenantId(); | ||
492 | + if (Objective.Operation.ADD == type) { | ||
493 | + vtnRscService.addDeviceIdOfOvsMap(virtualPortId, tenantId, deviceId); | ||
494 | + } else if (Objective.Operation.REMOVE == type) { | ||
495 | + vtnRscService.removeDeviceIdOfOvsMap(host, tenantId, deviceId); | ||
496 | + } | ||
497 | + } | ||
498 | + | ||
481 | private void applyHostMonitoredL2Rules(Host host, Objective.Operation type) { | 499 | private void applyHostMonitoredL2Rules(Host host, Objective.Operation type) { |
482 | DeviceId deviceId = host.location().deviceId(); | 500 | DeviceId deviceId = host.location().deviceId(); |
483 | if (!mastershipService.isLocalMaster(deviceId)) { | 501 | if (!mastershipService.isLocalMaster(deviceId)) { | ... | ... |
... | @@ -21,6 +21,7 @@ import org.onlab.packet.MacAddress; | ... | @@ -21,6 +21,7 @@ import org.onlab.packet.MacAddress; |
21 | import org.onosproject.event.ListenerService; | 21 | import org.onosproject.event.ListenerService; |
22 | import org.onosproject.net.Device; | 22 | import org.onosproject.net.Device; |
23 | import org.onosproject.net.DeviceId; | 23 | import org.onosproject.net.DeviceId; |
24 | +import org.onosproject.net.Host; | ||
24 | import org.onosproject.net.HostId; | 25 | import org.onosproject.net.HostId; |
25 | import org.onosproject.vtnrsc.SegmentationId; | 26 | import org.onosproject.vtnrsc.SegmentationId; |
26 | import org.onosproject.vtnrsc.TenantId; | 27 | import org.onosproject.vtnrsc.TenantId; |
... | @@ -79,4 +80,24 @@ public interface VtnRscService extends ListenerService<VtnRscEvent, VtnRscListen | ... | @@ -79,4 +80,24 @@ public interface VtnRscService extends ListenerService<VtnRscEvent, VtnRscListen |
79 | * @return device identifier | 80 | * @return device identifier |
80 | */ | 81 | */ |
81 | DeviceId getSFToSFFMaping(VirtualPortId portId); | 82 | DeviceId getSFToSFFMaping(VirtualPortId portId); |
83 | + | ||
84 | + /** | ||
85 | + * Adds specify Device identifier to Service Function Forward OvsMap | ||
86 | + * or Classifier OvsMap. | ||
87 | + * | ||
88 | + * @param virtualPortId the VirtualPort identifier | ||
89 | + * @param tenantId the tenant identifier | ||
90 | + * @param deviceId the device identifier | ||
91 | + */ | ||
92 | + void addDeviceIdOfOvsMap(VirtualPortId virtualPortId, TenantId tenantId, DeviceId deviceId); | ||
93 | + | ||
94 | + /** | ||
95 | + * Removes specify Device identifier from Service Function Forward OvsMap | ||
96 | + * or Classifier OvsMap. | ||
97 | + * | ||
98 | + * @param host Host | ||
99 | + * @param tenantId the tenant identifier | ||
100 | + * @param deviceId the device identifier | ||
101 | + */ | ||
102 | + void removeDeviceIdOfOvsMap(Host host, TenantId tenantId, DeviceId deviceId); | ||
82 | } | 103 | } | ... | ... |
... | @@ -37,16 +37,19 @@ import org.onosproject.net.Device; | ... | @@ -37,16 +37,19 @@ import org.onosproject.net.Device; |
37 | import org.onosproject.net.DeviceId; | 37 | import org.onosproject.net.DeviceId; |
38 | import org.onosproject.net.Host; | 38 | import org.onosproject.net.Host; |
39 | import org.onosproject.net.HostId; | 39 | import org.onosproject.net.HostId; |
40 | -import org.onosproject.net.host.HostEvent; | ||
41 | -import org.onosproject.net.host.HostListener; | ||
42 | -import org.onosproject.net.host.HostService; | ||
43 | import org.onosproject.net.device.DeviceService; | 40 | import org.onosproject.net.device.DeviceService; |
41 | +import org.onosproject.net.host.HostService; | ||
44 | import org.onosproject.store.serializers.KryoNamespaces; | 42 | import org.onosproject.store.serializers.KryoNamespaces; |
45 | import org.onosproject.store.service.EventuallyConsistentMap; | 43 | import org.onosproject.store.service.EventuallyConsistentMap; |
46 | import org.onosproject.store.service.LogicalClockService; | 44 | import org.onosproject.store.service.LogicalClockService; |
47 | import org.onosproject.store.service.StorageService; | 45 | import org.onosproject.store.service.StorageService; |
48 | import org.onosproject.vtnrsc.FixedIp; | 46 | import org.onosproject.vtnrsc.FixedIp; |
49 | import org.onosproject.vtnrsc.FloatingIp; | 47 | import org.onosproject.vtnrsc.FloatingIp; |
48 | +import org.onosproject.vtnrsc.FlowClassifier; | ||
49 | +import org.onosproject.vtnrsc.PortChain; | ||
50 | +import org.onosproject.vtnrsc.PortPair; | ||
51 | +import org.onosproject.vtnrsc.PortPairGroup; | ||
52 | +import org.onosproject.vtnrsc.PortPairId; | ||
50 | import org.onosproject.vtnrsc.Router; | 53 | import org.onosproject.vtnrsc.Router; |
51 | import org.onosproject.vtnrsc.RouterInterface; | 54 | import org.onosproject.vtnrsc.RouterInterface; |
52 | import org.onosproject.vtnrsc.SegmentationId; | 55 | import org.onosproject.vtnrsc.SegmentationId; |
... | @@ -55,17 +58,24 @@ import org.onosproject.vtnrsc.SubnetId; | ... | @@ -55,17 +58,24 @@ import org.onosproject.vtnrsc.SubnetId; |
55 | import org.onosproject.vtnrsc.TenantId; | 58 | import org.onosproject.vtnrsc.TenantId; |
56 | import org.onosproject.vtnrsc.VirtualPort; | 59 | import org.onosproject.vtnrsc.VirtualPort; |
57 | import org.onosproject.vtnrsc.VirtualPortId; | 60 | import org.onosproject.vtnrsc.VirtualPortId; |
58 | -import org.onosproject.vtnrsc.PortPair; | ||
59 | -import org.onosproject.vtnrsc.PortPairId; | ||
60 | -import org.onosproject.vtnrsc.PortPairGroup; | ||
61 | -import org.onosproject.vtnrsc.FlowClassifier; | ||
62 | -import org.onosproject.vtnrsc.PortChain; | ||
63 | import org.onosproject.vtnrsc.event.VtnRscEvent; | 61 | import org.onosproject.vtnrsc.event.VtnRscEvent; |
64 | import org.onosproject.vtnrsc.event.VtnRscEventFeedback; | 62 | import org.onosproject.vtnrsc.event.VtnRscEventFeedback; |
65 | import org.onosproject.vtnrsc.event.VtnRscListener; | 63 | import org.onosproject.vtnrsc.event.VtnRscListener; |
66 | import org.onosproject.vtnrsc.floatingip.FloatingIpEvent; | 64 | import org.onosproject.vtnrsc.floatingip.FloatingIpEvent; |
67 | import org.onosproject.vtnrsc.floatingip.FloatingIpListener; | 65 | import org.onosproject.vtnrsc.floatingip.FloatingIpListener; |
68 | import org.onosproject.vtnrsc.floatingip.FloatingIpService; | 66 | import org.onosproject.vtnrsc.floatingip.FloatingIpService; |
67 | +import org.onosproject.vtnrsc.flowclassifier.FlowClassifierEvent; | ||
68 | +import org.onosproject.vtnrsc.flowclassifier.FlowClassifierListener; | ||
69 | +import org.onosproject.vtnrsc.flowclassifier.FlowClassifierService; | ||
70 | +import org.onosproject.vtnrsc.portchain.PortChainEvent; | ||
71 | +import org.onosproject.vtnrsc.portchain.PortChainListener; | ||
72 | +import org.onosproject.vtnrsc.portchain.PortChainService; | ||
73 | +import org.onosproject.vtnrsc.portpair.PortPairEvent; | ||
74 | +import org.onosproject.vtnrsc.portpair.PortPairListener; | ||
75 | +import org.onosproject.vtnrsc.portpair.PortPairService; | ||
76 | +import org.onosproject.vtnrsc.portpairgroup.PortPairGroupEvent; | ||
77 | +import org.onosproject.vtnrsc.portpairgroup.PortPairGroupListener; | ||
78 | +import org.onosproject.vtnrsc.portpairgroup.PortPairGroupService; | ||
69 | import org.onosproject.vtnrsc.router.RouterEvent; | 79 | import org.onosproject.vtnrsc.router.RouterEvent; |
70 | import org.onosproject.vtnrsc.router.RouterListener; | 80 | import org.onosproject.vtnrsc.router.RouterListener; |
71 | import org.onosproject.vtnrsc.router.RouterService; | 81 | import org.onosproject.vtnrsc.router.RouterService; |
... | @@ -76,18 +86,6 @@ import org.onosproject.vtnrsc.service.VtnRscService; | ... | @@ -76,18 +86,6 @@ import org.onosproject.vtnrsc.service.VtnRscService; |
76 | import org.onosproject.vtnrsc.subnet.SubnetService; | 86 | import org.onosproject.vtnrsc.subnet.SubnetService; |
77 | import org.onosproject.vtnrsc.tenantnetwork.TenantNetworkService; | 87 | import org.onosproject.vtnrsc.tenantnetwork.TenantNetworkService; |
78 | import org.onosproject.vtnrsc.virtualport.VirtualPortService; | 88 | import org.onosproject.vtnrsc.virtualport.VirtualPortService; |
79 | -import org.onosproject.vtnrsc.portpair.PortPairEvent; | ||
80 | -import org.onosproject.vtnrsc.portpair.PortPairListener; | ||
81 | -import org.onosproject.vtnrsc.portpair.PortPairService; | ||
82 | -import org.onosproject.vtnrsc.portpairgroup.PortPairGroupEvent; | ||
83 | -import org.onosproject.vtnrsc.portpairgroup.PortPairGroupListener; | ||
84 | -import org.onosproject.vtnrsc.portpairgroup.PortPairGroupService; | ||
85 | -import org.onosproject.vtnrsc.flowclassifier.FlowClassifierEvent; | ||
86 | -import org.onosproject.vtnrsc.flowclassifier.FlowClassifierListener; | ||
87 | -import org.onosproject.vtnrsc.flowclassifier.FlowClassifierService; | ||
88 | -import org.onosproject.vtnrsc.portchain.PortChainEvent; | ||
89 | -import org.onosproject.vtnrsc.portchain.PortChainListener; | ||
90 | -import org.onosproject.vtnrsc.portchain.PortChainService; | ||
91 | import org.slf4j.Logger; | 89 | import org.slf4j.Logger; |
92 | 90 | ||
93 | /** | 91 | /** |
... | @@ -105,7 +103,6 @@ public class VtnRscManager extends AbstractListenerManager<VtnRscEvent, VtnRscLi | ... | @@ -105,7 +103,6 @@ public class VtnRscManager extends AbstractListenerManager<VtnRscEvent, VtnRscLi |
105 | protected LogicalClockService clockService; | 103 | protected LogicalClockService clockService; |
106 | 104 | ||
107 | private final Logger log = getLogger(getClass()); | 105 | private final Logger log = getLogger(getClass()); |
108 | - private HostListener hostListener = new InnerHostListener(); | ||
109 | private FloatingIpListener floatingIpListener = new InnerFloatingIpListener(); | 106 | private FloatingIpListener floatingIpListener = new InnerFloatingIpListener(); |
110 | private RouterListener routerListener = new InnerRouterListener(); | 107 | private RouterListener routerListener = new InnerRouterListener(); |
111 | private RouterInterfaceListener routerInterfaceListener = new InnerRouterInterfaceListener(); | 108 | private RouterInterfaceListener routerInterfaceListener = new InnerRouterInterfaceListener(); |
... | @@ -120,11 +117,11 @@ public class VtnRscManager extends AbstractListenerManager<VtnRscEvent, VtnRscLi | ... | @@ -120,11 +117,11 @@ public class VtnRscManager extends AbstractListenerManager<VtnRscEvent, VtnRscLi |
120 | 117 | ||
121 | private static final String IFACEID = "ifaceid"; | 118 | private static final String IFACEID = "ifaceid"; |
122 | private static final String RUNNELOPTOPOIC = "tunnel-ops-ids"; | 119 | private static final String RUNNELOPTOPOIC = "tunnel-ops-ids"; |
123 | - private static final String LISTENER_NOT_NULL = "listener cannot be null"; | ||
124 | private static final String EVENT_NOT_NULL = "event cannot be null"; | 120 | private static final String EVENT_NOT_NULL = "event cannot be null"; |
125 | private static final String TENANTID_NOT_NULL = "tenantId cannot be null"; | 121 | private static final String TENANTID_NOT_NULL = "tenantId cannot be null"; |
126 | private static final String DEVICEID_NOT_NULL = "deviceId cannot be null"; | 122 | private static final String DEVICEID_NOT_NULL = "deviceId cannot be null"; |
127 | - private static final String OVSMAP_NOT_NULL = "ovsMap cannot be null"; | 123 | + private static final String VIRTUALPORTID_NOT_NULL = "virtualPortId cannot be null"; |
124 | + private static final String HOST_NOT_NULL = "host cannot be null"; | ||
128 | private static final String L3VNIMAP = "l3vniMap"; | 125 | private static final String L3VNIMAP = "l3vniMap"; |
129 | private static final String CLASSIFIEROVSMAP = "classifierOvsMap"; | 126 | private static final String CLASSIFIEROVSMAP = "classifierOvsMap"; |
130 | private static final String SFFOVSMAP = "sffOvsMap"; | 127 | private static final String SFFOVSMAP = "sffOvsMap"; |
... | @@ -157,7 +154,6 @@ public class VtnRscManager extends AbstractListenerManager<VtnRscEvent, VtnRscLi | ... | @@ -157,7 +154,6 @@ public class VtnRscManager extends AbstractListenerManager<VtnRscEvent, VtnRscLi |
157 | @Activate | 154 | @Activate |
158 | public void activate() { | 155 | public void activate() { |
159 | eventDispatcher.addSink(VtnRscEvent.class, listenerRegistry); | 156 | eventDispatcher.addSink(VtnRscEvent.class, listenerRegistry); |
160 | - hostService.addListener(hostListener); | ||
161 | floatingIpService.addListener(floatingIpListener); | 157 | floatingIpService.addListener(floatingIpListener); |
162 | routerService.addListener(routerListener); | 158 | routerService.addListener(routerListener); |
163 | routerInterfaceService.addListener(routerInterfaceListener); | 159 | routerInterfaceService.addListener(routerInterfaceListener); |
... | @@ -191,7 +187,6 @@ public class VtnRscManager extends AbstractListenerManager<VtnRscEvent, VtnRscLi | ... | @@ -191,7 +187,6 @@ public class VtnRscManager extends AbstractListenerManager<VtnRscEvent, VtnRscLi |
191 | @Deactivate | 187 | @Deactivate |
192 | public void deactivate() { | 188 | public void deactivate() { |
193 | eventDispatcher.removeSink(VtnRscEvent.class); | 189 | eventDispatcher.removeSink(VtnRscEvent.class); |
194 | - hostService.removeListener(hostListener); | ||
195 | floatingIpService.removeListener(floatingIpListener); | 190 | floatingIpService.removeListener(floatingIpListener); |
196 | routerService.removeListener(routerListener); | 191 | routerService.removeListener(routerListener); |
197 | routerInterfaceService.removeListener(routerInterfaceListener); | 192 | routerInterfaceService.removeListener(routerInterfaceListener); |
... | @@ -220,37 +215,6 @@ public class VtnRscManager extends AbstractListenerManager<VtnRscEvent, VtnRscLi | ... | @@ -220,37 +215,6 @@ public class VtnRscManager extends AbstractListenerManager<VtnRscEvent, VtnRscLi |
220 | return l3vni; | 215 | return l3vni; |
221 | } | 216 | } |
222 | 217 | ||
223 | - private class InnerHostListener implements HostListener { | ||
224 | - | ||
225 | - @Override | ||
226 | - public void event(HostEvent event) { | ||
227 | - checkNotNull(event, EVENT_NOT_NULL); | ||
228 | - Host host = event.subject(); | ||
229 | - String ifaceId = host.annotations().value(IFACEID); | ||
230 | - if (ifaceId == null) { | ||
231 | - log.error("The ifaceId of Host is null"); | ||
232 | - return; | ||
233 | - } | ||
234 | - VirtualPortId hPortId = VirtualPortId.portId(ifaceId); | ||
235 | - TenantId tenantId = virtualPortService.getPort(hPortId).tenantId(); | ||
236 | - DeviceId deviceId = host.location().deviceId(); | ||
237 | - if (HostEvent.Type.HOST_ADDED == event.type()) { | ||
238 | - if (isServiceFunction(hPortId)) { | ||
239 | - addDeviceIdOfOvsMap(tenantId, deviceId, sffOvsMap); | ||
240 | - } else { | ||
241 | - addDeviceIdOfOvsMap(tenantId, deviceId, classifierOvsMap); | ||
242 | - } | ||
243 | - } else if (HostEvent.Type.HOST_REMOVED == event.type()) { | ||
244 | - if (isLastSFHostOfTenant(host, deviceId, tenantId)) { | ||
245 | - removeDeviceIdOfOvsMap(tenantId, deviceId, sffOvsMap); | ||
246 | - } | ||
247 | - if (isLastClassifierHostOfTenant(host, deviceId, tenantId)) { | ||
248 | - removeDeviceIdOfOvsMap(tenantId, deviceId, classifierOvsMap); | ||
249 | - } | ||
250 | - } | ||
251 | - } | ||
252 | - } | ||
253 | - | ||
254 | private class InnerFloatingIpListener implements FloatingIpListener { | 218 | private class InnerFloatingIpListener implements FloatingIpListener { |
255 | 219 | ||
256 | @Override | 220 | @Override |
... | @@ -466,6 +430,32 @@ public class VtnRscManager extends AbstractListenerManager<VtnRscEvent, VtnRscLi | ... | @@ -466,6 +430,32 @@ public class VtnRscManager extends AbstractListenerManager<VtnRscEvent, VtnRscLi |
466 | return null; | 430 | return null; |
467 | } | 431 | } |
468 | 432 | ||
433 | + @Override | ||
434 | + public void addDeviceIdOfOvsMap(VirtualPortId virtualPortId, | ||
435 | + TenantId tenantId, DeviceId deviceId) { | ||
436 | + checkNotNull(virtualPortId, VIRTUALPORTID_NOT_NULL); | ||
437 | + checkNotNull(tenantId, TENANTID_NOT_NULL); | ||
438 | + checkNotNull(deviceId, DEVICEID_NOT_NULL); | ||
439 | + if (isServiceFunction(virtualPortId)) { | ||
440 | + addDeviceIdToSpecificMap(tenantId, deviceId, sffOvsMap); | ||
441 | + } else { | ||
442 | + addDeviceIdToSpecificMap(tenantId, deviceId, classifierOvsMap); | ||
443 | + } | ||
444 | + } | ||
445 | + | ||
446 | + @Override | ||
447 | + public void removeDeviceIdOfOvsMap(Host host, TenantId tenantId, DeviceId deviceId) { | ||
448 | + checkNotNull(host, HOST_NOT_NULL); | ||
449 | + checkNotNull(tenantId, TENANTID_NOT_NULL); | ||
450 | + checkNotNull(deviceId, DEVICEID_NOT_NULL); | ||
451 | + if (isLastSFHostOfTenant(host, deviceId, tenantId)) { | ||
452 | + removeDeviceIdToSpecificMap(tenantId, deviceId, sffOvsMap); | ||
453 | + } | ||
454 | + if (isLastClassifierHostOfTenant(host, deviceId, tenantId)) { | ||
455 | + removeDeviceIdToSpecificMap(tenantId, deviceId, classifierOvsMap); | ||
456 | + } | ||
457 | + } | ||
458 | + | ||
469 | /** | 459 | /** |
470 | * Checks whether the last Service Function host of a specific tenant in | 460 | * Checks whether the last Service Function host of a specific tenant in |
471 | * this device. | 461 | * this device. |
... | @@ -477,11 +467,7 @@ public class VtnRscManager extends AbstractListenerManager<VtnRscEvent, VtnRscLi | ... | @@ -477,11 +467,7 @@ public class VtnRscManager extends AbstractListenerManager<VtnRscEvent, VtnRscLi |
477 | */ | 467 | */ |
478 | private boolean isLastSFHostOfTenant(Host host, DeviceId deviceId, | 468 | private boolean isLastSFHostOfTenant(Host host, DeviceId deviceId, |
479 | TenantId tenantId) { | 469 | TenantId tenantId) { |
480 | - checkNotNull(host, "host cannot be null"); | ||
481 | - checkNotNull(deviceId, DEVICEID_NOT_NULL); | ||
482 | - checkNotNull(tenantId, TENANTID_NOT_NULL); | ||
483 | Set<Host> hostSet = hostService.getConnectedHosts(deviceId); | 470 | Set<Host> hostSet = hostService.getConnectedHosts(deviceId); |
484 | - Set<Host> sfcHostSet = new HashSet<Host>(); | ||
485 | if (hostSet != null) { | 471 | if (hostSet != null) { |
486 | for (Host h : hostSet) { | 472 | for (Host h : hostSet) { |
487 | String ifaceId = h.annotations().value(IFACEID); | 473 | String ifaceId = h.annotations().value(IFACEID); |
... | @@ -490,15 +476,14 @@ public class VtnRscManager extends AbstractListenerManager<VtnRscEvent, VtnRscLi | ... | @@ -490,15 +476,14 @@ public class VtnRscManager extends AbstractListenerManager<VtnRscEvent, VtnRscLi |
490 | if (virtualPortService.getPort(hPortId).tenantId().tenantId() | 476 | if (virtualPortService.getPort(hPortId).tenantId().tenantId() |
491 | .equals(tenantId.tenantId()) | 477 | .equals(tenantId.tenantId()) |
492 | && isServiceFunction(hPortId)) { | 478 | && isServiceFunction(hPortId)) { |
493 | - sfcHostSet.add(h); | 479 | + if (!h.equals(host)) { |
480 | + return false; | ||
481 | + } | ||
494 | } | 482 | } |
495 | } | 483 | } |
496 | } | 484 | } |
497 | } | 485 | } |
498 | - if (sfcHostSet.size() == 1 && sfcHostSet.contains(host)) { | 486 | + return true; |
499 | - return true; | ||
500 | - } | ||
501 | - return false; | ||
502 | } | 487 | } |
503 | 488 | ||
504 | /** | 489 | /** |
... | @@ -512,11 +497,7 @@ public class VtnRscManager extends AbstractListenerManager<VtnRscEvent, VtnRscLi | ... | @@ -512,11 +497,7 @@ public class VtnRscManager extends AbstractListenerManager<VtnRscEvent, VtnRscLi |
512 | */ | 497 | */ |
513 | private boolean isLastClassifierHostOfTenant(Host host, DeviceId deviceId, | 498 | private boolean isLastClassifierHostOfTenant(Host host, DeviceId deviceId, |
514 | TenantId tenantId) { | 499 | TenantId tenantId) { |
515 | - checkNotNull(host, "host cannot be null"); | ||
516 | - checkNotNull(deviceId, DEVICEID_NOT_NULL); | ||
517 | - checkNotNull(tenantId, TENANTID_NOT_NULL); | ||
518 | Set<Host> hostSet = hostService.getConnectedHosts(deviceId); | 500 | Set<Host> hostSet = hostService.getConnectedHosts(deviceId); |
519 | - Set<Host> sfcHostSet = new HashSet<Host>(); | ||
520 | if (hostSet != null) { | 501 | if (hostSet != null) { |
521 | for (Host h : hostSet) { | 502 | for (Host h : hostSet) { |
522 | String ifaceId = h.annotations().value(IFACEID); | 503 | String ifaceId = h.annotations().value(IFACEID); |
... | @@ -525,15 +506,14 @@ public class VtnRscManager extends AbstractListenerManager<VtnRscEvent, VtnRscLi | ... | @@ -525,15 +506,14 @@ public class VtnRscManager extends AbstractListenerManager<VtnRscEvent, VtnRscLi |
525 | if (virtualPortService.getPort(hPortId).tenantId().tenantId() | 506 | if (virtualPortService.getPort(hPortId).tenantId().tenantId() |
526 | .equals(tenantId.tenantId()) | 507 | .equals(tenantId.tenantId()) |
527 | && !isServiceFunction(hPortId)) { | 508 | && !isServiceFunction(hPortId)) { |
528 | - sfcHostSet.add(h); | 509 | + if (!h.equals(host)) { |
510 | + return false; | ||
511 | + } | ||
529 | } | 512 | } |
530 | } | 513 | } |
531 | } | 514 | } |
532 | } | 515 | } |
533 | - if (sfcHostSet.size() == 1 && sfcHostSet.contains(host)) { | 516 | + return true; |
534 | - return true; | ||
535 | - } | ||
536 | - return false; | ||
537 | } | 517 | } |
538 | 518 | ||
539 | /** | 519 | /** |
... | @@ -543,12 +523,9 @@ public class VtnRscManager extends AbstractListenerManager<VtnRscEvent, VtnRscLi | ... | @@ -543,12 +523,9 @@ public class VtnRscManager extends AbstractListenerManager<VtnRscEvent, VtnRscLi |
543 | * @param deviceId the device identifier | 523 | * @param deviceId the device identifier |
544 | * @param ovsMap the instance of map to store device identifier | 524 | * @param ovsMap the instance of map to store device identifier |
545 | */ | 525 | */ |
546 | - private void addDeviceIdOfOvsMap(TenantId tenantId, | 526 | + private void addDeviceIdToSpecificMap(TenantId tenantId, |
547 | DeviceId deviceId, | 527 | DeviceId deviceId, |
548 | EventuallyConsistentMap<TenantId, Set<DeviceId>> ovsMap) { | 528 | EventuallyConsistentMap<TenantId, Set<DeviceId>> ovsMap) { |
549 | - checkNotNull(tenantId, TENANTID_NOT_NULL); | ||
550 | - checkNotNull(deviceId, DEVICEID_NOT_NULL); | ||
551 | - checkNotNull(ovsMap, OVSMAP_NOT_NULL); | ||
552 | if (ovsMap.containsKey(tenantId)) { | 529 | if (ovsMap.containsKey(tenantId)) { |
553 | Set<DeviceId> deviceIdSet = ovsMap.get(tenantId); | 530 | Set<DeviceId> deviceIdSet = ovsMap.get(tenantId); |
554 | deviceIdSet.add(deviceId); | 531 | deviceIdSet.add(deviceId); |
... | @@ -567,14 +544,11 @@ public class VtnRscManager extends AbstractListenerManager<VtnRscEvent, VtnRscLi | ... | @@ -567,14 +544,11 @@ public class VtnRscManager extends AbstractListenerManager<VtnRscEvent, VtnRscLi |
567 | * @param deviceId the device identifier | 544 | * @param deviceId the device identifier |
568 | * @param ovsMap the instance of map to store device identifier | 545 | * @param ovsMap the instance of map to store device identifier |
569 | */ | 546 | */ |
570 | - private void removeDeviceIdOfOvsMap(TenantId tenantId, | 547 | + private void removeDeviceIdToSpecificMap(TenantId tenantId, |
571 | DeviceId deviceId, | 548 | DeviceId deviceId, |
572 | EventuallyConsistentMap<TenantId, Set<DeviceId>> ovsMap) { | 549 | EventuallyConsistentMap<TenantId, Set<DeviceId>> ovsMap) { |
573 | - checkNotNull(tenantId, TENANTID_NOT_NULL); | ||
574 | - checkNotNull(deviceId, DEVICEID_NOT_NULL); | ||
575 | - checkNotNull(ovsMap, OVSMAP_NOT_NULL); | ||
576 | Set<DeviceId> deviceIdSet = ovsMap.get(tenantId); | 550 | Set<DeviceId> deviceIdSet = ovsMap.get(tenantId); |
577 | - if (deviceIdSet.size() > 1) { | 551 | + if (deviceIdSet != null && deviceIdSet.size() > 1) { |
578 | deviceIdSet.remove(deviceId); | 552 | deviceIdSet.remove(deviceId); |
579 | ovsMap.put(tenantId, deviceIdSet); | 553 | ovsMap.put(tenantId, deviceIdSet); |
580 | } else { | 554 | } else { | ... | ... |
-
Please register or login to post a comment