Committed by
Gerrit Code Review
Partial support for LambdaQuery returning FLEX grid.
Change-Id: I419cb38d1639639fad3f8327ecfbd3c63932f179
Showing
1 changed file
with
27 additions
and
1 deletions
... | @@ -17,14 +17,17 @@ package org.onosproject.net.resource.impl; | ... | @@ -17,14 +17,17 @@ package org.onosproject.net.resource.impl; |
17 | 17 | ||
18 | import com.google.common.collect.ImmutableSet; | 18 | import com.google.common.collect.ImmutableSet; |
19 | import com.google.common.collect.Lists; | 19 | import com.google.common.collect.Lists; |
20 | + | ||
20 | import org.onlab.packet.MplsLabel; | 21 | import org.onlab.packet.MplsLabel; |
21 | import org.onlab.packet.VlanId; | 22 | import org.onlab.packet.VlanId; |
22 | import org.onlab.util.Bandwidth; | 23 | import org.onlab.util.Bandwidth; |
23 | import org.onlab.util.ItemNotFoundException; | 24 | import org.onlab.util.ItemNotFoundException; |
24 | import org.onosproject.mastership.MastershipService; | 25 | import org.onosproject.mastership.MastershipService; |
26 | +import org.onosproject.net.ChannelSpacing; | ||
25 | import org.onosproject.net.ConnectPoint; | 27 | import org.onosproject.net.ConnectPoint; |
26 | import org.onosproject.net.Device; | 28 | import org.onosproject.net.Device; |
27 | import org.onosproject.net.DeviceId; | 29 | import org.onosproject.net.DeviceId; |
30 | +import org.onosproject.net.GridType; | ||
28 | import org.onosproject.net.OchSignal; | 31 | import org.onosproject.net.OchSignal; |
29 | import org.onosproject.net.Port; | 32 | import org.onosproject.net.Port; |
30 | import org.onosproject.net.PortNumber; | 33 | import org.onosproject.net.PortNumber; |
... | @@ -55,6 +58,7 @@ import java.util.Optional; | ... | @@ -55,6 +58,7 @@ import java.util.Optional; |
55 | import java.util.Set; | 58 | import java.util.Set; |
56 | import java.util.concurrent.ExecutorService; | 59 | import java.util.concurrent.ExecutorService; |
57 | import java.util.stream.Collectors; | 60 | import java.util.stream.Collectors; |
61 | +import java.util.stream.Stream; | ||
58 | 62 | ||
59 | import static com.google.common.base.Preconditions.checkNotNull; | 63 | import static com.google.common.base.Preconditions.checkNotNull; |
60 | 64 | ||
... | @@ -259,7 +263,7 @@ final class ResourceDeviceListener implements DeviceListener { | ... | @@ -259,7 +263,7 @@ final class ResourceDeviceListener implements DeviceListener { |
259 | LambdaQuery query = handler.behaviour(LambdaQuery.class); | 263 | LambdaQuery query = handler.behaviour(LambdaQuery.class); |
260 | if (query != null) { | 264 | if (query != null) { |
261 | return query.queryLambdas(port).stream() | 265 | return query.queryLambdas(port).stream() |
262 | - .flatMap(x -> OchSignal.toFlexGrid(x).stream()) | 266 | + .flatMap(ResourceDeviceListener::toResourceGrid) |
263 | .collect(Collectors.toSet()); | 267 | .collect(Collectors.toSet()); |
264 | } else { | 268 | } else { |
265 | return Collections.emptySet(); | 269 | return Collections.emptySet(); |
... | @@ -269,6 +273,28 @@ final class ResourceDeviceListener implements DeviceListener { | ... | @@ -269,6 +273,28 @@ final class ResourceDeviceListener implements DeviceListener { |
269 | } | 273 | } |
270 | } | 274 | } |
271 | 275 | ||
276 | + /** | ||
277 | + * Convert {@link OchSignal} into gridtype used to track Resource. | ||
278 | + * | ||
279 | + * @param ochSignal {@link OchSignal} | ||
280 | + * @return {@code ochSignal} mapped to Stream of flex grid slots with 6.25 GHz spacing | ||
281 | + * and 12.5 GHz slot width. | ||
282 | + */ | ||
283 | + private static Stream<OchSignal> toResourceGrid(OchSignal ochSignal) { | ||
284 | + if (ochSignal.gridType() != GridType.FLEX) { | ||
285 | + return OchSignal.toFlexGrid(ochSignal).stream(); | ||
286 | + } | ||
287 | + if (ochSignal.gridType() == GridType.FLEX && | ||
288 | + ochSignal.channelSpacing() == ChannelSpacing.CHL_6P25GHZ && | ||
289 | + ochSignal.slotGranularity() == 1) { | ||
290 | + // input was already flex grid slots with 6.25 GHz spacing and 12.5 GHz slot width. | ||
291 | + return Stream.of(ochSignal); | ||
292 | + } | ||
293 | + // FIXME handle FLEX but not 6.25 GHz spacing or 12.5 GHz slot width case. | ||
294 | + log.error("Converting {} to resource tracking grid not supported yet.", ochSignal); | ||
295 | + return Stream.<OchSignal>builder().build(); | ||
296 | + } | ||
297 | + | ||
272 | private Set<VlanId> queryVlanIds(DeviceId device, PortNumber port) { | 298 | private Set<VlanId> queryVlanIds(DeviceId device, PortNumber port) { |
273 | try { | 299 | try { |
274 | DriverHandler handler = driverService.createHandler(device); | 300 | DriverHandler handler = driverService.createHandler(device); | ... | ... |
-
Please register or login to post a comment