Committed by
Gerrit Code Review
Add support to CordMcast for sending multicast sink ports to remote cluster.
Change-Id: Ib915c68218033e1dcfa6f738a629c2d1d8442261
Showing
3 changed files
with
75 additions
and
98 deletions
... | @@ -20,11 +20,9 @@ import com.fasterxml.jackson.databind.JsonNode; | ... | @@ -20,11 +20,9 @@ import com.fasterxml.jackson.databind.JsonNode; |
20 | import com.fasterxml.jackson.databind.node.ObjectNode; | 20 | import com.fasterxml.jackson.databind.node.ObjectNode; |
21 | import com.google.common.collect.Iterators; | 21 | import com.google.common.collect.Iterators; |
22 | import com.google.common.collect.Maps; | 22 | import com.google.common.collect.Maps; |
23 | -import org.apache.commons.lang.StringUtils; | ||
24 | import org.onlab.packet.MacAddress; | 23 | import org.onlab.packet.MacAddress; |
25 | import org.onosproject.net.ConnectPoint; | 24 | import org.onosproject.net.ConnectPoint; |
26 | import org.onosproject.net.DeviceId; | 25 | import org.onosproject.net.DeviceId; |
27 | -import org.onosproject.net.PortNumber; | ||
28 | import org.onosproject.net.config.Config; | 26 | import org.onosproject.net.config.Config; |
29 | 27 | ||
30 | import java.util.Map; | 28 | import java.util.Map; |
... | @@ -49,7 +47,7 @@ public class AccessAgentConfig extends Config<DeviceId> { | ... | @@ -49,7 +47,7 @@ public class AccessAgentConfig extends Config<DeviceId> { |
49 | return hasOnlyFields(OLTS, AGENT_MAC, VTN_LOCATION) && | 47 | return hasOnlyFields(OLTS, AGENT_MAC, VTN_LOCATION) && |
50 | isMacAddress(AGENT_MAC, MANDATORY) && | 48 | isMacAddress(AGENT_MAC, MANDATORY) && |
51 | isConnectPoint(VTN_LOCATION, OPTIONAL) && | 49 | isConnectPoint(VTN_LOCATION, OPTIONAL) && |
52 | - isValidOlts(); | 50 | + areOltsValid(); |
53 | } | 51 | } |
54 | 52 | ||
55 | /** | 53 | /** |
... | @@ -61,7 +59,7 @@ public class AccessAgentConfig extends Config<DeviceId> { | ... | @@ -61,7 +59,7 @@ public class AccessAgentConfig extends Config<DeviceId> { |
61 | JsonNode olts = node.get(OLTS); | 59 | JsonNode olts = node.get(OLTS); |
62 | Map<ConnectPoint, MacAddress> oltMacInfo = Maps.newHashMap(); | 60 | Map<ConnectPoint, MacAddress> oltMacInfo = Maps.newHashMap(); |
63 | olts.fields().forEachRemaining(item -> oltMacInfo.put( | 61 | olts.fields().forEachRemaining(item -> oltMacInfo.put( |
64 | - new ConnectPoint(subject(), PortNumber.fromString(item.getKey())), | 62 | + ConnectPoint.deviceConnectPoint(item.getKey()), |
65 | MacAddress.valueOf(item.getValue().asText()))); | 63 | MacAddress.valueOf(item.getValue().asText()))); |
66 | 64 | ||
67 | MacAddress agentMac = MacAddress.valueOf(node.path(AGENT_MAC).asText()); | 65 | MacAddress agentMac = MacAddress.valueOf(node.path(AGENT_MAC).asText()); |
... | @@ -77,12 +75,13 @@ public class AccessAgentConfig extends Config<DeviceId> { | ... | @@ -77,12 +75,13 @@ public class AccessAgentConfig extends Config<DeviceId> { |
77 | return new AccessAgentData(subject(), oltMacInfo, agentMac, vtnLocation); | 75 | return new AccessAgentData(subject(), oltMacInfo, agentMac, vtnLocation); |
78 | } | 76 | } |
79 | 77 | ||
80 | - private boolean isValidOlts() { | 78 | + private boolean areOltsValid() { |
81 | JsonNode olts = node.get(OLTS); | 79 | JsonNode olts = node.get(OLTS); |
82 | if (!olts.isObject()) { | 80 | if (!olts.isObject()) { |
83 | return false; | 81 | return false; |
84 | } | 82 | } |
85 | - return !Iterators.any(olts.fields(), item -> !StringUtils.isNumeric(item.getKey()) || | 83 | + return Iterators.all(olts.fields(), |
86 | - !isMacAddress((ObjectNode) olts, item.getKey(), MANDATORY)); | 84 | + item -> ConnectPoint.deviceConnectPoint(item.getKey()) != null && |
85 | + isMacAddress((ObjectNode) olts, item.getKey(), MANDATORY)); | ||
87 | } | 86 | } |
88 | } | 87 | } | ... | ... |
... | @@ -17,12 +17,15 @@ | ... | @@ -17,12 +17,15 @@ |
17 | package org.onosproject.cordconfig.access; | 17 | package org.onosproject.cordconfig.access; |
18 | 18 | ||
19 | import com.google.common.collect.ImmutableMap; | 19 | import com.google.common.collect.ImmutableMap; |
20 | +import org.apache.commons.lang3.tuple.Pair; | ||
20 | import org.onlab.packet.MacAddress; | 21 | import org.onlab.packet.MacAddress; |
21 | import org.onosproject.net.ConnectPoint; | 22 | import org.onosproject.net.ConnectPoint; |
22 | import org.onosproject.net.DeviceId; | 23 | import org.onosproject.net.DeviceId; |
23 | 24 | ||
25 | +import java.util.List; | ||
24 | import java.util.Map; | 26 | import java.util.Map; |
25 | import java.util.Optional; | 27 | import java.util.Optional; |
28 | +import java.util.stream.Collectors; | ||
26 | 29 | ||
27 | import static com.google.common.base.Preconditions.checkNotNull; | 30 | import static com.google.common.base.Preconditions.checkNotNull; |
28 | 31 | ||
... | @@ -30,32 +33,41 @@ import static com.google.common.base.Preconditions.checkNotNull; | ... | @@ -30,32 +33,41 @@ import static com.google.common.base.Preconditions.checkNotNull; |
30 | * Information about an access agent. | 33 | * Information about an access agent. |
31 | */ | 34 | */ |
32 | public class AccessAgentData { | 35 | public class AccessAgentData { |
36 | + | ||
33 | private static final String DEVICE_ID_MISSING = "Device ID cannot be null"; | 37 | private static final String DEVICE_ID_MISSING = "Device ID cannot be null"; |
34 | private static final String OLT_INFO_MISSING = "OLT information cannot be null"; | 38 | private static final String OLT_INFO_MISSING = "OLT information cannot be null"; |
35 | private static final String AGENT_MAC_MISSING = "Agent mac cannot be null"; | 39 | private static final String AGENT_MAC_MISSING = "Agent mac cannot be null"; |
36 | private static final String VTN_MISSING = "VTN location cannot be null"; | 40 | private static final String VTN_MISSING = "VTN location cannot be null"; |
37 | 41 | ||
42 | + private static final int CHIP_PORT_RANGE_SIZE = 130; | ||
38 | 43 | ||
39 | private final Map<ConnectPoint, MacAddress> oltMacInfo; | 44 | private final Map<ConnectPoint, MacAddress> oltMacInfo; |
40 | private final MacAddress agentMac; | 45 | private final MacAddress agentMac; |
41 | private final Optional<ConnectPoint> vtnLocation; | 46 | private final Optional<ConnectPoint> vtnLocation; |
42 | private final DeviceId deviceId; | 47 | private final DeviceId deviceId; |
43 | 48 | ||
49 | + // OLT chip information sorted by ascending MAC address | ||
50 | + private final List<Pair<ConnectPoint, MacAddress>> sortedOltChips; | ||
44 | 51 | ||
45 | /** | 52 | /** |
46 | - * Constucts an agent configuration for a given device. | 53 | + * Constructs an agent configuration for a given device. |
47 | * | 54 | * |
48 | - * @param deviceId access device id | 55 | + * @param deviceId access device ID |
49 | * @param oltMacInfo a map of olt chips and their mac address | 56 | * @param oltMacInfo a map of olt chips and their mac address |
50 | - * @param agentMac the mac address of the agent | 57 | + * @param agentMac the MAC address of the agent |
51 | * @param vtnLocation the location of the agent | 58 | * @param vtnLocation the location of the agent |
52 | */ | 59 | */ |
53 | public AccessAgentData(DeviceId deviceId, Map<ConnectPoint, MacAddress> oltMacInfo, | 60 | public AccessAgentData(DeviceId deviceId, Map<ConnectPoint, MacAddress> oltMacInfo, |
54 | MacAddress agentMac, Optional<ConnectPoint> vtnLocation) { | 61 | MacAddress agentMac, Optional<ConnectPoint> vtnLocation) { |
55 | this.deviceId = checkNotNull(deviceId, DEVICE_ID_MISSING); | 62 | this.deviceId = checkNotNull(deviceId, DEVICE_ID_MISSING); |
56 | - this.oltMacInfo = checkNotNull(oltMacInfo, OLT_INFO_MISSING); | 63 | + this.oltMacInfo = ImmutableMap.copyOf(checkNotNull(oltMacInfo, OLT_INFO_MISSING)); |
57 | this.agentMac = checkNotNull(agentMac, AGENT_MAC_MISSING); | 64 | this.agentMac = checkNotNull(agentMac, AGENT_MAC_MISSING); |
58 | this.vtnLocation = checkNotNull(vtnLocation, VTN_MISSING); | 65 | this.vtnLocation = checkNotNull(vtnLocation, VTN_MISSING); |
66 | + | ||
67 | + this.sortedOltChips = oltMacInfo.entrySet().stream() | ||
68 | + .sorted((e1, e2) -> Long.compare(e1.getValue().toLong(), e2.getValue().toLong())) | ||
69 | + .map(e -> Pair.of(e.getKey(), e.getValue())) | ||
70 | + .collect(Collectors.toList()); | ||
59 | } | 71 | } |
60 | 72 | ||
61 | /** | 73 | /** |
... | @@ -68,17 +80,17 @@ public class AccessAgentData { | ... | @@ -68,17 +80,17 @@ public class AccessAgentData { |
68 | } | 80 | } |
69 | 81 | ||
70 | /** | 82 | /** |
71 | - * Returns the mapping of olt chips to mac addresses. Each chip is | 83 | + * Returns the mapping of OLT chips to MAC addresses. Each chip is |
72 | * symbolized by a connect point. | 84 | * symbolized by a connect point. |
73 | * | 85 | * |
74 | - * @return a mapping of chips (as connect points) to mac addresses | 86 | + * @return a mapping of chips (as connect points) to MAC addresses |
75 | */ | 87 | */ |
76 | public Map<ConnectPoint, MacAddress> getOltMacInfo() { | 88 | public Map<ConnectPoint, MacAddress> getOltMacInfo() { |
77 | - return ImmutableMap.copyOf(oltMacInfo); | 89 | + return oltMacInfo; |
78 | } | 90 | } |
79 | 91 | ||
80 | /** | 92 | /** |
81 | - * Reuturns the agents mac address. | 93 | + * Returns the agent's MAC address. |
82 | * | 94 | * |
83 | * @return a mac address | 95 | * @return a mac address |
84 | */ | 96 | */ |
... | @@ -94,4 +106,21 @@ public class AccessAgentData { | ... | @@ -94,4 +106,21 @@ public class AccessAgentData { |
94 | public Optional<ConnectPoint> getVtnLocation() { | 106 | public Optional<ConnectPoint> getVtnLocation() { |
95 | return vtnLocation; | 107 | return vtnLocation; |
96 | } | 108 | } |
109 | + | ||
110 | + /** | ||
111 | + * Returns the point where the OLT is connected to the fabric given a | ||
112 | + * connect point on the agent device. | ||
113 | + * | ||
114 | + * @param agentConnectPoint connect point on the agent device | ||
115 | + * @return point were OLT is connected to fabric | ||
116 | + */ | ||
117 | + public Optional<ConnectPoint> getOltConnectPoint(ConnectPoint agentConnectPoint) { | ||
118 | + int index = ((int) agentConnectPoint.port().toLong()) / CHIP_PORT_RANGE_SIZE; | ||
119 | + | ||
120 | + if (index >= sortedOltChips.size()) { | ||
121 | + return Optional.empty(); | ||
122 | + } | ||
123 | + | ||
124 | + return Optional.of(sortedOltChips.get(index).getKey()); | ||
125 | + } | ||
97 | } | 126 | } | ... | ... |
... | @@ -37,17 +37,12 @@ import org.onlab.packet.VlanId; | ... | @@ -37,17 +37,12 @@ import org.onlab.packet.VlanId; |
37 | import org.onosproject.cfg.ComponentConfigService; | 37 | import org.onosproject.cfg.ComponentConfigService; |
38 | import org.onosproject.codec.CodecService; | 38 | import org.onosproject.codec.CodecService; |
39 | import org.onosproject.codec.JsonCodec; | 39 | import org.onosproject.codec.JsonCodec; |
40 | -import org.onosproject.cordconfig.access.AccessDeviceConfig; | 40 | +import org.onosproject.cordconfig.access.AccessAgentData; |
41 | import org.onosproject.cordconfig.access.AccessDeviceData; | 41 | import org.onosproject.cordconfig.access.AccessDeviceData; |
42 | +import org.onosproject.cordconfig.access.CordConfigService; | ||
42 | import org.onosproject.core.ApplicationId; | 43 | import org.onosproject.core.ApplicationId; |
43 | import org.onosproject.core.CoreService; | 44 | import org.onosproject.core.CoreService; |
44 | import org.onosproject.net.ConnectPoint; | 45 | import org.onosproject.net.ConnectPoint; |
45 | -import org.onosproject.net.DeviceId; | ||
46 | -import org.onosproject.net.config.ConfigFactory; | ||
47 | -import org.onosproject.net.config.NetworkConfigEvent; | ||
48 | -import org.onosproject.net.config.NetworkConfigListener; | ||
49 | -import org.onosproject.net.config.NetworkConfigRegistry; | ||
50 | -import org.onosproject.net.config.basics.SubjectFactories; | ||
51 | import org.onosproject.net.flow.DefaultTrafficSelector; | 46 | import org.onosproject.net.flow.DefaultTrafficSelector; |
52 | import org.onosproject.net.flow.DefaultTrafficTreatment; | 47 | import org.onosproject.net.flow.DefaultTrafficTreatment; |
53 | import org.onosproject.net.flow.TrafficSelector; | 48 | import org.onosproject.net.flow.TrafficSelector; |
... | @@ -64,7 +59,6 @@ import org.onosproject.net.mcast.McastListener; | ... | @@ -64,7 +59,6 @@ import org.onosproject.net.mcast.McastListener; |
64 | import org.onosproject.net.mcast.McastRoute; | 59 | import org.onosproject.net.mcast.McastRoute; |
65 | import org.onosproject.net.mcast.McastRouteInfo; | 60 | import org.onosproject.net.mcast.McastRouteInfo; |
66 | import org.onosproject.net.mcast.MulticastRouteService; | 61 | import org.onosproject.net.mcast.MulticastRouteService; |
67 | - | ||
68 | import org.onosproject.rest.AbstractWebResource; | 62 | import org.onosproject.rest.AbstractWebResource; |
69 | import org.osgi.service.component.ComponentContext; | 63 | import org.osgi.service.component.ComponentContext; |
70 | import org.slf4j.Logger; | 64 | import org.slf4j.Logger; |
... | @@ -80,8 +74,8 @@ import java.io.IOException; | ... | @@ -80,8 +74,8 @@ import java.io.IOException; |
80 | import java.util.Dictionary; | 74 | import java.util.Dictionary; |
81 | import java.util.List; | 75 | import java.util.List; |
82 | import java.util.Map; | 76 | import java.util.Map; |
77 | +import java.util.Optional; | ||
83 | import java.util.Properties; | 78 | import java.util.Properties; |
84 | -import java.util.concurrent.ConcurrentHashMap; | ||
85 | import java.util.concurrent.atomic.AtomicBoolean; | 79 | import java.util.concurrent.atomic.AtomicBoolean; |
86 | 80 | ||
87 | import static com.google.common.base.Preconditions.checkNotNull; | 81 | import static com.google.common.base.Preconditions.checkNotNull; |
... | @@ -98,8 +92,9 @@ import static org.slf4j.LoggerFactory.getLogger; | ... | @@ -98,8 +92,9 @@ import static org.slf4j.LoggerFactory.getLogger; |
98 | @Component(immediate = true) | 92 | @Component(immediate = true) |
99 | public class CordMcast { | 93 | public class CordMcast { |
100 | 94 | ||
95 | + private final Logger log = getLogger(getClass()); | ||
101 | 96 | ||
102 | - private static final int DEFAULT_REST_TIMEOUT_MS = 2000; | 97 | + private static final int DEFAULT_REST_TIMEOUT_MS = 1000; |
103 | private static final int DEFAULT_PRIORITY = 500; | 98 | private static final int DEFAULT_PRIORITY = 500; |
104 | private static final short DEFAULT_MCAST_VLAN = 4000; | 99 | private static final short DEFAULT_MCAST_VLAN = 4000; |
105 | private static final String DEFAULT_SYNC_HOST = "10.90.0.8:8181"; | 100 | private static final String DEFAULT_SYNC_HOST = "10.90.0.8:8181"; |
... | @@ -107,8 +102,6 @@ public class CordMcast { | ... | @@ -107,8 +102,6 @@ public class CordMcast { |
107 | private static final String DEFAULT_PASSWORD = "karaf"; | 102 | private static final String DEFAULT_PASSWORD = "karaf"; |
108 | private static final boolean DEFAULT_VLAN_ENABLED = true; | 103 | private static final boolean DEFAULT_VLAN_ENABLED = true; |
109 | 104 | ||
110 | - private final Logger log = getLogger(getClass()); | ||
111 | - | ||
112 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | 105 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
113 | protected MulticastRouteService mcastService; | 106 | protected MulticastRouteService mcastService; |
114 | 107 | ||
... | @@ -125,11 +118,9 @@ public class CordMcast { | ... | @@ -125,11 +118,9 @@ public class CordMcast { |
125 | protected ComponentConfigService componentConfigService; | 118 | protected ComponentConfigService componentConfigService; |
126 | 119 | ||
127 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | 120 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
128 | - protected NetworkConfigRegistry networkConfig; | 121 | + protected CordConfigService cordConfigService; |
129 | 122 | ||
130 | protected McastListener listener = new InternalMulticastListener(); | 123 | protected McastListener listener = new InternalMulticastListener(); |
131 | - private InternalNetworkConfigListener configListener = | ||
132 | - new InternalNetworkConfigListener(); | ||
133 | 124 | ||
134 | //TODO: move this to a ec map | 125 | //TODO: move this to a ec map |
135 | private Map<IpAddress, Integer> groups = Maps.newConcurrentMap(); | 126 | private Map<IpAddress, Integer> groups = Maps.newConcurrentMap(); |
... | @@ -162,20 +153,6 @@ public class CordMcast { | ... | @@ -162,20 +153,6 @@ public class CordMcast { |
162 | 153 | ||
163 | private String fabricOnosUrl; | 154 | private String fabricOnosUrl; |
164 | 155 | ||
165 | - private Map<DeviceId, AccessDeviceData> oltData = new ConcurrentHashMap<>(); | ||
166 | - | ||
167 | - private static final Class<AccessDeviceConfig> CONFIG_CLASS = | ||
168 | - AccessDeviceConfig.class; | ||
169 | - | ||
170 | - private ConfigFactory<DeviceId, AccessDeviceConfig> configFactory = | ||
171 | - new ConfigFactory<DeviceId, AccessDeviceConfig>( | ||
172 | - SubjectFactories.DEVICE_SUBJECT_FACTORY, CONFIG_CLASS, "accessDevice") { | ||
173 | - @Override | ||
174 | - public AccessDeviceConfig createConfig() { | ||
175 | - return new AccessDeviceConfig(); | ||
176 | - } | ||
177 | - }; | ||
178 | - | ||
179 | @Activate | 156 | @Activate |
180 | public void activate(ComponentContext context) { | 157 | public void activate(ComponentContext context) { |
181 | componentConfigService.registerProperties(getClass()); | 158 | componentConfigService.registerProperties(getClass()); |
... | @@ -183,23 +160,8 @@ public class CordMcast { | ... | @@ -183,23 +160,8 @@ public class CordMcast { |
183 | 160 | ||
184 | appId = coreService.registerApplication("org.onosproject.cordmcast"); | 161 | appId = coreService.registerApplication("org.onosproject.cordmcast"); |
185 | 162 | ||
186 | - | ||
187 | clearRemoteRoutes(); | 163 | clearRemoteRoutes(); |
188 | 164 | ||
189 | - networkConfig.registerConfigFactory(configFactory); | ||
190 | - networkConfig.addListener(configListener); | ||
191 | - | ||
192 | - networkConfig.getSubjects(DeviceId.class, AccessDeviceConfig.class).forEach( | ||
193 | - subject -> { | ||
194 | - AccessDeviceConfig config = networkConfig.getConfig(subject, AccessDeviceConfig.class); | ||
195 | - if (config != null) { | ||
196 | - AccessDeviceData data = config.getOlt(); | ||
197 | - oltData.put(data.deviceId(), data); | ||
198 | - } | ||
199 | - } | ||
200 | - ); | ||
201 | - | ||
202 | - | ||
203 | mcastService.addListener(listener); | 165 | mcastService.addListener(listener); |
204 | 166 | ||
205 | mcastService.getRoutes().stream() | 167 | mcastService.getRoutes().stream() |
... | @@ -215,8 +177,6 @@ public class CordMcast { | ... | @@ -215,8 +177,6 @@ public class CordMcast { |
215 | public void deactivate() { | 177 | public void deactivate() { |
216 | componentConfigService.unregisterProperties(getClass(), false); | 178 | componentConfigService.unregisterProperties(getClass(), false); |
217 | mcastService.removeListener(listener); | 179 | mcastService.removeListener(listener); |
218 | - networkConfig.unregisterConfigFactory(configFactory); | ||
219 | - networkConfig.removeListener(configListener); | ||
220 | log.info("Stopped"); | 180 | log.info("Stopped"); |
221 | } | 181 | } |
222 | 182 | ||
... | @@ -323,9 +283,9 @@ public class CordMcast { | ... | @@ -323,9 +283,9 @@ public class CordMcast { |
323 | checkNotNull(route, "Route cannot be null"); | 283 | checkNotNull(route, "Route cannot be null"); |
324 | checkNotNull(sink, "Sink cannot be null"); | 284 | checkNotNull(sink, "Sink cannot be null"); |
325 | 285 | ||
326 | - AccessDeviceData oltInfo = oltData.get(sink.deviceId()); | 286 | + Optional<AccessDeviceData> oltInfo = cordConfigService.getAccessDevice(sink.deviceId()); |
327 | 287 | ||
328 | - if (oltInfo == null) { | 288 | + if (!oltInfo.isPresent()) { |
329 | log.warn("Unknown OLT device : {}", sink.deviceId()); | 289 | log.warn("Unknown OLT device : {}", sink.deviceId()); |
330 | return; | 290 | return; |
331 | } | 291 | } |
... | @@ -359,7 +319,7 @@ public class CordMcast { | ... | @@ -359,7 +319,7 @@ public class CordMcast { |
359 | flowObjectiveService.next(sink.deviceId(), next); | 319 | flowObjectiveService.next(sink.deviceId(), next); |
360 | 320 | ||
361 | TrafficSelector.Builder mcast = DefaultTrafficSelector.builder() | 321 | TrafficSelector.Builder mcast = DefaultTrafficSelector.builder() |
362 | - .matchInPort(oltInfo.uplink()) | 322 | + .matchInPort(oltInfo.get().uplink()) |
363 | .matchEthType(Ethernet.TYPE_IPV4) | 323 | .matchEthType(Ethernet.TYPE_IPV4) |
364 | .matchIPDst(g.toIpPrefix()); | 324 | .matchIPDst(g.toIpPrefix()); |
365 | 325 | ||
... | @@ -420,17 +380,29 @@ public class CordMcast { | ... | @@ -420,17 +380,29 @@ public class CordMcast { |
420 | flowObjectiveService.next(sink.deviceId(), next); | 380 | flowObjectiveService.next(sink.deviceId(), next); |
421 | } | 381 | } |
422 | 382 | ||
423 | - | 383 | + addRemoteRoute(route, sink); |
424 | - addRemoteRoute(route); | ||
425 | } | 384 | } |
426 | 385 | ||
427 | - private void addRemoteRoute(McastRoute route) { | 386 | + private void addRemoteRoute(McastRoute route, ConnectPoint inPort) { |
428 | checkNotNull(route); | 387 | checkNotNull(route); |
429 | if (syncHost == null) { | 388 | if (syncHost == null) { |
430 | log.warn("No host configured for synchronization; route will be dropped"); | 389 | log.warn("No host configured for synchronization; route will be dropped"); |
431 | return; | 390 | return; |
432 | } | 391 | } |
433 | 392 | ||
393 | + Optional<AccessAgentData> accessAgent = cordConfigService.getAccessAgent(inPort.deviceId()); | ||
394 | + if (!accessAgent.isPresent()) { | ||
395 | + log.warn("No accessAgent config found for in port {}", inPort); | ||
396 | + return; | ||
397 | + } | ||
398 | + | ||
399 | + if (!accessAgent.get().getOltConnectPoint(inPort).isPresent()) { | ||
400 | + log.warn("No OLT configured for in port {}", inPort); | ||
401 | + return; | ||
402 | + } | ||
403 | + | ||
404 | + ConnectPoint oltConnectPoint = accessAgent.get().getOltConnectPoint(inPort).get(); | ||
405 | + | ||
434 | log.debug("Sending route {} to other ONOS {}", route, fabricOnosUrl); | 406 | log.debug("Sending route {} to other ONOS {}", route, fabricOnosUrl); |
435 | 407 | ||
436 | Invocation.Builder builder = getClientBuilder(fabricOnosUrl); | 408 | Invocation.Builder builder = getClientBuilder(fabricOnosUrl); |
... | @@ -440,6 +412,13 @@ public class CordMcast { | ... | @@ -440,6 +412,13 @@ public class CordMcast { |
440 | 412 | ||
441 | try { | 413 | try { |
442 | builder.post(Entity.json(json.toString())); | 414 | builder.post(Entity.json(json.toString())); |
415 | + | ||
416 | + builder = getClientBuilder(fabricOnosUrl + "/sinks/" + route.group() + "/" + route.source()); | ||
417 | + ObjectMapper mapper = new ObjectMapper(); | ||
418 | + ObjectNode obj = mapper.createObjectNode(); | ||
419 | + obj.putArray("sinks").add(oltConnectPoint.deviceId() + "/" + oltConnectPoint.port()); | ||
420 | + | ||
421 | + builder.post(Entity.json(obj.toString())); | ||
443 | } catch (ProcessingException e) { | 422 | } catch (ProcessingException e) { |
444 | log.warn("Unable to send route to remote controller: {}", e.getMessage()); | 423 | log.warn("Unable to send route to remote controller: {}", e.getMessage()); |
445 | } | 424 | } |
... | @@ -489,7 +468,7 @@ public class CordMcast { | ... | @@ -489,7 +468,7 @@ public class CordMcast { |
489 | list.forEach(n -> mcastRoutes.add( | 468 | list.forEach(n -> mcastRoutes.add( |
490 | routeCodec.decode((ObjectNode) n, new AbstractWebResource()))); | 469 | routeCodec.decode((ObjectNode) n, new AbstractWebResource()))); |
491 | 470 | ||
492 | - } catch (IOException e) { | 471 | + } catch (IOException | ProcessingException e) { |
493 | log.warn("Error clearing remote routes", e); | 472 | log.warn("Error clearing remote routes", e); |
494 | } | 473 | } |
495 | 474 | ||
... | @@ -508,34 +487,4 @@ public class CordMcast { | ... | @@ -508,34 +487,4 @@ public class CordMcast { |
508 | return wt.request(JSON_UTF_8.toString()); | 487 | return wt.request(JSON_UTF_8.toString()); |
509 | } | 488 | } |
510 | 489 | ||
511 | - private class InternalNetworkConfigListener implements NetworkConfigListener { | ||
512 | - @Override | ||
513 | - public void event(NetworkConfigEvent event) { | ||
514 | - switch (event.type()) { | ||
515 | - | ||
516 | - case CONFIG_ADDED: | ||
517 | - case CONFIG_UPDATED: | ||
518 | - AccessDeviceConfig config = | ||
519 | - networkConfig.getConfig((DeviceId) event.subject(), CONFIG_CLASS); | ||
520 | - if (config != null) { | ||
521 | - oltData.put(config.getOlt().deviceId(), config.getOlt()); | ||
522 | - } | ||
523 | - | ||
524 | - break; | ||
525 | - case CONFIG_REGISTERED: | ||
526 | - case CONFIG_UNREGISTERED: | ||
527 | - break; | ||
528 | - case CONFIG_REMOVED: | ||
529 | - oltData.remove(event.subject()); | ||
530 | - break; | ||
531 | - default: | ||
532 | - break; | ||
533 | - } | ||
534 | - } | ||
535 | - | ||
536 | - @Override | ||
537 | - public boolean isRelevant(NetworkConfigEvent event) { | ||
538 | - return event.configClass().equals(CONFIG_CLASS); | ||
539 | - } | ||
540 | - } | ||
541 | } | 490 | } | ... | ... |
-
Please register or login to post a comment