Committed by
Gerrit Code Review
[ONOS-4513] Remove optical dependency from store/dist
- Ensure only generic port description will go into the DeviceStore Change-Id: I7ba6c1680c2d5e3a5579337193c620c89f5f7f41
Showing
2 changed files
with
67 additions
and
80 deletions
| ... | @@ -22,6 +22,8 @@ import static org.onlab.util.Tools.nullIsNotFound; | ... | @@ -22,6 +22,8 @@ import static org.onlab.util.Tools.nullIsNotFound; |
| 22 | import static org.onosproject.net.MastershipRole.MASTER; | 22 | import static org.onosproject.net.MastershipRole.MASTER; |
| 23 | import static org.onosproject.net.MastershipRole.NONE; | 23 | import static org.onosproject.net.MastershipRole.NONE; |
| 24 | import static org.onosproject.net.MastershipRole.STANDBY; | 24 | import static org.onosproject.net.MastershipRole.STANDBY; |
| 25 | +import static org.onosproject.net.optical.device.OchPortHelper.ochPortDescription; | ||
| 26 | +import static org.onosproject.net.optical.device.OduCltPortHelper.oduCltPortDescription; | ||
| 25 | import static org.onosproject.security.AppGuard.checkPermission; | 27 | import static org.onosproject.security.AppGuard.checkPermission; |
| 26 | import static org.onosproject.security.AppPermission.Type.DEVICE_READ; | 28 | import static org.onosproject.security.AppPermission.Type.DEVICE_READ; |
| 27 | import static org.slf4j.LoggerFactory.getLogger; | 29 | import static org.slf4j.LoggerFactory.getLogger; |
| ... | @@ -74,8 +76,14 @@ import org.onosproject.net.device.DeviceProviderService; | ... | @@ -74,8 +76,14 @@ import org.onosproject.net.device.DeviceProviderService; |
| 74 | import org.onosproject.net.device.DeviceService; | 76 | import org.onosproject.net.device.DeviceService; |
| 75 | import org.onosproject.net.device.DeviceStore; | 77 | import org.onosproject.net.device.DeviceStore; |
| 76 | import org.onosproject.net.device.DeviceStoreDelegate; | 78 | import org.onosproject.net.device.DeviceStoreDelegate; |
| 79 | +import org.onosproject.net.device.OchPortDescription; | ||
| 80 | +import org.onosproject.net.device.OduCltPortDescription; | ||
| 81 | +import org.onosproject.net.device.OmsPortDescription; | ||
| 82 | +import org.onosproject.net.device.OtuPortDescription; | ||
| 77 | import org.onosproject.net.device.PortDescription; | 83 | import org.onosproject.net.device.PortDescription; |
| 78 | import org.onosproject.net.device.PortStatistics; | 84 | import org.onosproject.net.device.PortStatistics; |
| 85 | +import org.onosproject.net.optical.device.OmsPortHelper; | ||
| 86 | +import org.onosproject.net.optical.device.OtuPortHelper; | ||
| 79 | import org.onosproject.net.provider.AbstractListenerProviderRegistry; | 87 | import org.onosproject.net.provider.AbstractListenerProviderRegistry; |
| 80 | import org.onosproject.net.provider.AbstractProviderService; | 88 | import org.onosproject.net.provider.AbstractProviderService; |
| 81 | import org.slf4j.Logger; | 89 | import org.slf4j.Logger; |
| ... | @@ -420,6 +428,60 @@ public class DeviceManager | ... | @@ -420,6 +428,60 @@ public class DeviceManager |
| 420 | } | 428 | } |
| 421 | } | 429 | } |
| 422 | 430 | ||
| 431 | + /** | ||
| 432 | + * Transforms optical specific PortDescription to generic PortDescription. | ||
| 433 | + * | ||
| 434 | + * @param descr PortDescription | ||
| 435 | + * @return generic PortDescription | ||
| 436 | + * @deprecated in Goldeneye (1.6.0) | ||
| 437 | + */ | ||
| 438 | + @Deprecated | ||
| 439 | + private PortDescription ensureGeneric(PortDescription descr) { | ||
| 440 | + switch (descr.type()) { | ||
| 441 | + case OCH: | ||
| 442 | + if (descr instanceof OchPortDescription) { | ||
| 443 | + OchPortDescription och = (OchPortDescription) descr; | ||
| 444 | + return ochPortDescription(och, | ||
| 445 | + och.signalType(), | ||
| 446 | + och.isTunable(), | ||
| 447 | + och.lambda(), | ||
| 448 | + och.annotations()); | ||
| 449 | + } | ||
| 450 | + break; | ||
| 451 | + case ODUCLT: | ||
| 452 | + if (descr instanceof OduCltPortDescription) { | ||
| 453 | + OduCltPortDescription clt = (OduCltPortDescription) descr; | ||
| 454 | + return oduCltPortDescription(clt, | ||
| 455 | + clt.signalType(), | ||
| 456 | + clt.annotations()); | ||
| 457 | + } | ||
| 458 | + break; | ||
| 459 | + case OMS: | ||
| 460 | + if (descr instanceof OmsPortDescription) { | ||
| 461 | + OmsPortDescription oms = (OmsPortDescription) descr; | ||
| 462 | + return OmsPortHelper.omsPortDescription(oms, | ||
| 463 | + oms.minFrequency(), | ||
| 464 | + oms.maxFrequency(), | ||
| 465 | + oms.grid(), | ||
| 466 | + oms.annotations()); | ||
| 467 | + } | ||
| 468 | + break; | ||
| 469 | + case OTU: | ||
| 470 | + if (descr instanceof OtuPortDescription) { | ||
| 471 | + OtuPortDescription otu = (OtuPortDescription) descr; | ||
| 472 | + return OtuPortHelper.otuPortDescription(otu, | ||
| 473 | + otu.signalType(), | ||
| 474 | + otu.annotations()); | ||
| 475 | + } | ||
| 476 | + break; | ||
| 477 | + | ||
| 478 | + default: | ||
| 479 | + // no-op | ||
| 480 | + break; | ||
| 481 | + } | ||
| 482 | + return descr; | ||
| 483 | + } | ||
| 484 | + | ||
| 423 | @Override | 485 | @Override |
| 424 | public void updatePorts(DeviceId deviceId, | 486 | public void updatePorts(DeviceId deviceId, |
| 425 | List<PortDescription> portDescriptions) { | 487 | List<PortDescription> portDescriptions) { |
| ... | @@ -434,6 +496,7 @@ public class DeviceManager | ... | @@ -434,6 +496,7 @@ public class DeviceManager |
| 434 | } | 496 | } |
| 435 | portDescriptions = portDescriptions.stream() | 497 | portDescriptions = portDescriptions.stream() |
| 436 | .map(e -> consolidate(deviceId, e)) | 498 | .map(e -> consolidate(deviceId, e)) |
| 499 | + .map(this::ensureGeneric) | ||
| 437 | .collect(Collectors.toList()); | 500 | .collect(Collectors.toList()); |
| 438 | List<DeviceEvent> events = store.updatePorts(this.provider().id(), | 501 | List<DeviceEvent> events = store.updatePorts(this.provider().id(), |
| 439 | deviceId, portDescriptions); | 502 | deviceId, portDescriptions); |
| ... | @@ -462,12 +525,14 @@ public class DeviceManager | ... | @@ -462,12 +525,14 @@ public class DeviceManager |
| 462 | if ((Device.Type.ROADM.equals(device.type())) || | 525 | if ((Device.Type.ROADM.equals(device.type())) || |
| 463 | (Device.Type.OTN.equals(device.type()))) { | 526 | (Device.Type.OTN.equals(device.type()))) { |
| 464 | Port port = getPort(deviceId, portDescription.portNumber()); | 527 | Port port = getPort(deviceId, portDescription.portNumber()); |
| 528 | + // FIXME This is ignoring all other info in portDescription given as input?? | ||
| 465 | portDescription = OpticalPortOperator.descriptionOf(port, portDescription.isEnabled()); | 529 | portDescription = OpticalPortOperator.descriptionOf(port, portDescription.isEnabled()); |
| 466 | } | 530 | } |
| 467 | 531 | ||
| 468 | portDescription = consolidate(deviceId, portDescription); | 532 | portDescription = consolidate(deviceId, portDescription); |
| 469 | final DeviceEvent event = store.updatePortStatus(this.provider().id(), | 533 | final DeviceEvent event = store.updatePortStatus(this.provider().id(), |
| 470 | - deviceId, portDescription); | 534 | + deviceId, |
| 535 | + ensureGeneric(portDescription)); | ||
| 471 | if (event != null) { | 536 | if (event != null) { |
| 472 | log.info("Device {} port {} status changed", deviceId, event.port().number()); | 537 | log.info("Device {} port {} status changed", deviceId, event.port().number()); |
| 473 | post(event); | 538 | post(event); | ... | ... |
| ... | @@ -17,11 +17,6 @@ package org.onosproject.store.device.impl; | ... | @@ -17,11 +17,6 @@ package org.onosproject.store.device.impl; |
| 17 | 17 | ||
| 18 | import static com.google.common.base.Preconditions.checkNotNull; | 18 | import static com.google.common.base.Preconditions.checkNotNull; |
| 19 | import static org.onosproject.net.DefaultAnnotations.union; | 19 | import static org.onosproject.net.DefaultAnnotations.union; |
| 20 | -import static org.onosproject.net.optical.device.OchPortHelper.ochPortDescription; | ||
| 21 | -import static org.onosproject.net.optical.device.OduCltPortHelper.oduCltPortDescription; | ||
| 22 | -import static org.onosproject.net.optical.device.OmsPortHelper.omsPortDescription; | ||
| 23 | -import static org.onosproject.net.optical.device.OtuPortHelper.otuPortDescription; | ||
| 24 | - | ||
| 25 | import java.util.Collections; | 20 | import java.util.Collections; |
| 26 | import java.util.Map; | 21 | import java.util.Map; |
| 27 | import java.util.concurrent.ConcurrentHashMap; | 22 | import java.util.concurrent.ConcurrentHashMap; |
| ... | @@ -32,10 +27,6 @@ import org.onosproject.net.SparseAnnotations; | ... | @@ -32,10 +27,6 @@ import org.onosproject.net.SparseAnnotations; |
| 32 | import org.onosproject.net.device.DefaultDeviceDescription; | 27 | import org.onosproject.net.device.DefaultDeviceDescription; |
| 33 | import org.onosproject.net.device.DefaultPortDescription; | 28 | import org.onosproject.net.device.DefaultPortDescription; |
| 34 | import org.onosproject.net.device.DeviceDescription; | 29 | import org.onosproject.net.device.DeviceDescription; |
| 35 | -import org.onosproject.net.device.OchPortDescription; | ||
| 36 | -import org.onosproject.net.device.OduCltPortDescription; | ||
| 37 | -import org.onosproject.net.device.OmsPortDescription; | ||
| 38 | -import org.onosproject.net.device.OtuPortDescription; | ||
| 39 | import org.onosproject.net.device.PortDescription; | 30 | import org.onosproject.net.device.PortDescription; |
| 40 | import org.onosproject.store.Timestamp; | 31 | import org.onosproject.store.Timestamp; |
| 41 | import org.onosproject.store.impl.Timestamped; | 32 | import org.onosproject.store.impl.Timestamped; |
| ... | @@ -105,78 +96,9 @@ class DeviceDescriptions { | ... | @@ -105,78 +96,9 @@ class DeviceDescriptions { |
| 105 | if (oldOne != null) { | 96 | if (oldOne != null) { |
| 106 | SparseAnnotations merged = union(oldOne.value().annotations(), | 97 | SparseAnnotations merged = union(oldOne.value().annotations(), |
| 107 | newDesc.value().annotations()); | 98 | newDesc.value().annotations()); |
| 108 | - newOne = null; | 99 | + newOne = new Timestamped<>( |
| 109 | - switch (newDesc.value().type()) { | ||
| 110 | - case OMS: | ||
| 111 | - if (newDesc.value() instanceof OmsPortDescription) { | ||
| 112 | - // remove if-block after deprecation is complete | ||
| 113 | - OmsPortDescription omsDesc = (OmsPortDescription) (newDesc.value()); | ||
| 114 | - newOne = new Timestamped<>( | ||
| 115 | - omsPortDescription(omsDesc, | ||
| 116 | - omsDesc.minFrequency(), | ||
| 117 | - omsDesc.maxFrequency(), | ||
| 118 | - omsDesc.grid(), merged), | ||
| 119 | - newDesc.timestamp()); | ||
| 120 | - } else { | ||
| 121 | - // same as default case | ||
| 122 | - newOne = new Timestamped<>( | ||
| 123 | - new DefaultPortDescription(newDesc.value(), merged), | ||
| 124 | - newDesc.timestamp()); | ||
| 125 | - } | ||
| 126 | - break; | ||
| 127 | - case OCH: | ||
| 128 | - if (newDesc.value() instanceof OchPortDescription) { | ||
| 129 | - // remove if-block after Och related deprecation is complete | ||
| 130 | - OchPortDescription ochDesc = (OchPortDescription) (newDesc.value()); | ||
| 131 | - newOne = new Timestamped<>( | ||
| 132 | - ochPortDescription(ochDesc, | ||
| 133 | - ochDesc.signalType(), | ||
| 134 | - ochDesc.isTunable(), | ||
| 135 | - ochDesc.lambda(), merged), | ||
| 136 | - newDesc.timestamp()); | ||
| 137 | - } else { | ||
| 138 | - // same as default case | ||
| 139 | - newOne = new Timestamped<>( | ||
| 140 | - new DefaultPortDescription(newDesc.value(), merged), | ||
| 141 | - newDesc.timestamp()); | ||
| 142 | - } | ||
| 143 | - break; | ||
| 144 | - case ODUCLT: | ||
| 145 | - if (newDesc.value() instanceof OduCltPortDescription) { | ||
| 146 | - // remove if-block after deprecation is complete | ||
| 147 | - OduCltPortDescription ocDesc = (OduCltPortDescription) (newDesc.value()); | ||
| 148 | - newOne = new Timestamped<>( | ||
| 149 | - oduCltPortDescription(ocDesc, | ||
| 150 | - ocDesc.signalType(), | ||
| 151 | - merged), | ||
| 152 | - newDesc.timestamp()); | ||
| 153 | - } else { | ||
| 154 | - // same as default case | ||
| 155 | - newOne = new Timestamped<>( | ||
| 156 | - new DefaultPortDescription(newDesc.value(), merged), | ||
| 157 | - newDesc.timestamp()); | ||
| 158 | - } | ||
| 159 | - break; | ||
| 160 | - case OTU: | ||
| 161 | - if (newDesc.value() instanceof OtuPortDescription) { | ||
| 162 | - // remove if-block after deprecation is complete | ||
| 163 | - OtuPortDescription otuDesc = (OtuPortDescription) (newDesc.value()); | ||
| 164 | - newOne = new Timestamped<>( | ||
| 165 | - otuPortDescription( | ||
| 166 | - otuDesc, otuDesc.signalType(), merged), | ||
| 167 | - newDesc.timestamp()); | ||
| 168 | - } else { | ||
| 169 | - // same as default case | ||
| 170 | - newOne = new Timestamped<>( | ||
| 171 | - new DefaultPortDescription(newDesc.value(), merged), | ||
| 172 | - newDesc.timestamp()); | ||
| 173 | - } | ||
| 174 | - break; | ||
| 175 | - default: | ||
| 176 | - newOne = new Timestamped<>( | ||
| 177 | new DefaultPortDescription(newDesc.value(), merged), | 100 | new DefaultPortDescription(newDesc.value(), merged), |
| 178 | newDesc.timestamp()); | 101 | newDesc.timestamp()); |
| 179 | - } | ||
| 180 | } | 102 | } |
| 181 | portDescs.put(newOne.value().portNumber(), newOne); | 103 | portDescs.put(newOne.value().portNumber(), newOne); |
| 182 | } | 104 | } | ... | ... |
-
Please register or login to post a comment