Committed by
ShashikanthVH-Huawei
Bgp link listener deleted.
Change-Id: Ie853639739dd474bea2aebc013bb378c6dc8163a
Showing
5 changed files
with
9 additions
and
280 deletions
| ... | @@ -58,20 +58,6 @@ public interface BgpController { | ... | @@ -58,20 +58,6 @@ public interface BgpController { |
| 58 | void removeListener(BgpNodeListener listener); | 58 | void removeListener(BgpNodeListener listener); |
| 59 | 59 | ||
| 60 | /** | 60 | /** |
| 61 | - * Register a listener for BGP message events. | ||
| 62 | - * | ||
| 63 | - * @param listener the listener to notify | ||
| 64 | - */ | ||
| 65 | - void addLinkListener(BgpLinkListener listener); | ||
| 66 | - | ||
| 67 | - /** | ||
| 68 | - * Unregister a listener. | ||
| 69 | - * | ||
| 70 | - * @param listener the listener to unregister | ||
| 71 | - */ | ||
| 72 | - void removeLinkListener(BgpLinkListener listener); | ||
| 73 | - | ||
| 74 | - /** | ||
| 75 | * Send a message to a particular bgp peer. | 61 | * Send a message to a particular bgp peer. |
| 76 | * | 62 | * |
| 77 | * @param bgpId the id of the peer to send message. | 63 | * @param bgpId the id of the peer to send message. |
| ... | @@ -128,11 +114,4 @@ public interface BgpController { | ... | @@ -128,11 +114,4 @@ public interface BgpController { |
| 128 | * @return node listener | 114 | * @return node listener |
| 129 | */ | 115 | */ |
| 130 | Set<BgpNodeListener> listener(); | 116 | Set<BgpNodeListener> listener(); |
| 131 | - | ||
| 132 | - /** | ||
| 133 | - * Return BGP link listener. | ||
| 134 | - * | ||
| 135 | - * @return link listener | ||
| 136 | - */ | ||
| 137 | - Set<BgpLinkListener> linkListener(); | ||
| 138 | } | 117 | } | ... | ... |
| ... | @@ -46,20 +46,17 @@ public final class BgpDpid { | ... | @@ -46,20 +46,17 @@ public final class BgpDpid { |
| 46 | this.stringBuilder = new StringBuilder("bgpls://"); | 46 | this.stringBuilder = new StringBuilder("bgpls://"); |
| 47 | 47 | ||
| 48 | if (linkNlri.getRouteDistinguisher() != null) { | 48 | if (linkNlri.getRouteDistinguisher() != null) { |
| 49 | - this.stringBuilder.append(Long.toString(linkNlri.getRouteDistinguisher().getRouteDistinguisher())) | 49 | + this.stringBuilder.append(linkNlri.getRouteDistinguisher().getRouteDistinguisher()).append(':'); |
| 50 | - .append(':'); | ||
| 51 | } | 50 | } |
| 52 | 51 | ||
| 53 | try { | 52 | try { |
| 54 | - this.stringBuilder.append(linkNlri.getProtocolId().toString()) | 53 | + this.stringBuilder.append(linkNlri.getProtocolId()).append(':').append(linkNlri.getIdentifier()) |
| 55 | - .append(':') | ||
| 56 | - .append(Long.toString(linkNlri.getIdentifier())) | ||
| 57 | .append('/'); | 54 | .append('/'); |
| 58 | 55 | ||
| 59 | if (nodeDescriptorType == NODE_DESCRIPTOR_LOCAL) { | 56 | if (nodeDescriptorType == NODE_DESCRIPTOR_LOCAL) { |
| 60 | - add(linkNlri.localNodeDescriptors().toString()); | 57 | + add(linkNlri.localNodeDescriptors()); |
| 61 | } else if (nodeDescriptorType == NODE_DESCRIPTOR_REMOTE) { | 58 | } else if (nodeDescriptorType == NODE_DESCRIPTOR_REMOTE) { |
| 62 | - add(linkNlri.remoteNodeDescriptors().toString()); | 59 | + add(linkNlri.remoteNodeDescriptors()); |
| 63 | } | 60 | } |
| 64 | } catch (BgpParseException e) { | 61 | } catch (BgpParseException e) { |
| 65 | log.info("Exception BgpId string: " + e.toString()); | 62 | log.info("Exception BgpId string: " + e.toString()); |
| ... | @@ -76,18 +73,15 @@ public final class BgpDpid { | ... | @@ -76,18 +73,15 @@ public final class BgpDpid { |
| 76 | this.stringBuilder = new StringBuilder("bgpls://"); | 73 | this.stringBuilder = new StringBuilder("bgpls://"); |
| 77 | 74 | ||
| 78 | if (nodeNlri.getRouteDistinguisher() != null) { | 75 | if (nodeNlri.getRouteDistinguisher() != null) { |
| 79 | - this.stringBuilder.append(Long.toString(nodeNlri.getRouteDistinguisher().getRouteDistinguisher())) | 76 | + this.stringBuilder.append(nodeNlri.getRouteDistinguisher().getRouteDistinguisher()).append(':'); |
| 80 | - .append(':'); | ||
| 81 | } | 77 | } |
| 82 | 78 | ||
| 83 | try { | 79 | try { |
| 84 | 80 | ||
| 85 | - this.stringBuilder.append(nodeNlri.getProtocolId().toString()) | 81 | + this.stringBuilder.append(nodeNlri.getProtocolId()).append(':').append(nodeNlri.getIdentifier()) |
| 86 | - .append(':') | ||
| 87 | - .append(Long.toString(nodeNlri.getIdentifier())) | ||
| 88 | .append('/'); | 82 | .append('/'); |
| 89 | 83 | ||
| 90 | - add(nodeNlri.getLocalNodeDescriptors().toString()); | 84 | + add(nodeNlri.getLocalNodeDescriptors()); |
| 91 | 85 | ||
| 92 | } catch (BgpParseException e) { | 86 | } catch (BgpParseException e) { |
| 93 | log.info("Exception node string: " + e.toString()); | 87 | log.info("Exception node string: " + e.toString()); | ... | ... |
| ... | @@ -30,7 +30,6 @@ import org.onosproject.bgp.controller.BgpCfg; | ... | @@ -30,7 +30,6 @@ import org.onosproject.bgp.controller.BgpCfg; |
| 30 | import org.onosproject.bgp.controller.BgpController; | 30 | import org.onosproject.bgp.controller.BgpController; |
| 31 | import org.onosproject.bgp.controller.BgpId; | 31 | import org.onosproject.bgp.controller.BgpId; |
| 32 | import org.onosproject.bgp.controller.BgpPeer; | 32 | import org.onosproject.bgp.controller.BgpPeer; |
| 33 | -import org.onosproject.bgp.controller.BgpLinkListener; | ||
| 34 | import org.onosproject.bgp.controller.BgpNodeListener; | 33 | import org.onosproject.bgp.controller.BgpNodeListener; |
| 35 | import org.onosproject.bgp.controller.BgpPeerManager; | 34 | import org.onosproject.bgp.controller.BgpPeerManager; |
| 36 | import org.onosproject.bgpio.exceptions.BgpParseException; | 35 | import org.onosproject.bgpio.exceptions.BgpParseException; |
| ... | @@ -49,7 +48,6 @@ public class BgpControllerImpl implements BgpController { | ... | @@ -49,7 +48,6 @@ public class BgpControllerImpl implements BgpController { |
| 49 | protected BgpPeerManagerImpl peerManager = new BgpPeerManagerImpl(); | 48 | protected BgpPeerManagerImpl peerManager = new BgpPeerManagerImpl(); |
| 50 | 49 | ||
| 51 | protected Set<BgpNodeListener> bgpNodeListener = new CopyOnWriteArraySet<>(); | 50 | protected Set<BgpNodeListener> bgpNodeListener = new CopyOnWriteArraySet<>(); |
| 52 | - protected Set<BgpLinkListener> bgpLinkListener = new CopyOnWriteArraySet<>(); | ||
| 53 | 51 | ||
| 54 | final Controller ctrl = new Controller(this); | 52 | final Controller ctrl = new Controller(this); |
| 55 | 53 | ||
| ... | @@ -95,21 +93,6 @@ public class BgpControllerImpl implements BgpController { | ... | @@ -95,21 +93,6 @@ public class BgpControllerImpl implements BgpController { |
| 95 | } | 93 | } |
| 96 | 94 | ||
| 97 | @Override | 95 | @Override |
| 98 | - public void addLinkListener(BgpLinkListener listener) { | ||
| 99 | - this.bgpLinkListener.add(listener); | ||
| 100 | - } | ||
| 101 | - | ||
| 102 | - @Override | ||
| 103 | - public void removeLinkListener(BgpLinkListener listener) { | ||
| 104 | - this.bgpLinkListener.remove(listener); | ||
| 105 | - } | ||
| 106 | - | ||
| 107 | - @Override | ||
| 108 | - public Set<BgpLinkListener> linkListener() { | ||
| 109 | - return bgpLinkListener; | ||
| 110 | - } | ||
| 111 | - | ||
| 112 | - @Override | ||
| 113 | public void writeMsg(BgpId bgpId, BgpMessage msg) { | 96 | public void writeMsg(BgpId bgpId, BgpMessage msg) { |
| 114 | this.getPeer(bgpId).sendMessage(msg); | 97 | this.getPeer(bgpId).sendMessage(msg); |
| 115 | } | 98 | } | ... | ... |
| ... | @@ -13,14 +13,9 @@ | ... | @@ -13,14 +13,9 @@ |
| 13 | 13 | ||
| 14 | package org.onosproject.provider.bgp.topology.impl; | 14 | package org.onosproject.provider.bgp.topology.impl; |
| 15 | 15 | ||
| 16 | -import static com.google.common.base.Preconditions.checkNotNull; | ||
| 17 | import static org.onosproject.bgp.controller.BgpDpid.uri; | 16 | import static org.onosproject.bgp.controller.BgpDpid.uri; |
| 18 | import static org.onosproject.net.DeviceId.deviceId; | 17 | import static org.onosproject.net.DeviceId.deviceId; |
| 19 | 18 | ||
| 20 | -import java.util.ArrayList; | ||
| 21 | -import java.util.HashMap; | ||
| 22 | -import java.util.List; | ||
| 23 | - | ||
| 24 | import org.onlab.packet.ChassisId; | 19 | import org.onlab.packet.ChassisId; |
| 25 | import org.apache.felix.scr.annotations.Activate; | 20 | import org.apache.felix.scr.annotations.Activate; |
| 26 | import org.apache.felix.scr.annotations.Component; | 21 | import org.apache.felix.scr.annotations.Component; |
| ... | @@ -29,27 +24,16 @@ import org.apache.felix.scr.annotations.Reference; | ... | @@ -29,27 +24,16 @@ import org.apache.felix.scr.annotations.Reference; |
| 29 | import org.apache.felix.scr.annotations.ReferenceCardinality; | 24 | import org.apache.felix.scr.annotations.ReferenceCardinality; |
| 30 | import org.onosproject.bgp.controller.BgpController; | 25 | import org.onosproject.bgp.controller.BgpController; |
| 31 | import org.onosproject.bgp.controller.BgpDpid; | 26 | import org.onosproject.bgp.controller.BgpDpid; |
| 32 | -import org.onosproject.bgp.controller.BgpLinkListener; | ||
| 33 | import org.onosproject.bgp.controller.BgpNodeListener; | 27 | import org.onosproject.bgp.controller.BgpNodeListener; |
| 34 | -import org.onosproject.bgpio.protocol.linkstate.BgpLinkLsNlriVer4; | ||
| 35 | import org.onosproject.bgpio.protocol.linkstate.BgpNodeLSNlriVer4; | 28 | import org.onosproject.bgpio.protocol.linkstate.BgpNodeLSNlriVer4; |
| 36 | -import org.onosproject.net.ConnectPoint; | ||
| 37 | import org.onosproject.net.Device; | 29 | import org.onosproject.net.Device; |
| 38 | import org.onosproject.net.DeviceId; | 30 | import org.onosproject.net.DeviceId; |
| 39 | -import org.onosproject.net.Link; | ||
| 40 | import org.onosproject.net.MastershipRole; | 31 | import org.onosproject.net.MastershipRole; |
| 41 | import org.onosproject.net.device.DefaultDeviceDescription; | 32 | import org.onosproject.net.device.DefaultDeviceDescription; |
| 42 | -import org.onosproject.net.device.DefaultPortDescription; | ||
| 43 | import org.onosproject.net.device.DeviceDescription; | 33 | import org.onosproject.net.device.DeviceDescription; |
| 44 | import org.onosproject.net.device.DeviceProvider; | 34 | import org.onosproject.net.device.DeviceProvider; |
| 45 | import org.onosproject.net.device.DeviceProviderRegistry; | 35 | import org.onosproject.net.device.DeviceProviderRegistry; |
| 46 | import org.onosproject.net.device.DeviceProviderService; | 36 | import org.onosproject.net.device.DeviceProviderService; |
| 47 | -import org.onosproject.net.device.PortDescription; | ||
| 48 | -import org.onosproject.net.link.DefaultLinkDescription; | ||
| 49 | -import org.onosproject.net.link.LinkDescription; | ||
| 50 | -import org.onosproject.net.link.LinkProvider; | ||
| 51 | -import org.onosproject.net.link.LinkProviderRegistry; | ||
| 52 | -import org.onosproject.net.link.LinkProviderService; | ||
| 53 | import org.onosproject.net.provider.AbstractProvider; | 37 | import org.onosproject.net.provider.AbstractProvider; |
| 54 | import org.onosproject.net.provider.ProviderId; | 38 | import org.onosproject.net.provider.ProviderId; |
| 55 | import org.slf4j.Logger; | 39 | import org.slf4j.Logger; |
| ... | @@ -59,7 +43,7 @@ import org.slf4j.LoggerFactory; | ... | @@ -59,7 +43,7 @@ import org.slf4j.LoggerFactory; |
| 59 | * Provider which uses an BGP controller to detect network infrastructure topology. | 43 | * Provider which uses an BGP controller to detect network infrastructure topology. |
| 60 | */ | 44 | */ |
| 61 | @Component(immediate = true) | 45 | @Component(immediate = true) |
| 62 | -public class BgpTopologyProvider extends AbstractProvider implements LinkProvider, DeviceProvider { | 46 | +public class BgpTopologyProvider extends AbstractProvider implements DeviceProvider { |
| 63 | 47 | ||
| 64 | public BgpTopologyProvider() { | 48 | public BgpTopologyProvider() { |
| 65 | super(new ProviderId("bgp", "org.onosproject.provider.bgp")); | 49 | super(new ProviderId("bgp", "org.onosproject.provider.bgp")); |
| ... | @@ -68,86 +52,31 @@ public class BgpTopologyProvider extends AbstractProvider implements LinkProvide | ... | @@ -68,86 +52,31 @@ public class BgpTopologyProvider extends AbstractProvider implements LinkProvide |
| 68 | private static final Logger log = LoggerFactory.getLogger(BgpTopologyProvider.class); | 52 | private static final Logger log = LoggerFactory.getLogger(BgpTopologyProvider.class); |
| 69 | 53 | ||
| 70 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | 54 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
| 71 | - protected LinkProviderRegistry linkProviderRegistry; | ||
| 72 | - | ||
| 73 | - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | ||
| 74 | protected DeviceProviderRegistry deviceProviderRegistry; | 55 | protected DeviceProviderRegistry deviceProviderRegistry; |
| 75 | 56 | ||
| 76 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | 57 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
| 77 | protected BgpController controller; | 58 | protected BgpController controller; |
| 78 | 59 | ||
| 79 | private DeviceProviderService deviceProviderService; | 60 | private DeviceProviderService deviceProviderService; |
| 80 | - private LinkProviderService linkProviderService; | ||
| 81 | 61 | ||
| 82 | - private HashMap<String, List<PortDescription>> portMap = new HashMap<>(); | ||
| 83 | private InternalBgpProvider listener = new InternalBgpProvider(); | 62 | private InternalBgpProvider listener = new InternalBgpProvider(); |
| 84 | private static final String UNKNOWN = "unknown"; | 63 | private static final String UNKNOWN = "unknown"; |
| 85 | 64 | ||
| 86 | @Activate | 65 | @Activate |
| 87 | public void activate() { | 66 | public void activate() { |
| 88 | - linkProviderService = linkProviderRegistry.register(this); | ||
| 89 | deviceProviderService = deviceProviderRegistry.register(this); | 67 | deviceProviderService = deviceProviderRegistry.register(this); |
| 90 | controller.addListener(listener); | 68 | controller.addListener(listener); |
| 91 | - controller.addLinkListener(listener); | ||
| 92 | } | 69 | } |
| 93 | 70 | ||
| 94 | @Deactivate | 71 | @Deactivate |
| 95 | public void deactivate() { | 72 | public void deactivate() { |
| 96 | - linkProviderRegistry.unregister(this); | ||
| 97 | - linkProviderService = null; | ||
| 98 | controller.removeListener(listener); | 73 | controller.removeListener(listener); |
| 99 | - controller.removeLinkListener(listener); | ||
| 100 | - } | ||
| 101 | - | ||
| 102 | - private List<PortDescription> buildPortDescriptions(String linkUri) { | ||
| 103 | - | ||
| 104 | - List<PortDescription> portList; | ||
| 105 | - | ||
| 106 | - if (portMap.containsKey(linkUri)) { | ||
| 107 | - portList = portMap.get(linkUri); | ||
| 108 | - } else { | ||
| 109 | - portList = new ArrayList<>(); | ||
| 110 | - } | ||
| 111 | - | ||
| 112 | - // TODO: port description | ||
| 113 | - portList.add(new DefaultPortDescription(null, true)); | ||
| 114 | - | ||
| 115 | - portMap.put(linkUri, portList); | ||
| 116 | - return portList; | ||
| 117 | - } | ||
| 118 | - | ||
| 119 | - /** | ||
| 120 | - * Build a link description from a bgp link. | ||
| 121 | - * | ||
| 122 | - * @param bgpLink bgp link | ||
| 123 | - * @return linkDescription link description | ||
| 124 | - */ | ||
| 125 | - private LinkDescription buildLinkDescription(BgpLinkLsNlriVer4 bgpLink) { | ||
| 126 | - LinkDescription ld = null; | ||
| 127 | - checkNotNull(bgpLink); | ||
| 128 | - | ||
| 129 | - BgpDpid localNodeUri = new BgpDpid(bgpLink, BgpDpid.NODE_DESCRIPTOR_LOCAL); | ||
| 130 | - DeviceId srcDeviceID = deviceId(uri(localNodeUri.toString())); | ||
| 131 | - | ||
| 132 | - BgpDpid remoteNodeUri = new BgpDpid(bgpLink, BgpDpid.NODE_DESCRIPTOR_REMOTE); | ||
| 133 | - DeviceId dstDeviceID = deviceId(uri(remoteNodeUri.toString())); | ||
| 134 | - | ||
| 135 | - deviceProviderService.updatePorts(srcDeviceID, buildPortDescriptions(localNodeUri.toString())); | ||
| 136 | - | ||
| 137 | - deviceProviderService.updatePorts(dstDeviceID, buildPortDescriptions(remoteNodeUri.toString())); | ||
| 138 | - | ||
| 139 | - ConnectPoint src = new ConnectPoint(srcDeviceID, null); | ||
| 140 | - | ||
| 141 | - ConnectPoint dst = new ConnectPoint(dstDeviceID, null); | ||
| 142 | - | ||
| 143 | - ld = new DefaultLinkDescription(src, dst, Link.Type.INDIRECT); | ||
| 144 | - return ld; | ||
| 145 | } | 74 | } |
| 146 | 75 | ||
| 147 | /* | 76 | /* |
| 148 | * Implements device and link update. | 77 | * Implements device and link update. |
| 149 | */ | 78 | */ |
| 150 | - private class InternalBgpProvider implements BgpNodeListener, BgpLinkListener { | 79 | + private class InternalBgpProvider implements BgpNodeListener { |
| 151 | 80 | ||
| 152 | @Override | 81 | @Override |
| 153 | public void addNode(BgpNodeLSNlriVer4 nodeNlri) { | 82 | public void addNode(BgpNodeLSNlriVer4 nodeNlri) { |
| ... | @@ -177,40 +106,6 @@ public class BgpTopologyProvider extends AbstractProvider implements LinkProvide | ... | @@ -177,40 +106,6 @@ public class BgpTopologyProvider extends AbstractProvider implements LinkProvide |
| 177 | BgpDpid nodeUri = new BgpDpid(nodeNlri); | 106 | BgpDpid nodeUri = new BgpDpid(nodeNlri); |
| 178 | deviceProviderService.deviceDisconnected(deviceId(uri(nodeUri.toString()))); | 107 | deviceProviderService.deviceDisconnected(deviceId(uri(nodeUri.toString()))); |
| 179 | } | 108 | } |
| 180 | - | ||
| 181 | - @Override | ||
| 182 | - public void addLink(BgpLinkLsNlriVer4 linkNlri) { | ||
| 183 | - log.debug("Add link {}", linkNlri.toString()); | ||
| 184 | - | ||
| 185 | - if (linkProviderService == null) { | ||
| 186 | - return; | ||
| 187 | - } | ||
| 188 | - | ||
| 189 | - LinkDescription ld = buildLinkDescription(linkNlri); | ||
| 190 | - if (ld == null) { | ||
| 191 | - log.error("Invalid link info."); | ||
| 192 | - return; | ||
| 193 | - } | ||
| 194 | - | ||
| 195 | - linkProviderService.linkDetected(ld); | ||
| 196 | - } | ||
| 197 | - | ||
| 198 | - @Override | ||
| 199 | - public void deleteLink(BgpLinkLsNlriVer4 linkNlri) { | ||
| 200 | - log.debug("Delete link {}", linkNlri.toString()); | ||
| 201 | - | ||
| 202 | - if (linkProviderService == null) { | ||
| 203 | - return; | ||
| 204 | - } | ||
| 205 | - | ||
| 206 | - LinkDescription ld = buildLinkDescription(linkNlri); | ||
| 207 | - if (ld == null) { | ||
| 208 | - log.error("Invalid link info."); | ||
| 209 | - return; | ||
| 210 | - } | ||
| 211 | - | ||
| 212 | - linkProviderService.linkVanished(ld); | ||
| 213 | - } | ||
| 214 | } | 109 | } |
| 215 | 110 | ||
| 216 | @Override | 111 | @Override | ... | ... |
| ... | @@ -31,22 +31,17 @@ import org.onosproject.bgp.controller.BgpCfg; | ... | @@ -31,22 +31,17 @@ import org.onosproject.bgp.controller.BgpCfg; |
| 31 | import org.onosproject.bgp.controller.BgpController; | 31 | import org.onosproject.bgp.controller.BgpController; |
| 32 | import org.onosproject.bgp.controller.BgpId; | 32 | import org.onosproject.bgp.controller.BgpId; |
| 33 | import org.onosproject.bgp.controller.BgpPeer; | 33 | import org.onosproject.bgp.controller.BgpPeer; |
| 34 | -import org.onosproject.bgp.controller.BgpLinkListener; | ||
| 35 | import org.onosproject.bgp.controller.BgpNodeListener; | 34 | import org.onosproject.bgp.controller.BgpNodeListener; |
| 36 | import org.onosproject.bgp.controller.BgpPeerManager; | 35 | import org.onosproject.bgp.controller.BgpPeerManager; |
| 37 | import org.onosproject.bgpio.exceptions.BgpParseException; | 36 | import org.onosproject.bgpio.exceptions.BgpParseException; |
| 38 | import org.onosproject.bgpio.protocol.BgpMessage; | 37 | import org.onosproject.bgpio.protocol.BgpMessage; |
| 39 | -import org.onosproject.bgpio.protocol.linkstate.BgpLinkLSIdentifier; | ||
| 40 | import org.onosproject.bgpio.protocol.linkstate.BgpNodeLSIdentifier; | 38 | import org.onosproject.bgpio.protocol.linkstate.BgpNodeLSIdentifier; |
| 41 | import org.onosproject.bgpio.protocol.linkstate.BgpNodeLSNlriVer4; | 39 | import org.onosproject.bgpio.protocol.linkstate.BgpNodeLSNlriVer4; |
| 42 | -import org.onosproject.bgpio.protocol.linkstate.BgpLinkLsNlriVer4; | ||
| 43 | import org.onosproject.bgpio.protocol.linkstate.NodeDescriptors; | 40 | import org.onosproject.bgpio.protocol.linkstate.NodeDescriptors; |
| 44 | import org.onosproject.bgpio.types.AutonomousSystemTlv; | 41 | import org.onosproject.bgpio.types.AutonomousSystemTlv; |
| 45 | -import org.onosproject.bgpio.types.LinkLocalRemoteIdentifiersTlv; | ||
| 46 | import org.onosproject.bgpio.types.BgpValueType; | 42 | import org.onosproject.bgpio.types.BgpValueType; |
| 47 | import org.onosproject.bgpio.types.RouteDistinguisher; | 43 | import org.onosproject.bgpio.types.RouteDistinguisher; |
| 48 | import org.onosproject.bgpio.util.Constants; | 44 | import org.onosproject.bgpio.util.Constants; |
| 49 | -import org.onosproject.net.ConnectPoint; | ||
| 50 | import org.onosproject.net.DeviceId; | 45 | import org.onosproject.net.DeviceId; |
| 51 | import org.onosproject.net.MastershipRole; | 46 | import org.onosproject.net.MastershipRole; |
| 52 | import org.onosproject.net.device.DeviceDescription; | 47 | import org.onosproject.net.device.DeviceDescription; |
| ... | @@ -55,10 +50,6 @@ import org.onosproject.net.device.DeviceProviderRegistry; | ... | @@ -55,10 +50,6 @@ import org.onosproject.net.device.DeviceProviderRegistry; |
| 55 | import org.onosproject.net.device.DeviceProviderService; | 50 | import org.onosproject.net.device.DeviceProviderService; |
| 56 | import org.onosproject.net.device.PortDescription; | 51 | import org.onosproject.net.device.PortDescription; |
| 57 | import org.onosproject.net.device.PortStatistics; | 52 | import org.onosproject.net.device.PortStatistics; |
| 58 | -import org.onosproject.net.link.LinkDescription; | ||
| 59 | -import org.onosproject.net.link.LinkProvider; | ||
| 60 | -import org.onosproject.net.link.LinkProviderRegistry; | ||
| 61 | -import org.onosproject.net.link.LinkProviderService; | ||
| 62 | import org.onosproject.net.provider.ProviderId; | 53 | import org.onosproject.net.provider.ProviderId; |
| 63 | 54 | ||
| 64 | public class BgpTopologyProviderTest { | 55 | public class BgpTopologyProviderTest { |
| ... | @@ -74,17 +65,14 @@ public class BgpTopologyProviderTest { | ... | @@ -74,17 +65,14 @@ public class BgpTopologyProviderTest { |
| 74 | + "%20subtlvs=[autonomoussystemtlv%7btype=512,%20length=4,%20asnum=100%7d]%7d"); | 65 | + "%20subtlvs=[autonomoussystemtlv%7btype=512,%20length=4,%20asnum=100%7d]%7d"); |
| 75 | private final BgpTopologyProvider provider = new BgpTopologyProvider(); | 66 | private final BgpTopologyProvider provider = new BgpTopologyProvider(); |
| 76 | private final TestDeviceRegistry nodeRegistry = new TestDeviceRegistry(); | 67 | private final TestDeviceRegistry nodeRegistry = new TestDeviceRegistry(); |
| 77 | - private final TestLinkRegistry linkRegistry = new TestLinkRegistry(); | ||
| 78 | private final TestController controller = new TestController(); | 68 | private final TestController controller = new TestController(); |
| 79 | 69 | ||
| 80 | @Before | 70 | @Before |
| 81 | public void startUp() { | 71 | public void startUp() { |
| 82 | provider.deviceProviderRegistry = nodeRegistry; | 72 | provider.deviceProviderRegistry = nodeRegistry; |
| 83 | - provider.linkProviderRegistry = linkRegistry; | ||
| 84 | provider.controller = controller; | 73 | provider.controller = controller; |
| 85 | provider.activate(); | 74 | provider.activate(); |
| 86 | assertNotNull("provider should be registered", nodeRegistry.provider); | 75 | assertNotNull("provider should be registered", nodeRegistry.provider); |
| 87 | - assertNotNull("provider should be registered", linkRegistry.provider); | ||
| 88 | assertNotNull("listener should be registered", controller.nodeListener); | 76 | assertNotNull("listener should be registered", controller.nodeListener); |
| 89 | } | 77 | } |
| 90 | 78 | ||
| ... | @@ -94,7 +82,6 @@ public class BgpTopologyProviderTest { | ... | @@ -94,7 +82,6 @@ public class BgpTopologyProviderTest { |
| 94 | assertNull("listener should be removed", controller.nodeListener); | 82 | assertNull("listener should be removed", controller.nodeListener); |
| 95 | provider.controller = null; | 83 | provider.controller = null; |
| 96 | provider.deviceProviderRegistry = null; | 84 | provider.deviceProviderRegistry = null; |
| 97 | - provider.linkProviderRegistry = null; | ||
| 98 | } | 85 | } |
| 99 | 86 | ||
| 100 | /* Class implement device test registry */ | 87 | /* Class implement device test registry */ |
| ... | @@ -165,69 +152,9 @@ public class BgpTopologyProviderTest { | ... | @@ -165,69 +152,9 @@ public class BgpTopologyProviderTest { |
| 165 | } | 152 | } |
| 166 | } | 153 | } |
| 167 | 154 | ||
| 168 | - /* class implement link test registery */ | ||
| 169 | - private class TestLinkRegistry implements LinkProviderRegistry { | ||
| 170 | - LinkProvider provider; | ||
| 171 | - | ||
| 172 | - Set<DeviceId> connected = new HashSet<>(); | ||
| 173 | - | ||
| 174 | - @Override | ||
| 175 | - public LinkProviderService register(LinkProvider provider) { | ||
| 176 | - this.provider = provider; | ||
| 177 | - return new TestProviderService(); | ||
| 178 | - } | ||
| 179 | - | ||
| 180 | - @Override | ||
| 181 | - public void unregister(LinkProvider provider) { | ||
| 182 | - } | ||
| 183 | - | ||
| 184 | - @Override | ||
| 185 | - public Set<ProviderId> getProviders() { | ||
| 186 | - return null; | ||
| 187 | - } | ||
| 188 | - | ||
| 189 | - private class TestProviderService implements LinkProviderService { | ||
| 190 | - | ||
| 191 | - @Override | ||
| 192 | - public LinkProvider provider() { | ||
| 193 | - // TODO Auto-generated method stub | ||
| 194 | - return null; | ||
| 195 | - } | ||
| 196 | - | ||
| 197 | - @Override | ||
| 198 | - public void linkDetected(LinkDescription linkDescription) { | ||
| 199 | - if ((linkDescription.src().deviceId().equals(DID3)) | ||
| 200 | - && (linkDescription.dst().deviceId().equals(DID3))) { | ||
| 201 | - connected.add(linkDescription.src().deviceId()); | ||
| 202 | - } | ||
| 203 | - } | ||
| 204 | - | ||
| 205 | - @Override | ||
| 206 | - public void linkVanished(LinkDescription linkDescription) { | ||
| 207 | - if ((linkDescription.src().deviceId().equals(DID3)) | ||
| 208 | - && (linkDescription.dst().deviceId().equals(DID3))) { | ||
| 209 | - connected.remove(linkDescription.src().deviceId()); | ||
| 210 | - } | ||
| 211 | - } | ||
| 212 | - | ||
| 213 | - @Override | ||
| 214 | - public void linksVanished(ConnectPoint connectPoint) { | ||
| 215 | - // TODO Auto-generated method stub | ||
| 216 | - | ||
| 217 | - } | ||
| 218 | - | ||
| 219 | - @Override | ||
| 220 | - public void linksVanished(DeviceId deviceId) { | ||
| 221 | - connected.remove(deviceId); | ||
| 222 | - } | ||
| 223 | - | ||
| 224 | - } | ||
| 225 | - } | ||
| 226 | - | ||
| 227 | /* class implement test controller */ | 155 | /* class implement test controller */ |
| 228 | private class TestController implements BgpController { | 156 | private class TestController implements BgpController { |
| 229 | protected Set<BgpNodeListener> nodeListener = new CopyOnWriteArraySet<>(); | 157 | protected Set<BgpNodeListener> nodeListener = new CopyOnWriteArraySet<>(); |
| 230 | - protected Set<BgpLinkListener> linkListener = new CopyOnWriteArraySet<>(); | ||
| 231 | 158 | ||
| 232 | @Override | 159 | @Override |
| 233 | public void addListener(BgpNodeListener nodeListener) { | 160 | public void addListener(BgpNodeListener nodeListener) { |
| ... | @@ -240,16 +167,6 @@ public class BgpTopologyProviderTest { | ... | @@ -240,16 +167,6 @@ public class BgpTopologyProviderTest { |
| 240 | } | 167 | } |
| 241 | 168 | ||
| 242 | @Override | 169 | @Override |
| 243 | - public void addLinkListener(BgpLinkListener linkListener) { | ||
| 244 | - this.linkListener.add(linkListener); | ||
| 245 | - } | ||
| 246 | - | ||
| 247 | - @Override | ||
| 248 | - public void removeLinkListener(BgpLinkListener linkListener) { | ||
| 249 | - this.linkListener = null; | ||
| 250 | - } | ||
| 251 | - | ||
| 252 | - @Override | ||
| 253 | public Iterable<BgpPeer> getPeers() { | 170 | public Iterable<BgpPeer> getPeers() { |
| 254 | // TODO Auto-generated method stub | 171 | // TODO Auto-generated method stub |
| 255 | return null; | 172 | return null; |
| ... | @@ -309,12 +226,6 @@ public class BgpTopologyProviderTest { | ... | @@ -309,12 +226,6 @@ public class BgpTopologyProviderTest { |
| 309 | // TODO Auto-generated method stub | 226 | // TODO Auto-generated method stub |
| 310 | return null; | 227 | return null; |
| 311 | } | 228 | } |
| 312 | - | ||
| 313 | - @Override | ||
| 314 | - public Set<BgpLinkListener> linkListener() { | ||
| 315 | - // TODO Auto-generated method stub | ||
| 316 | - return null; | ||
| 317 | - } | ||
| 318 | } | 229 | } |
| 319 | 230 | ||
| 320 | /* Validate node is added to the device validating URI, RIB should get updated properly */ | 231 | /* Validate node is added to the device validating URI, RIB should get updated properly */ |
| ... | @@ -387,37 +298,4 @@ public class BgpTopologyProviderTest { | ... | @@ -387,37 +298,4 @@ public class BgpTopologyProviderTest { |
| 387 | assertTrue("Failed to add device", (nodeRegistry.connected.size() == 0)); | 298 | assertTrue("Failed to add device", (nodeRegistry.connected.size() == 0)); |
| 388 | } | 299 | } |
| 389 | } | 300 | } |
| 390 | - | ||
| 391 | - /* Validate link is added to the device validating URI, RIB should get updated properly */ | ||
| 392 | - @Test | ||
| 393 | - public void bgpTopologyProviderTestAddLink1() { | ||
| 394 | - | ||
| 395 | - NodeDescriptors localNodeDescriptors; | ||
| 396 | - NodeDescriptors remoteNodeDescriptors; | ||
| 397 | - LinkedList<BgpValueType> subTlvs; | ||
| 398 | - LinkedList<BgpValueType> linkDescriptor = new LinkedList<>(); | ||
| 399 | - BgpValueType tlvLocalRemoteId; | ||
| 400 | - short deslength = AutonomousSystemTlv.LENGTH; | ||
| 401 | - short desType = AutonomousSystemTlv.TYPE; | ||
| 402 | - | ||
| 403 | - BgpValueType tlv = new AutonomousSystemTlv(100); | ||
| 404 | - subTlvs = new LinkedList<>(); | ||
| 405 | - subTlvs.add(tlv); | ||
| 406 | - | ||
| 407 | - localNodeDescriptors = new NodeDescriptors(subTlvs, deslength, desType); | ||
| 408 | - remoteNodeDescriptors = new NodeDescriptors(subTlvs, deslength, desType); | ||
| 409 | - tlvLocalRemoteId = new LinkLocalRemoteIdentifiersTlv(1, 2); | ||
| 410 | - linkDescriptor.add(tlvLocalRemoteId); | ||
| 411 | - | ||
| 412 | - BgpLinkLSIdentifier linkLSIdentifier = new BgpLinkLSIdentifier(localNodeDescriptors, remoteNodeDescriptors, | ||
| 413 | - linkDescriptor); | ||
| 414 | - BgpLinkLsNlriVer4 linkNlri = new BgpLinkLsNlriVer4((byte) Constants.DIRECT, 0, linkLSIdentifier, null, false); | ||
| 415 | - | ||
| 416 | - for (BgpLinkListener l : controller.linkListener) { | ||
| 417 | - l.addLink(linkNlri); | ||
| 418 | - assertTrue(linkRegistry.connected.size() == 1); | ||
| 419 | - l.deleteLink(linkNlri); | ||
| 420 | - assertTrue(linkRegistry.connected.size() == 0); | ||
| 421 | - } | ||
| 422 | - } | ||
| 423 | } | 301 | } | ... | ... |
-
Please register or login to post a comment