Committed by
Gerrit Code Review
[ONOS] SR resilency, CR resilency and delete problem , old tunnels not deleting issue
Change-Id: Ib4b9732c28a1f87a8a76347a5936593b1b5bf72a
Showing
7 changed files
with
170 additions
and
82 deletions
... | @@ -325,7 +325,7 @@ public final class BasicPceccHandler { | ... | @@ -325,7 +325,7 @@ public final class BasicPceccHandler { |
325 | } | 325 | } |
326 | 326 | ||
327 | // Install a rule for pushing local labels to the device which is specific to path. | 327 | // Install a rule for pushing local labels to the device which is specific to path. |
328 | - private void installLocalLabelRule(DeviceId deviceId, LabelResourceId labelId, | 328 | + private synchronized void installLocalLabelRule(DeviceId deviceId, LabelResourceId labelId, |
329 | PortNumber portNum, TunnelId tunnelId, | 329 | PortNumber portNum, TunnelId tunnelId, |
330 | Boolean isBos, Long labelType, | 330 | Boolean isBos, Long labelType, |
331 | Objective.Operation type) { | 331 | Objective.Operation type) { | ... | ... |
... | @@ -31,7 +31,6 @@ import java.util.concurrent.ScheduledExecutorService; | ... | @@ -31,7 +31,6 @@ import java.util.concurrent.ScheduledExecutorService; |
31 | 31 | ||
32 | import org.onlab.packet.Ethernet; | 32 | import org.onlab.packet.Ethernet; |
33 | import org.onlab.packet.IPv4; | 33 | import org.onlab.packet.IPv4; |
34 | - | ||
35 | import org.apache.felix.scr.annotations.Activate; | 34 | import org.apache.felix.scr.annotations.Activate; |
36 | import org.apache.felix.scr.annotations.Component; | 35 | import org.apache.felix.scr.annotations.Component; |
37 | import org.apache.felix.scr.annotations.Deactivate; | 36 | import org.apache.felix.scr.annotations.Deactivate; |
... | @@ -110,14 +109,14 @@ import org.slf4j.LoggerFactory; | ... | @@ -110,14 +109,14 @@ import org.slf4j.LoggerFactory; |
110 | import com.google.common.collect.ImmutableList; | 109 | import com.google.common.collect.ImmutableList; |
111 | import com.google.common.collect.ImmutableSet; | 110 | import com.google.common.collect.ImmutableSet; |
112 | 111 | ||
113 | -import static org.onosproject.incubator.net.tunnel.Tunnel.Type.MPLS; | 112 | +import static org.onosproject.incubator.net.tunnel.Tunnel.State.ACTIVE; |
114 | import static org.onosproject.incubator.net.tunnel.Tunnel.State.INIT; | 113 | import static org.onosproject.incubator.net.tunnel.Tunnel.State.INIT; |
115 | import static org.onosproject.incubator.net.tunnel.Tunnel.State.ESTABLISHED; | 114 | import static org.onosproject.incubator.net.tunnel.Tunnel.State.ESTABLISHED; |
116 | import static org.onosproject.incubator.net.tunnel.Tunnel.State.UNSTABLE; | 115 | import static org.onosproject.incubator.net.tunnel.Tunnel.State.UNSTABLE; |
116 | +import static org.onosproject.incubator.net.tunnel.Tunnel.Type.MPLS; | ||
117 | import static org.onosproject.pce.pceservice.LspType.WITH_SIGNALLING; | 117 | import static org.onosproject.pce.pceservice.LspType.WITH_SIGNALLING; |
118 | import static org.onosproject.pce.pceservice.LspType.SR_WITHOUT_SIGNALLING; | 118 | import static org.onosproject.pce.pceservice.LspType.SR_WITHOUT_SIGNALLING; |
119 | import static org.onosproject.pce.pceservice.LspType.WITHOUT_SIGNALLING_AND_WITHOUT_SR; | 119 | import static org.onosproject.pce.pceservice.LspType.WITHOUT_SIGNALLING_AND_WITHOUT_SR; |
120 | - | ||
121 | import static org.onosproject.pce.pceservice.PcepAnnotationKeys.BANDWIDTH; | 120 | import static org.onosproject.pce.pceservice.PcepAnnotationKeys.BANDWIDTH; |
122 | import static org.onosproject.pce.pceservice.PcepAnnotationKeys.LOCAL_LSP_ID; | 121 | import static org.onosproject.pce.pceservice.PcepAnnotationKeys.LOCAL_LSP_ID; |
123 | import static org.onosproject.pce.pceservice.PcepAnnotationKeys.LSP_SIG_TYPE; | 122 | import static org.onosproject.pce.pceservice.PcepAnnotationKeys.LSP_SIG_TYPE; |
... | @@ -621,6 +620,12 @@ public class PceManager implements PceService { | ... | @@ -621,6 +620,12 @@ public class PceManager implements PceService { |
621 | return false; | 620 | return false; |
622 | } | 621 | } |
623 | 622 | ||
623 | + LspType lspType = LspType.valueOf(tunnel.annotations().value(LSP_SIG_TYPE)); | ||
624 | + // Release basic PCECC labels. | ||
625 | + if (lspType == WITHOUT_SIGNALLING_AND_WITHOUT_SR) { | ||
626 | + crHandler.releaseLabel(tunnel); | ||
627 | + } | ||
628 | + | ||
624 | // 2. Call tunnel service. | 629 | // 2. Call tunnel service. |
625 | return tunnelService.downTunnel(appId, tunnel.tunnelId()); | 630 | return tunnelService.downTunnel(appId, tunnel.tunnelId()); |
626 | } | 631 | } |
... | @@ -1148,6 +1153,22 @@ public class PceManager implements PceService { | ... | @@ -1148,6 +1153,22 @@ public class PceManager implements PceService { |
1148 | } | 1153 | } |
1149 | } | 1154 | } |
1150 | 1155 | ||
1156 | + //In CR case, release labels when new tunnel for it is updated. | ||
1157 | + if (lspType == WITHOUT_SIGNALLING_AND_WITHOUT_SR && tunnel.state() == ACTIVE | ||
1158 | + && mastershipService.getLocalRole(tunnel.path().src().deviceId()) == MastershipRole.MASTER) { | ||
1159 | + Collection<Tunnel> tunnels = tunnelService.queryTunnel(tunnel.src(), tunnel.dst()); | ||
1160 | + | ||
1161 | + for (Tunnel t : tunnels) { | ||
1162 | + if (tunnel.annotations().value(PLSP_ID).equals(t.annotations().value(PLSP_ID)) | ||
1163 | + && !tunnel.annotations().value(LOCAL_LSP_ID) | ||
1164 | + .equals(t.annotations().value(LOCAL_LSP_ID))) { | ||
1165 | + // Release basic PCECC labels. | ||
1166 | + crHandler.releaseLabel(t); | ||
1167 | + break; | ||
1168 | + } | ||
1169 | + } | ||
1170 | + } | ||
1171 | + | ||
1151 | if (tunnel.state() == UNSTABLE) { | 1172 | if (tunnel.state() == UNSTABLE) { |
1152 | /* | 1173 | /* |
1153 | * During LSP DB sync if PCC doesn't report LSP which was PCE initiated, it's state is turned into | 1174 | * During LSP DB sync if PCC doesn't report LSP which was PCE initiated, it's state is turned into |
... | @@ -1183,23 +1204,16 @@ public class PceManager implements PceService { | ... | @@ -1183,23 +1204,16 @@ public class PceManager implements PceService { |
1183 | if (lspType != WITH_SIGNALLING) { | 1204 | if (lspType != WITH_SIGNALLING) { |
1184 | localLspIdFreeList.add(Short.valueOf(tunnel.annotations().value(LOCAL_LSP_ID))); | 1205 | localLspIdFreeList.add(Short.valueOf(tunnel.annotations().value(LOCAL_LSP_ID))); |
1185 | } | 1206 | } |
1186 | - | ||
1187 | // If not zero bandwidth, and delegated (initiated LSPs will also be delegated). | 1207 | // If not zero bandwidth, and delegated (initiated LSPs will also be delegated). |
1188 | - if (bwConstraintValue != 0) { | 1208 | + if (Double.parseDouble(tunnel.annotations().value(BANDWIDTH)) != 0.0 |
1189 | - releaseBandwidth(event.subject()); | 1209 | + && mastershipService.getLocalRole(tunnel.path().src().deviceId()) == MastershipRole.MASTER) { |
1190 | - | 1210 | + releaseBandwidth(tunnel); |
1191 | - // Release basic PCECC labels. | ||
1192 | - if (lspType == WITHOUT_SIGNALLING_AND_WITHOUT_SR) { | ||
1193 | - // Delete stored tunnel consumer id from PCE store (while still retaining label list.) | ||
1194 | - PceccTunnelInfo pceccTunnelInfo = pceStore.getTunnelInfo(tunnel.tunnelId()); | ||
1195 | - pceccTunnelInfo.tunnelConsumerId(null); | ||
1196 | - if (mastershipService.getLocalRole(tunnel.path().src().deviceId()) == MastershipRole.MASTER) { | ||
1197 | - crHandler.releaseLabel(tunnel); | ||
1198 | } | 1211 | } |
1199 | - } else { | 1212 | + |
1213 | + if (pceStore.getTunnelInfo(tunnel.tunnelId()) != null) { | ||
1200 | pceStore.removeTunnelInfo(tunnel.tunnelId()); | 1214 | pceStore.removeTunnelInfo(tunnel.tunnelId()); |
1201 | } | 1215 | } |
1202 | - } | 1216 | + |
1203 | break; | 1217 | break; |
1204 | 1218 | ||
1205 | default: | 1219 | default: | ... | ... |
... | @@ -641,11 +641,14 @@ public class PceManagerTest { | ... | @@ -641,11 +641,14 @@ public class PceManagerTest { |
641 | build4RouterTopo(false, false, false, false, 5); | 641 | build4RouterTopo(false, false, false, false, 5); |
642 | List<Constraint> constraints = new LinkedList<Constraint>(); | 642 | List<Constraint> constraints = new LinkedList<Constraint>(); |
643 | CostConstraint costConstraint = new CostConstraint(TE_COST); | 643 | CostConstraint costConstraint = new CostConstraint(TE_COST); |
644 | + BandwidthConstraint bwConst = new BandwidthConstraint(Bandwidth.bps(3)); | ||
645 | + constraints.add(bwConst); | ||
644 | constraints.add(costConstraint); | 646 | constraints.add(costConstraint); |
645 | 647 | ||
646 | pceManager.setupPath(D1.deviceId(), D2.deviceId(), "T123", constraints, WITH_SIGNALLING); | 648 | pceManager.setupPath(D1.deviceId(), D2.deviceId(), "T123", constraints, WITH_SIGNALLING); |
647 | 649 | ||
648 | Collection<Tunnel> tunnels = (Collection<Tunnel>) pceManager.queryAllPath(); | 650 | Collection<Tunnel> tunnels = (Collection<Tunnel>) pceManager.queryAllPath(); |
651 | + | ||
649 | assertThat(tunnels.size(), is(1)); | 652 | assertThat(tunnels.size(), is(1)); |
650 | boolean result; | 653 | boolean result; |
651 | for (Tunnel tunnel : tunnels) { | 654 | for (Tunnel tunnel : tunnels) { | ... | ... |
... | @@ -63,8 +63,6 @@ import org.onosproject.bgpio.types.attr.BgpLinkAttrTeDefaultMetric; | ... | @@ -63,8 +63,6 @@ import org.onosproject.bgpio.types.attr.BgpLinkAttrTeDefaultMetric; |
63 | import org.onosproject.core.CoreService; | 63 | import org.onosproject.core.CoreService; |
64 | import org.onosproject.incubator.net.resource.label.LabelResourceAdminService; | 64 | import org.onosproject.incubator.net.resource.label.LabelResourceAdminService; |
65 | import org.onosproject.incubator.net.resource.label.LabelResourceId; | 65 | import org.onosproject.incubator.net.resource.label.LabelResourceId; |
66 | -import org.onosproject.mastership.MastershipEvent; | ||
67 | -import org.onosproject.mastership.MastershipListener; | ||
68 | import org.onosproject.mastership.MastershipService; | 66 | import org.onosproject.mastership.MastershipService; |
69 | import org.onosproject.net.AnnotationKeys; | 67 | import org.onosproject.net.AnnotationKeys; |
70 | import org.onosproject.net.ConnectPoint; | 68 | import org.onosproject.net.ConnectPoint; |
... | @@ -79,6 +77,8 @@ import org.onosproject.net.config.basics.BandwidthCapacity; | ... | @@ -79,6 +77,8 @@ import org.onosproject.net.config.basics.BandwidthCapacity; |
79 | import org.onosproject.net.device.DefaultDeviceDescription; | 77 | import org.onosproject.net.device.DefaultDeviceDescription; |
80 | import org.onosproject.net.device.DefaultPortDescription; | 78 | import org.onosproject.net.device.DefaultPortDescription; |
81 | import org.onosproject.net.device.DeviceDescription; | 79 | import org.onosproject.net.device.DeviceDescription; |
80 | +import org.onosproject.net.device.DeviceEvent; | ||
81 | +import org.onosproject.net.device.DeviceListener; | ||
82 | import org.onosproject.net.device.DeviceProvider; | 82 | import org.onosproject.net.device.DeviceProvider; |
83 | import org.onosproject.net.device.DeviceProviderRegistry; | 83 | import org.onosproject.net.device.DeviceProviderRegistry; |
84 | import org.onosproject.net.device.DeviceProviderService; | 84 | import org.onosproject.net.device.DeviceProviderService; |
... | @@ -140,7 +140,7 @@ public class BgpTopologyProvider extends AbstractProvider implements DeviceProvi | ... | @@ -140,7 +140,7 @@ public class BgpTopologyProvider extends AbstractProvider implements DeviceProvi |
140 | private DeviceProviderService deviceProviderService; | 140 | private DeviceProviderService deviceProviderService; |
141 | private LinkProviderService linkProviderService; | 141 | private LinkProviderService linkProviderService; |
142 | 142 | ||
143 | - private InternalMastershipListener masterListener = new InternalMastershipListener(); | 143 | + private DeviceListener deviceListener = new InternalDeviceListener(); |
144 | private InternalBgpProvider listener = new InternalBgpProvider(); | 144 | private InternalBgpProvider listener = new InternalBgpProvider(); |
145 | private static final String UNKNOWN = "unknown"; | 145 | private static final String UNKNOWN = "unknown"; |
146 | public static final long IDENTIFIER_SET = 0x100000000L; | 146 | public static final long IDENTIFIER_SET = 0x100000000L; |
... | @@ -169,7 +169,7 @@ public class BgpTopologyProvider extends AbstractProvider implements DeviceProvi | ... | @@ -169,7 +169,7 @@ public class BgpTopologyProvider extends AbstractProvider implements DeviceProvi |
169 | deviceProviderService = deviceProviderRegistry.register(this); | 169 | deviceProviderService = deviceProviderRegistry.register(this); |
170 | linkProviderService = linkProviderRegistry.register(this); | 170 | linkProviderService = linkProviderRegistry.register(this); |
171 | controller.addListener(listener); | 171 | controller.addListener(listener); |
172 | - mastershipService.addListener(masterListener); | 172 | + deviceService.addListener(deviceListener); |
173 | controller.addLinkListener(listener); | 173 | controller.addLinkListener(listener); |
174 | } | 174 | } |
175 | 175 | ||
... | @@ -182,25 +182,28 @@ public class BgpTopologyProvider extends AbstractProvider implements DeviceProvi | ... | @@ -182,25 +182,28 @@ public class BgpTopologyProvider extends AbstractProvider implements DeviceProvi |
182 | linkProviderService = null; | 182 | linkProviderService = null; |
183 | controller.removeListener(listener); | 183 | controller.removeListener(listener); |
184 | controller.removeLinkListener(listener); | 184 | controller.removeLinkListener(listener); |
185 | - mastershipService.removeListener(masterListener); | 185 | + deviceService.removeListener(deviceListener); |
186 | } | 186 | } |
187 | 187 | ||
188 | - private class InternalMastershipListener implements MastershipListener { | 188 | + private class InternalDeviceListener implements DeviceListener { |
189 | @Override | 189 | @Override |
190 | - public void event(MastershipEvent event) { | 190 | + public void event(DeviceEvent event) { |
191 | - if (event.type() == MastershipEvent.Type.MASTER_CHANGED) { | 191 | + Device device = event.subject(); |
192 | - if (mastershipService.getMasterFor(event.subject()) != null) { | 192 | + |
193 | - //Only for L3 device create label pool for that device | 193 | + switch (event.type()) { |
194 | - Device device = deviceService.getDevice(event.subject()); | 194 | + case DEVICE_ADDED: |
195 | - if (device == null) { | 195 | + if (!mastershipService.isLocalMaster(device.id())) { |
196 | - log.debug("Device {} doesn't exist", event.subject()); | 196 | + break; |
197 | - return; | ||
198 | } | 197 | } |
199 | - //Reserve device label pool for L3 devices | 198 | + |
199 | + // Reserve device label pool for L3 devices | ||
200 | if (device.annotations().value(LSRID) != null) { | 200 | if (device.annotations().value(LSRID) != null) { |
201 | - createDevicePool(event.subject()); | 201 | + createDevicePool(device.id()); |
202 | - } | ||
203 | } | 202 | } |
203 | + break; | ||
204 | + | ||
205 | + default: | ||
206 | + break; | ||
204 | } | 207 | } |
205 | } | 208 | } |
206 | } | 209 | } |
... | @@ -444,7 +447,6 @@ public class BgpTopologyProvider extends AbstractProvider implements DeviceProvi | ... | @@ -444,7 +447,6 @@ public class BgpTopologyProvider extends AbstractProvider implements DeviceProvi |
444 | @Override | 447 | @Override |
445 | public void deleteLink(BgpLinkLsNlriVer4 linkNlri) throws BgpParseException { | 448 | public void deleteLink(BgpLinkLsNlriVer4 linkNlri) throws BgpParseException { |
446 | log.debug("Delete link {}", linkNlri.toString()); | 449 | log.debug("Delete link {}", linkNlri.toString()); |
447 | - | ||
448 | if (linkProviderService == null) { | 450 | if (linkProviderService == null) { |
449 | return; | 451 | return; |
450 | } | 452 | } |
... | @@ -461,6 +463,10 @@ public class BgpTopologyProvider extends AbstractProvider implements DeviceProvi | ... | @@ -461,6 +463,10 @@ public class BgpTopologyProvider extends AbstractProvider implements DeviceProvi |
461 | } | 463 | } |
462 | 464 | ||
463 | linkProviderService.linkVanished(linkDes); | 465 | linkProviderService.linkVanished(linkDes); |
466 | + | ||
467 | + linkDes = new DefaultLinkDescription(linkDes.dst(), linkDes.src(), Link.Type.DIRECT, | ||
468 | + false, linkDes.annotations()); | ||
469 | + linkProviderService.linkVanished(linkDes); | ||
464 | } | 470 | } |
465 | } | 471 | } |
466 | 472 | ... | ... |
... | @@ -53,10 +53,7 @@ import org.onosproject.bgpio.types.LinkStateAttributes; | ... | @@ -53,10 +53,7 @@ import org.onosproject.bgpio.types.LinkStateAttributes; |
53 | import org.onosproject.incubator.net.resource.label.LabelResourceAdminService; | 53 | import org.onosproject.incubator.net.resource.label.LabelResourceAdminService; |
54 | import org.onosproject.incubator.net.resource.label.LabelResourceId; | 54 | import org.onosproject.incubator.net.resource.label.LabelResourceId; |
55 | import org.onosproject.incubator.net.resource.label.LabelResourcePool; | 55 | import org.onosproject.incubator.net.resource.label.LabelResourcePool; |
56 | -import org.onosproject.mastership.MastershipEvent; | ||
57 | -import org.onosproject.mastership.MastershipListener; | ||
58 | import org.onosproject.mastership.MastershipServiceAdapter; | 56 | import org.onosproject.mastership.MastershipServiceAdapter; |
59 | -import org.onosproject.mastership.MastershipEvent.Type; | ||
60 | import org.onosproject.net.link.LinkServiceAdapter; | 57 | import org.onosproject.net.link.LinkServiceAdapter; |
61 | import org.onosproject.bgpio.types.LinkLocalRemoteIdentifiersTlv; | 58 | import org.onosproject.bgpio.types.LinkLocalRemoteIdentifiersTlv; |
62 | import org.onosproject.bgpio.types.RouteDistinguisher; | 59 | import org.onosproject.bgpio.types.RouteDistinguisher; |
... | @@ -68,8 +65,8 @@ import org.onosproject.bgpio.types.attr.BgpLinkAttrMaxLinkBandwidth; | ... | @@ -68,8 +65,8 @@ import org.onosproject.bgpio.types.attr.BgpLinkAttrMaxLinkBandwidth; |
68 | import org.onosproject.bgpio.types.attr.BgpLinkAttrTeDefaultMetric; | 65 | import org.onosproject.bgpio.types.attr.BgpLinkAttrTeDefaultMetric; |
69 | import org.onosproject.bgpio.util.Constants; | 66 | import org.onosproject.bgpio.util.Constants; |
70 | import org.onosproject.cluster.NodeId; | 67 | import org.onosproject.cluster.NodeId; |
71 | -import org.onosproject.cluster.RoleInfo; | ||
72 | import org.onosproject.net.ConnectPoint; | 68 | import org.onosproject.net.ConnectPoint; |
69 | +import org.onosproject.net.DefaultAnnotations; | ||
73 | import org.onosproject.net.DefaultDevice; | 70 | import org.onosproject.net.DefaultDevice; |
74 | import org.onosproject.net.DefaultLink; | 71 | import org.onosproject.net.DefaultLink; |
75 | import org.onosproject.net.Device; | 72 | import org.onosproject.net.Device; |
... | @@ -82,6 +79,8 @@ import org.onosproject.net.config.ConfigApplyDelegate; | ... | @@ -82,6 +79,8 @@ import org.onosproject.net.config.ConfigApplyDelegate; |
82 | import org.onosproject.net.config.ConfigFactory; | 79 | import org.onosproject.net.config.ConfigFactory; |
83 | import org.onosproject.net.config.NetworkConfigRegistryAdapter; | 80 | import org.onosproject.net.config.NetworkConfigRegistryAdapter; |
84 | import org.onosproject.net.device.DeviceDescription; | 81 | import org.onosproject.net.device.DeviceDescription; |
82 | +import org.onosproject.net.device.DeviceEvent; | ||
83 | +import org.onosproject.net.device.DeviceListener; | ||
85 | import org.onosproject.net.device.DeviceProvider; | 84 | import org.onosproject.net.device.DeviceProvider; |
86 | import org.onosproject.net.device.DeviceProviderRegistry; | 85 | import org.onosproject.net.device.DeviceProviderRegistry; |
87 | import org.onosproject.net.device.DeviceProviderService; | 86 | import org.onosproject.net.device.DeviceProviderService; |
... | @@ -122,7 +121,7 @@ public class BgpTopologyProviderTest { | ... | @@ -122,7 +121,7 @@ public class BgpTopologyProviderTest { |
122 | private MockNetConfigRegistryAdapter networkConfigService = new MockNetConfigRegistryAdapter(); | 121 | private MockNetConfigRegistryAdapter networkConfigService = new MockNetConfigRegistryAdapter(); |
123 | private MockLabelResourceService labelResourceAdminService = new MockLabelResourceService(); | 122 | private MockLabelResourceService labelResourceAdminService = new MockLabelResourceService(); |
124 | private Map<DeviceId, Device> deviceMap = new HashMap<>(); | 123 | private Map<DeviceId, Device> deviceMap = new HashMap<>(); |
125 | - private MastershipListener listener; | 124 | + private DeviceListener listener; |
126 | 125 | ||
127 | @Before | 126 | @Before |
128 | public void startUp() throws TestUtilsException { | 127 | public void startUp() throws TestUtilsException { |
... | @@ -134,7 +133,7 @@ public class BgpTopologyProviderTest { | ... | @@ -134,7 +133,7 @@ public class BgpTopologyProviderTest { |
134 | provider.labelResourceAdminService = labelResourceAdminService; | 133 | provider.labelResourceAdminService = labelResourceAdminService; |
135 | provider.mastershipService = mastershipService; | 134 | provider.mastershipService = mastershipService; |
136 | provider.networkConfigService = networkConfigService; | 135 | provider.networkConfigService = networkConfigService; |
137 | - listener = TestUtils.getField(provider, "masterListener"); | 136 | + listener = TestUtils.getField(provider, "deviceListener"); |
138 | provider.activate(); | 137 | provider.activate(); |
139 | assertThat("device provider should be registered", not(nodeRegistry.provider)); | 138 | assertThat("device provider should be registered", not(nodeRegistry.provider)); |
140 | assertThat("link provider should be registered", not(linkRegistry.linkProvider)); | 139 | assertThat("link provider should be registered", not(linkRegistry.linkProvider)); |
... | @@ -887,10 +886,14 @@ public class BgpTopologyProviderTest { | ... | @@ -887,10 +886,14 @@ public class BgpTopologyProviderTest { |
887 | l.addNode(nodeNlri, details); | 886 | l.addNode(nodeNlri, details); |
888 | assertThat(nodeRegistry.connected.size(), is(1)); | 887 | assertThat(nodeRegistry.connected.size(), is(1)); |
889 | } | 888 | } |
889 | + DefaultAnnotations.Builder newBuilder = DefaultAnnotations.builder(); | ||
890 | 890 | ||
891 | - MastershipEvent event = new MastershipEvent(Type.MASTER_CHANGED, nodeRegistry.connected.iterator().next(), | 891 | + newBuilder.set("lsrId", "1.1.1.1"); |
892 | - new RoleInfo(NodeId.nodeId("Node1"), new LinkedList<>())); | ||
893 | 892 | ||
893 | + Device device = new DefaultDevice(BgpTopologyProviderTest.providerId, nodeRegistry.connected.iterator().next(), | ||
894 | + Device.Type.ROUTER, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, new ChassisId(), newBuilder.build()); | ||
895 | + | ||
896 | + DeviceEvent event = new DeviceEvent(DeviceEvent.Type.DEVICE_ADDED, device); | ||
894 | listener.event(event); | 897 | listener.event(event); |
895 | assertThat(labelResourceAdminService.resourcePool.keySet().size(), is(1)); | 898 | assertThat(labelResourceAdminService.resourcePool.keySet().size(), is(1)); |
896 | } | 899 | } |
... | @@ -926,9 +929,16 @@ public class BgpTopologyProviderTest { | ... | @@ -926,9 +929,16 @@ public class BgpTopologyProviderTest { |
926 | for (BgpNodeListener l : controller.nodeListener) { | 929 | for (BgpNodeListener l : controller.nodeListener) { |
927 | l.addNode(nodeNlri, details); | 930 | l.addNode(nodeNlri, details); |
928 | assertThat(nodeRegistry.connected.size(), is(1)); | 931 | assertThat(nodeRegistry.connected.size(), is(1)); |
929 | - // Check label resource reserved for that device | 932 | + |
930 | - MastershipEvent event = new MastershipEvent(Type.MASTER_CHANGED, nodeRegistry.connected.iterator().next(), | 933 | + DefaultAnnotations.Builder newBuilder = DefaultAnnotations.builder(); |
931 | - new RoleInfo(NodeId.nodeId("Node1"), new LinkedList<>())); | 934 | + |
935 | + newBuilder.set("lsrId", "1.1.1.1"); | ||
936 | + | ||
937 | + Device device = new DefaultDevice(BgpTopologyProviderTest.providerId, | ||
938 | + nodeRegistry.connected.iterator().next(), Device.Type.ROUTER, UNKNOWN, | ||
939 | + UNKNOWN, UNKNOWN, UNKNOWN, new ChassisId(), newBuilder.build()); | ||
940 | + | ||
941 | + DeviceEvent event = new DeviceEvent(DeviceEvent.Type.DEVICE_ADDED, device); | ||
932 | listener.event(event); | 942 | listener.event(event); |
933 | assertThat(labelResourceAdminService.resourcePool.keySet().size(), is(1)); | 943 | assertThat(labelResourceAdminService.resourcePool.keySet().size(), is(1)); |
934 | 944 | ||
... | @@ -988,8 +998,15 @@ public class BgpTopologyProviderTest { | ... | @@ -988,8 +998,15 @@ public class BgpTopologyProviderTest { |
988 | l.addNode(nodeNlri, details); | 998 | l.addNode(nodeNlri, details); |
989 | assertThat(nodeRegistry.connected.size(), is(1)); | 999 | assertThat(nodeRegistry.connected.size(), is(1)); |
990 | //Check label resource reserved for that device | 1000 | //Check label resource reserved for that device |
991 | - MastershipEvent event = new MastershipEvent(Type.MASTER_CHANGED, nodeRegistry.connected.iterator().next(), | 1001 | + DefaultAnnotations.Builder newBuilder = DefaultAnnotations.builder(); |
992 | - new RoleInfo(NodeId.nodeId("Node1"), new LinkedList<>())); | 1002 | + |
1003 | + newBuilder.set("lsrId", "1.1.1.1"); | ||
1004 | + | ||
1005 | + Device device = new DefaultDevice(BgpTopologyProviderTest.providerId, | ||
1006 | + nodeRegistry.connected.iterator().next(), Device.Type.ROUTER, | ||
1007 | + UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, new ChassisId(), newBuilder.build()); | ||
1008 | + | ||
1009 | + DeviceEvent event = new DeviceEvent(DeviceEvent.Type.DEVICE_ADDED, device); | ||
993 | listener.event(event); | 1010 | listener.event(event); |
994 | assertThat(labelResourceAdminService.resourcePool.keySet().size(), is(1)); | 1011 | assertThat(labelResourceAdminService.resourcePool.keySet().size(), is(1)); |
995 | l.addNode(remNodeNlri, details); | 1012 | l.addNode(remNodeNlri, details); | ... | ... |
... | @@ -573,18 +573,22 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid | ... | @@ -573,18 +573,22 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid |
573 | return tunnelId; | 573 | return tunnelId; |
574 | } | 574 | } |
575 | 575 | ||
576 | - private void tunnelUpdated(Tunnel tunnel, Path path) { | 576 | + private void tunnelUpdated(Tunnel tunnel, Path path, State tunnelState) { |
577 | - handleTunnelUpdate(tunnel, path); | 577 | + handleTunnelUpdate(tunnel, path, tunnelState); |
578 | } | 578 | } |
579 | 579 | ||
580 | //Handles tunnel updated using tunnel admin service[specially to update annotations]. | 580 | //Handles tunnel updated using tunnel admin service[specially to update annotations]. |
581 | - private void handleTunnelUpdate(Tunnel tunnel, Path path) { | 581 | + private void handleTunnelUpdate(Tunnel tunnel, Path path, State tunnelState) { |
582 | 582 | ||
583 | if (tunnel.type() == MPLS) { | 583 | if (tunnel.type() == MPLS) { |
584 | pcepTunnelApiMapper.removeFromCoreTunnelRequestQueue(tunnel.tunnelId()); | 584 | pcepTunnelApiMapper.removeFromCoreTunnelRequestQueue(tunnel.tunnelId()); |
585 | 585 | ||
586 | - tunnelAdminService.updateTunnel(tunnel, path); | 586 | + TunnelDescription td = new DefaultTunnelDescription(tunnel.tunnelId(), tunnel.src(), tunnel.dst(), |
587 | + tunnel.type(), tunnel.groupId(), tunnel.providerId(), | ||
588 | + tunnel.tunnelName(), path, tunnel.resource(), | ||
589 | + (SparseAnnotations) tunnel.annotations()); | ||
587 | 590 | ||
591 | + service.tunnelUpdated(td, tunnelState); | ||
588 | return; | 592 | return; |
589 | } | 593 | } |
590 | 594 | ||
... | @@ -1451,7 +1455,7 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid | ... | @@ -1451,7 +1455,7 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid |
1451 | } | 1455 | } |
1452 | 1456 | ||
1453 | private SparseAnnotations getAnnotations(PcepLspObject lspObj, StatefulIPv4LspIdentifiersTlv ipv4LspIdenTlv, | 1457 | private SparseAnnotations getAnnotations(PcepLspObject lspObj, StatefulIPv4LspIdentifiersTlv ipv4LspIdenTlv, |
1454 | - float bandwidth, LspType lspType, String costType) { | 1458 | + float bandwidth, LspType lspType, String costType, boolean isPceInit) { |
1455 | 1459 | ||
1456 | Builder builder = DefaultAnnotations.builder(); | 1460 | Builder builder = DefaultAnnotations.builder(); |
1457 | 1461 | ||
... | @@ -1463,8 +1467,13 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid | ... | @@ -1463,8 +1467,13 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid |
1463 | builder.set(COST_TYPE, costType); | 1467 | builder.set(COST_TYPE, costType); |
1464 | } | 1468 | } |
1465 | 1469 | ||
1470 | + if (isPceInit) { | ||
1471 | + builder.set(PCE_INIT, String.valueOf(isPceInit)); | ||
1472 | + } | ||
1473 | + | ||
1466 | SparseAnnotations annotations = builder | 1474 | SparseAnnotations annotations = builder |
1467 | - .set(BANDWIDTH, (new Float(bandwidth)).toString()).set(LSP_SIG_TYPE, lspType.name()) | 1475 | + .set(BANDWIDTH, (new Float(bandwidth)).toString()) |
1476 | + .set(LSP_SIG_TYPE, lspType.name()) | ||
1468 | .set(PCC_TUNNEL_ID, String.valueOf(ipv4LspIdenTlv.getTunnelId())) | 1477 | .set(PCC_TUNNEL_ID, String.valueOf(ipv4LspIdenTlv.getTunnelId())) |
1469 | .set(PLSP_ID, String.valueOf(lspObj.getPlspId())) | 1478 | .set(PLSP_ID, String.valueOf(lspObj.getPlspId())) |
1470 | .set(LOCAL_LSP_ID, String.valueOf(ipv4LspIdenTlv.getLspId())) | 1479 | .set(LOCAL_LSP_ID, String.valueOf(ipv4LspIdenTlv.getLspId())) |
... | @@ -1530,6 +1539,7 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid | ... | @@ -1530,6 +1539,7 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid |
1530 | bandwidth = attributes.getBandwidthObject().getBandwidth(); | 1539 | bandwidth = attributes.getBandwidthObject().getBandwidth(); |
1531 | } | 1540 | } |
1532 | } | 1541 | } |
1542 | + PcepLspObject lspObj = stateRpt.getLspObject(); | ||
1533 | List<Object> eroSubObjList = buildPathFromEroObj(eroObj, providerId); | 1543 | List<Object> eroSubObjList = buildPathFromEroObj(eroObj, providerId); |
1534 | List<Link> links = new ArrayList<>(); | 1544 | List<Link> links = new ArrayList<>(); |
1535 | List<LabelResourceId> labels = new ArrayList<>(); | 1545 | List<LabelResourceId> labels = new ArrayList<>(); |
... | @@ -1540,21 +1550,20 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid | ... | @@ -1540,21 +1550,20 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid |
1540 | labels.add(LabelResourceId.labelResourceId(((Integer) linkOrLabel).longValue())); | 1550 | labels.add(LabelResourceId.labelResourceId(((Integer) linkOrLabel).longValue())); |
1541 | } | 1551 | } |
1542 | } | 1552 | } |
1543 | - if (links.isEmpty()) { | 1553 | + Path path = null; |
1554 | + if (!links.isEmpty()) { | ||
1555 | + path = new DefaultPath(providerId, links, cost, EMPTY); | ||
1556 | + } else if (!lspObj.getRFlag()) { | ||
1544 | return; | 1557 | return; |
1545 | } | 1558 | } |
1546 | - Path path = new DefaultPath(providerId, links, cost, EMPTY); | ||
1547 | NetworkResource labelStack = new DefaultLabelStack(labels); | 1559 | NetworkResource labelStack = new DefaultLabelStack(labels); |
1548 | // To carry PST TLV, SRP object can be present with value 0 even when PCRpt is not in response to any action | 1560 | // To carry PST TLV, SRP object can be present with value 0 even when PCRpt is not in response to any action |
1549 | // from PCE. | 1561 | // from PCE. |
1550 | PcepSrpObject srpObj = stateRpt.getSrpObject(); | 1562 | PcepSrpObject srpObj = stateRpt.getSrpObject(); |
1551 | LspType lspType = getLspType(srpObj); | 1563 | LspType lspType = getLspType(srpObj); |
1552 | - | ||
1553 | - PcepLspObject lspObj = stateRpt.getLspObject(); | ||
1554 | ListIterator<PcepValueType> listTlvIterator = lspObj.getOptionalTlv().listIterator(); | 1564 | ListIterator<PcepValueType> listTlvIterator = lspObj.getOptionalTlv().listIterator(); |
1555 | StatefulIPv4LspIdentifiersTlv ipv4LspIdenTlv = null; | 1565 | StatefulIPv4LspIdentifiersTlv ipv4LspIdenTlv = null; |
1556 | SymbolicPathNameTlv pathNameTlv = null; | 1566 | SymbolicPathNameTlv pathNameTlv = null; |
1557 | - | ||
1558 | while (listTlvIterator.hasNext()) { | 1567 | while (listTlvIterator.hasNext()) { |
1559 | PcepValueType tlv = listTlvIterator.next(); | 1568 | PcepValueType tlv = listTlvIterator.next(); |
1560 | switch (tlv.getType()) { | 1569 | switch (tlv.getType()) { |
... | @@ -1629,12 +1638,10 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid | ... | @@ -1629,12 +1638,10 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid |
1629 | log.error("Ingress deviceId not found"); | 1638 | log.error("Ingress deviceId not found"); |
1630 | return; | 1639 | return; |
1631 | } | 1640 | } |
1632 | - annotations = getAnnotations(lspObj, ipv4LspIdenTlv, bandwidth, lspType, costType); | 1641 | + annotations = getAnnotations(lspObj, ipv4LspIdenTlv, bandwidth, lspType, costType, lspObj.getCFlag()); |
1633 | - | ||
1634 | td = new DefaultTunnelDescription(null, tunnelEndPointSrc, tunnelEndPointDst, MPLS, new DefaultGroupId( | 1642 | td = new DefaultTunnelDescription(null, tunnelEndPointSrc, tunnelEndPointDst, MPLS, new DefaultGroupId( |
1635 | 0), providerId, TunnelName.tunnelName(new String(pathNameTlv.getValue())), path, labelStack, | 1643 | 0), providerId, TunnelName.tunnelName(new String(pathNameTlv.getValue())), path, labelStack, |
1636 | annotations); | 1644 | annotations); |
1637 | - | ||
1638 | // Do not support PCC initiated LSP after LSP DB sync is completed. | 1645 | // Do not support PCC initiated LSP after LSP DB sync is completed. |
1639 | if (!lspObj.getSFlag() && !lspObj.getCFlag()) { | 1646 | if (!lspObj.getSFlag() && !lspObj.getCFlag()) { |
1640 | log.error("Received PCC initiated LSP while not in sync."); | 1647 | log.error("Received PCC initiated LSP while not in sync."); |
... | @@ -1671,43 +1678,58 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid | ... | @@ -1671,43 +1678,58 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid |
1671 | pcepTunnelApiMapper.addToTunnelIdMap(pcepTunnelData); | 1678 | pcepTunnelApiMapper.addToTunnelIdMap(pcepTunnelData); |
1672 | } else if (!mastershipService.isLocalMaster(deviceId) && lspObj.getDFlag()) { | 1679 | } else if (!mastershipService.isLocalMaster(deviceId) && lspObj.getDFlag()) { |
1673 | //Start timer then update the tunnel with D flag | 1680 | //Start timer then update the tunnel with D flag |
1674 | - tunnelUpdateInDelegatedCase(pccId, annotations, td, providerId); | 1681 | + tunnelUpdateInDelegatedCase(pccId, annotations, td, providerId, tunnelState, ipv4LspIdenTlv); |
1675 | } | 1682 | } |
1676 | return; | 1683 | return; |
1677 | } | 1684 | } |
1678 | - | ||
1679 | //delegated owner will update can be a master or non-master | 1685 | //delegated owner will update can be a master or non-master |
1680 | - if (lspObj.getDFlag()) { | 1686 | + if (lspObj.getDFlag() && !lspObj.getRFlag()) { |
1687 | + tunnelUpdateForDelegatedLsp(tunnel, lspObj, | ||
1688 | + lspType, tunnelState, pccId, labelStack, ipv4LspIdenTlv); | ||
1689 | + return; | ||
1690 | + } | ||
1691 | + removeOrUpdatetunnel(tunnel, lspObj, providerId, tunnelState, ipv4LspIdenTlv); | ||
1692 | + } | ||
1681 | 1693 | ||
1694 | + private void tunnelUpdateForDelegatedLsp(Tunnel tunnel, PcepLspObject lspObj, | ||
1695 | + LspType lspType, State tunnelState, PccId pccId, | ||
1696 | + NetworkResource labelStack, | ||
1697 | + StatefulIPv4LspIdentifiersTlv ipv4LspIdenTlv) { | ||
1698 | + SparseAnnotations annotations = null; | ||
1699 | + Float bandwidth = 0.0f; | ||
1700 | + DefaultTunnelDescription td; | ||
1682 | if (tunnel.annotations().value(BANDWIDTH) != null) { | 1701 | if (tunnel.annotations().value(BANDWIDTH) != null) { |
1683 | bandwidth = Float.parseFloat(tunnel.annotations().value(BANDWIDTH)); | 1702 | bandwidth = Float.parseFloat(tunnel.annotations().value(BANDWIDTH)); |
1684 | } | 1703 | } |
1704 | + boolean isPceInit = tunnel.annotations().value(PCE_INIT) == null ? false : | ||
1705 | + Boolean.valueOf((tunnel.annotations().value(PCE_INIT))).booleanValue(); | ||
1685 | annotations = getAnnotations(lspObj, ipv4LspIdenTlv, | 1706 | annotations = getAnnotations(lspObj, ipv4LspIdenTlv, |
1686 | bandwidth, lspType, | 1707 | bandwidth, lspType, |
1687 | - tunnel.annotations().value(COST_TYPE)); | 1708 | + tunnel.annotations().value(COST_TYPE), isPceInit); |
1688 | - td = new DefaultTunnelDescription(null, tunnelEndPointSrc, tunnelEndPointDst, MPLS, new DefaultGroupId( | 1709 | + td = new DefaultTunnelDescription(null, tunnel.src(), tunnel.dst(), MPLS, new DefaultGroupId( |
1689 | - 0), providerId, TunnelName.tunnelName(new String(pathNameTlv.getValue())), | 1710 | + 0), tunnel.providerId(), tunnel.tunnelName(), |
1690 | tunnel.path(), labelStack, annotations); | 1711 | tunnel.path(), labelStack, annotations); |
1691 | - tunnelUpdateInDelegatedCase(pccId, annotations, td, providerId); | 1712 | + tunnelUpdateInDelegatedCase(pccId, annotations, td, tunnel.providerId(), tunnelState, ipv4LspIdenTlv); |
1692 | - } | ||
1693 | - removeOrUpdatetunnel(tunnel, pccId, lspObj, providerId, tunnelState); | ||
1694 | - return; | ||
1695 | } | 1713 | } |
1696 | 1714 | ||
1697 | - private void removeOrUpdatetunnel(Tunnel tunnel, PccId pccId, PcepLspObject lspObj, ProviderId providerId, | 1715 | + private void removeOrUpdatetunnel(Tunnel tunnel, PcepLspObject lspObj, ProviderId providerId, |
1698 | - State tunnelState) { | 1716 | + State tunnelState, StatefulIPv4LspIdentifiersTlv ipv4LspIdenTlv) { |
1699 | DefaultTunnelDescription td = new DefaultTunnelDescription(tunnel.tunnelId(), tunnel.src(), tunnel.dst(), | 1717 | DefaultTunnelDescription td = new DefaultTunnelDescription(tunnel.tunnelId(), tunnel.src(), tunnel.dst(), |
1700 | tunnel.type(), tunnel.groupId(), providerId, tunnel.tunnelName(), tunnel.path(), | 1718 | tunnel.type(), tunnel.groupId(), providerId, tunnel.tunnelName(), tunnel.path(), |
1701 | (SparseAnnotations) tunnel.annotations()); | 1719 | (SparseAnnotations) tunnel.annotations()); |
1702 | if (lspObj.getRFlag()) { | 1720 | if (lspObj.getRFlag()) { |
1703 | tunnelRemoved(td); | 1721 | tunnelRemoved(td); |
1704 | } else { | 1722 | } else { |
1723 | + PcepTunnelData pcepTunnelData = new PcepTunnelData(tunnel, tunnel.path(), LSP_STATE_RPT); | ||
1724 | + pcepTunnelData.setStatefulIpv4IndentifierTlv(ipv4LspIdenTlv); | ||
1725 | + pcepTunnelApiMapper.addToTunnelIdMap(pcepTunnelData); | ||
1705 | tunnelUpdated(td, tunnelState); | 1726 | tunnelUpdated(td, tunnelState); |
1706 | } | 1727 | } |
1707 | } | 1728 | } |
1708 | 1729 | ||
1709 | private void tunnelUpdateInDelegatedCase(PccId pccId, SparseAnnotations annotations, | 1730 | private void tunnelUpdateInDelegatedCase(PccId pccId, SparseAnnotations annotations, |
1710 | - DefaultTunnelDescription td, ProviderId providerId) { | 1731 | + DefaultTunnelDescription td, ProviderId providerId, State tunnelState, |
1732 | + StatefulIPv4LspIdentifiersTlv ipv4LspIdentifiersTlv) { | ||
1711 | //Wait for 2sec then query tunnel based on ingress PLSP-ID and local LSP-ID | 1733 | //Wait for 2sec then query tunnel based on ingress PLSP-ID and local LSP-ID |
1712 | 1734 | ||
1713 | /* | 1735 | /* |
... | @@ -1718,7 +1740,7 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid | ... | @@ -1718,7 +1740,7 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid |
1718 | 1740 | ||
1719 | // Thread is started after 2 seconds first time later periodically after 2 seconds to update the tunnel | 1741 | // Thread is started after 2 seconds first time later periodically after 2 seconds to update the tunnel |
1720 | executor.scheduleAtFixedRate(new UpdateDelegation(td, providerId, annotations, pccId, | 1742 | executor.scheduleAtFixedRate(new UpdateDelegation(td, providerId, annotations, pccId, |
1721 | - executor), DELAY, DELAY, TimeUnit.SECONDS); | 1743 | + executor, tunnelState, ipv4LspIdentifiersTlv), DELAY, DELAY, TimeUnit.SECONDS); |
1722 | } | 1744 | } |
1723 | 1745 | ||
1724 | /** | 1746 | /** |
... | @@ -1823,7 +1845,6 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid | ... | @@ -1823,7 +1845,6 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid |
1823 | // the other sub objects are not required | 1845 | // the other sub objects are not required |
1824 | } | 1846 | } |
1825 | } | 1847 | } |
1826 | - | ||
1827 | return subObjList; | 1848 | return subObjList; |
1828 | } | 1849 | } |
1829 | 1850 | ||
... | @@ -1881,7 +1902,6 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid | ... | @@ -1881,7 +1902,6 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid |
1881 | return service.tunnelQueryById(tunnelId); | 1902 | return service.tunnelQueryById(tunnelId); |
1882 | } | 1903 | } |
1883 | 1904 | ||
1884 | - | ||
1885 | private DeviceId getDevice(PccId pccId) { | 1905 | private DeviceId getDevice(PccId pccId) { |
1886 | // Get lsrId of the PCEP client from the PCC ID. Session info is based on lsrID. | 1906 | // Get lsrId of the PCEP client from the PCC ID. Session info is based on lsrID. |
1887 | IpAddress lsrId = pccId.ipAddress(); | 1907 | IpAddress lsrId = pccId.ipAddress(); |
... | @@ -1908,6 +1928,8 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid | ... | @@ -1908,6 +1928,8 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid |
1908 | SparseAnnotations annotations; | 1928 | SparseAnnotations annotations; |
1909 | PccId pccId; | 1929 | PccId pccId; |
1910 | ScheduledExecutorService executor; | 1930 | ScheduledExecutorService executor; |
1931 | + State tunnelState; | ||
1932 | + StatefulIPv4LspIdentifiersTlv ipv4LspIdentifiersTlv; | ||
1911 | 1933 | ||
1912 | /** | 1934 | /** |
1913 | * Creates an instance of UpdateDelegation. | 1935 | * Creates an instance of UpdateDelegation. |
... | @@ -1919,12 +1941,15 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid | ... | @@ -1919,12 +1941,15 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid |
1919 | * @param executor service of delegated owner | 1941 | * @param executor service of delegated owner |
1920 | */ | 1942 | */ |
1921 | public UpdateDelegation(DefaultTunnelDescription td, ProviderId providerId, SparseAnnotations annotations, | 1943 | public UpdateDelegation(DefaultTunnelDescription td, ProviderId providerId, SparseAnnotations annotations, |
1922 | - PccId pccId, ScheduledExecutorService executor) { | 1944 | + PccId pccId, ScheduledExecutorService executor, State tunnelState, |
1945 | + StatefulIPv4LspIdentifiersTlv ipv4LspIdentifiersTlv) { | ||
1923 | this.td = td; | 1946 | this.td = td; |
1924 | this.providerId = providerId; | 1947 | this.providerId = providerId; |
1925 | this.annotations = annotations; | 1948 | this.annotations = annotations; |
1926 | this.pccId = pccId; | 1949 | this.pccId = pccId; |
1927 | this.executor = executor; | 1950 | this.executor = executor; |
1951 | + this.tunnelState = tunnelState; | ||
1952 | + this.ipv4LspIdentifiersTlv = ipv4LspIdentifiersTlv; | ||
1928 | } | 1953 | } |
1929 | 1954 | ||
1930 | //Temporary using annotations later will use projection/network config service | 1955 | //Temporary using annotations later will use projection/network config service |
... | @@ -1950,7 +1975,11 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid | ... | @@ -1950,7 +1975,11 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid |
1950 | if (tempTunnelId != null) { | 1975 | if (tempTunnelId != null) { |
1951 | Tunnel tunnel = new DefaultTunnel(providerId, td.src(), td.dst(), MPLS, new DefaultGroupId(0), | 1976 | Tunnel tunnel = new DefaultTunnel(providerId, td.src(), td.dst(), MPLS, new DefaultGroupId(0), |
1952 | tempTunnelId, td.tunnelName(), td.path(), annotations); | 1977 | tempTunnelId, td.tunnelName(), td.path(), annotations); |
1953 | - tunnelUpdated(tunnel, td.path()); | 1978 | + PcepTunnelData pcepTunnelData = new PcepTunnelData(tunnel, tunnel.path(), LSP_STATE_RPT); |
1979 | + pcepTunnelData.setStatefulIpv4IndentifierTlv(ipv4LspIdentifiersTlv); | ||
1980 | + pcepTunnelData.setLspDFlag(Boolean.valueOf(tunnel.annotations().value(DELEGATE))); | ||
1981 | + pcepTunnelApiMapper.addToTunnelIdMap(pcepTunnelData); | ||
1982 | + tunnelUpdated(tunnel, td.path(), tunnelState); | ||
1954 | executor.shutdown(); | 1983 | executor.shutdown(); |
1955 | try { | 1984 | try { |
1956 | executor.awaitTermination(WAIT_TIME, TimeUnit.SECONDS); | 1985 | executor.awaitTermination(WAIT_TIME, TimeUnit.SECONDS); | ... | ... |
... | @@ -36,6 +36,7 @@ import java.util.Collection; | ... | @@ -36,6 +36,7 @@ import java.util.Collection; |
36 | import java.util.Collections; | 36 | import java.util.Collections; |
37 | import java.util.HashMap; | 37 | import java.util.HashMap; |
38 | import java.util.HashSet; | 38 | import java.util.HashSet; |
39 | +import java.util.Iterator; | ||
39 | import java.util.LinkedList; | 40 | import java.util.LinkedList; |
40 | import java.util.List; | 41 | import java.util.List; |
41 | import java.util.concurrent.TimeUnit; | 42 | import java.util.concurrent.TimeUnit; |
... | @@ -88,6 +89,7 @@ import org.onosproject.pcep.controller.ClientCapability; | ... | @@ -88,6 +89,7 @@ import org.onosproject.pcep.controller.ClientCapability; |
88 | import org.onosproject.pcep.controller.LspKey; | 89 | import org.onosproject.pcep.controller.LspKey; |
89 | import org.onosproject.pcep.controller.PccId; | 90 | import org.onosproject.pcep.controller.PccId; |
90 | 91 | ||
92 | +import com.esotericsoftware.minlog.Log; | ||
91 | import com.google.common.collect.FluentIterable; | 93 | import com.google.common.collect.FluentIterable; |
92 | import com.google.common.collect.ImmutableSet; | 94 | import com.google.common.collect.ImmutableSet; |
93 | 95 | ||
... | @@ -223,6 +225,7 @@ public class PcepTunnelAddedTest { | ... | @@ -223,6 +225,7 @@ public class PcepTunnelAddedTest { |
223 | tunnel.path(), | 225 | tunnel.path(), |
224 | tunnel.resource(), | 226 | tunnel.resource(), |
225 | tunnel.annotations()); | 227 | tunnel.annotations()); |
228 | + Log.info("tunnel.annotations().toString() " + tunnel.annotations().toString()); | ||
226 | tunnelService.tunnelIdAsKeyStore.put(id, storedTunnel); | 229 | tunnelService.tunnelIdAsKeyStore.put(id, storedTunnel); |
227 | return id; | 230 | return id; |
228 | } | 231 | } |
... | @@ -237,6 +240,18 @@ public class PcepTunnelAddedTest { | ... | @@ -237,6 +240,18 @@ public class PcepTunnelAddedTest { |
237 | 240 | ||
238 | @Override | 241 | @Override |
239 | public void tunnelUpdated(TunnelDescription tunnel, State state) { | 242 | public void tunnelUpdated(TunnelDescription tunnel, State state) { |
243 | + TunnelId id = TunnelId.valueOf(String.valueOf(++tunnelIdCounter)); | ||
244 | + Tunnel storedTunnel = new DefaultTunnel(ProviderId.NONE, | ||
245 | + tunnel.src(), tunnel.dst(), | ||
246 | + tunnel.type(), | ||
247 | + tunnel.groupId(), | ||
248 | + id, | ||
249 | + tunnel.tunnelName(), | ||
250 | + tunnel.path(), | ||
251 | + tunnel.resource(), | ||
252 | + tunnel.annotations()); | ||
253 | + tunnelService.tunnelIdAsKeyStore.put(id, storedTunnel); | ||
254 | + Log.info("tunnelService.tunnelIdAsKeyStore ++ " + tunnelService.tunnelIdAsKeyStore.toString()); | ||
240 | } | 255 | } |
241 | 256 | ||
242 | @Override | 257 | @Override |
... | @@ -254,6 +269,7 @@ public class PcepTunnelAddedTest { | ... | @@ -254,6 +269,7 @@ public class PcepTunnelAddedTest { |
254 | public TunnelId setupTunnel(ApplicationId producerId, ElementId srcElementId, Tunnel tunnel, Path path) { | 269 | public TunnelId setupTunnel(ApplicationId producerId, ElementId srcElementId, Tunnel tunnel, Path path) { |
255 | TunnelId tunnelId = TunnelId.valueOf(String.valueOf(++tunnelIdCounter)); | 270 | TunnelId tunnelId = TunnelId.valueOf(String.valueOf(++tunnelIdCounter)); |
256 | tunnelIdAsKeyStore.put(tunnelId, tunnel); | 271 | tunnelIdAsKeyStore.put(tunnelId, tunnel); |
272 | + Log.info("tunnelIdAsKeyStore insetup :: " + tunnelIdAsKeyStore.toString()); | ||
257 | return tunnelId; | 273 | return tunnelId; |
258 | } | 274 | } |
259 | 275 | ||
... | @@ -592,8 +608,11 @@ public class PcepTunnelAddedTest { | ... | @@ -592,8 +608,11 @@ public class PcepTunnelAddedTest { |
592 | 608 | ||
593 | controller.processClientMessage(PccId.pccId(IpAddress.valueOf("1.1.1.1")), message); | 609 | controller.processClientMessage(PccId.pccId(IpAddress.valueOf("1.1.1.1")), message); |
594 | TimeUnit.MILLISECONDS.sleep(4000); | 610 | TimeUnit.MILLISECONDS.sleep(4000); |
595 | - assertThat(registry.tunnelIdCounter, is((long) 1)); | 611 | + assertThat(registry.tunnelIdCounter, is((long) 2)); |
596 | - assertThat(tunnelService.tunnelIdAsKeyStore.values().iterator().next().annotations().value(DELEGATE), | 612 | + |
613 | + Iterator<Tunnel> iterator = tunnelService.tunnelIdAsKeyStore.values().iterator(); | ||
614 | + iterator.next(); | ||
615 | + assertThat(iterator.next().annotations().value(DELEGATE), | ||
597 | is("true")); | 616 | is("true")); |
598 | } | 617 | } |
599 | 618 | ... | ... |
-
Please register or login to post a comment