Committed by
Gerrit Code Review
Populate OchSignal with OchPort
Change-Id: I2e9031972e286f25f9caa32fac26d37e3efd10b5
Showing
4 changed files
with
49 additions
and
162 deletions
| ... | @@ -20,6 +20,7 @@ import org.onlab.util.Frequency; | ... | @@ -20,6 +20,7 @@ import org.onlab.util.Frequency; |
| 20 | import java.util.Objects; | 20 | import java.util.Objects; |
| 21 | 21 | ||
| 22 | import static com.google.common.base.MoreObjects.toStringHelper; | 22 | import static com.google.common.base.MoreObjects.toStringHelper; |
| 23 | +import static com.google.common.base.Preconditions.checkNotNull; | ||
| 23 | 24 | ||
| 24 | /** | 25 | /** |
| 25 | * Implementation of OCh port (Optical Channel). | 26 | * Implementation of OCh port (Optical Channel). |
| ... | @@ -33,38 +34,25 @@ public class OchPort extends DefaultPort { | ... | @@ -33,38 +34,25 @@ public class OchPort extends DefaultPort { |
| 33 | 34 | ||
| 34 | private final OduSignalType signalType; | 35 | private final OduSignalType signalType; |
| 35 | private final boolean isTunable; | 36 | private final boolean isTunable; |
| 36 | - private final GridType gridType; | 37 | + private final OchSignal lambda; |
| 37 | - private final ChannelSpacing channelSpacing; | ||
| 38 | - // Frequency = 193.1 THz + spacingMultiplier * channelSpacing | ||
| 39 | - private final int spacingMultiplier; | ||
| 40 | - // Slot width = slotGranularity * 12.5 GHz | ||
| 41 | - private final int slotGranularity; | ||
| 42 | - | ||
| 43 | 38 | ||
| 44 | /** | 39 | /** |
| 45 | * Creates an OCh port in the specified network element. | 40 | * Creates an OCh port in the specified network element. |
| 46 | * | 41 | * |
| 47 | - * @param element parent network element | 42 | + * @param element parent network element |
| 48 | - * @param number port number | 43 | + * @param number port number |
| 49 | - * @param isEnabled port enabled state | 44 | + * @param isEnabled port enabled state |
| 50 | - * @param signalType ODU signal type | 45 | + * @param signalType ODU signal type |
| 51 | - * @param isTunable maximum frequency in MHz | 46 | + * @param isTunable maximum frequency in MHz |
| 52 | - * @param gridType grid type | 47 | + * @param lambda OCh signal |
| 53 | - * @param channelSpacing channel spacing | 48 | + * @param annotations optional key/value annotations |
| 54 | - * @param spacingMultiplier channel spacing multiplier | ||
| 55 | - * @param slotGranularity slot width granularity | ||
| 56 | - * @param annotations optional key/value annotations | ||
| 57 | */ | 49 | */ |
| 58 | public OchPort(Element element, PortNumber number, boolean isEnabled, OduSignalType signalType, | 50 | public OchPort(Element element, PortNumber number, boolean isEnabled, OduSignalType signalType, |
| 59 | - boolean isTunable, GridType gridType, ChannelSpacing channelSpacing, | 51 | + boolean isTunable, OchSignal lambda, Annotations... annotations) { |
| 60 | - int spacingMultiplier, int slotGranularity, Annotations... annotations) { | ||
| 61 | super(element, number, isEnabled, Type.OCH, 0, annotations); | 52 | super(element, number, isEnabled, Type.OCH, 0, annotations); |
| 62 | this.signalType = signalType; | 53 | this.signalType = signalType; |
| 63 | this.isTunable = isTunable; | 54 | this.isTunable = isTunable; |
| 64 | - this.gridType = gridType; | 55 | + this.lambda = checkNotNull(lambda); |
| 65 | - this.channelSpacing = channelSpacing; | ||
| 66 | - this.spacingMultiplier = spacingMultiplier; | ||
| 67 | - this.slotGranularity = slotGranularity; | ||
| 68 | } | 56 | } |
| 69 | 57 | ||
| 70 | /** | 58 | /** |
| ... | @@ -86,63 +74,17 @@ public class OchPort extends DefaultPort { | ... | @@ -86,63 +74,17 @@ public class OchPort extends DefaultPort { |
| 86 | } | 74 | } |
| 87 | 75 | ||
| 88 | /** | 76 | /** |
| 89 | - * Returns grid type. | 77 | + * Returns OCh signal. |
| 90 | - * | ||
| 91 | - * @return grid type | ||
| 92 | - */ | ||
| 93 | - public GridType gridType() { | ||
| 94 | - return gridType; | ||
| 95 | - } | ||
| 96 | - | ||
| 97 | - /** | ||
| 98 | - * Returns channel spacing. | ||
| 99 | - * | ||
| 100 | - * @return channel spacing | ||
| 101 | - */ | ||
| 102 | - public ChannelSpacing channelSpacing() { | ||
| 103 | - return channelSpacing; | ||
| 104 | - } | ||
| 105 | - | ||
| 106 | - /** | ||
| 107 | - * Returns spacing multiplier. | ||
| 108 | - * | ||
| 109 | - * @return spacing multiplier | ||
| 110 | - */ | ||
| 111 | - public int spacingMultiplier() { | ||
| 112 | - return spacingMultiplier; | ||
| 113 | - } | ||
| 114 | - | ||
| 115 | - /** | ||
| 116 | - * Returns slow width granularity. | ||
| 117 | - * | ||
| 118 | - * @return slow width granularity | ||
| 119 | - */ | ||
| 120 | - public int slotGranularity() { | ||
| 121 | - return slotGranularity; | ||
| 122 | - } | ||
| 123 | - | ||
| 124 | - /** | ||
| 125 | - * Returns central frequency in MHz. | ||
| 126 | - * | ||
| 127 | - * @return frequency in MHz | ||
| 128 | - */ | ||
| 129 | - public Frequency centralFrequency() { | ||
| 130 | - return CENTER_FREQUENCY.add(channelSpacing().frequency().multiply(spacingMultiplier)); | ||
| 131 | - } | ||
| 132 | - | ||
| 133 | - /** | ||
| 134 | - * Returns slot width. | ||
| 135 | * | 78 | * |
| 136 | - * @return slot width | 79 | + * @return OCh signal |
| 137 | */ | 80 | */ |
| 138 | - public Frequency slotWidth() { | 81 | + public OchSignal lambda() { |
| 139 | - return FLEX_GRID_SLOT.multiply(slotGranularity); | 82 | + return lambda; |
| 140 | } | 83 | } |
| 141 | 84 | ||
| 142 | @Override | 85 | @Override |
| 143 | public int hashCode() { | 86 | public int hashCode() { |
| 144 | - return Objects.hash(number(), isEnabled(), type(), signalType, isTunable, | 87 | + return Objects.hash(number(), isEnabled(), type(), signalType, isTunable, lambda, annotations()); |
| 145 | - gridType, channelSpacing, spacingMultiplier, slotGranularity, annotations()); | ||
| 146 | } | 88 | } |
| 147 | 89 | ||
| 148 | @Override | 90 | @Override |
| ... | @@ -157,10 +99,7 @@ public class OchPort extends DefaultPort { | ... | @@ -157,10 +99,7 @@ public class OchPort extends DefaultPort { |
| 157 | Objects.equals(this.isEnabled(), other.isEnabled()) && | 99 | Objects.equals(this.isEnabled(), other.isEnabled()) && |
| 158 | Objects.equals(this.signalType, other.signalType) && | 100 | Objects.equals(this.signalType, other.signalType) && |
| 159 | Objects.equals(this.isTunable, other.isTunable) && | 101 | Objects.equals(this.isTunable, other.isTunable) && |
| 160 | - Objects.equals(this.gridType, other.gridType) && | 102 | + Objects.equals(this.lambda, other.lambda) && |
| 161 | - Objects.equals(this.channelSpacing, other.channelSpacing) && | ||
| 162 | - Objects.equals(this.spacingMultiplier, other.spacingMultiplier) && | ||
| 163 | - Objects.equals(this.slotGranularity, other.slotGranularity) && | ||
| 164 | Objects.equals(this.annotations(), other.annotations()); | 103 | Objects.equals(this.annotations(), other.annotations()); |
| 165 | } | 104 | } |
| 166 | return false; | 105 | return false; |
| ... | @@ -175,10 +114,7 @@ public class OchPort extends DefaultPort { | ... | @@ -175,10 +114,7 @@ public class OchPort extends DefaultPort { |
| 175 | .add("type", type()) | 114 | .add("type", type()) |
| 176 | .add("signalType", signalType) | 115 | .add("signalType", signalType) |
| 177 | .add("isTunable", isTunable) | 116 | .add("isTunable", isTunable) |
| 178 | - .add("gridType", gridType) | 117 | + .add("lambda", lambda) |
| 179 | - .add("channelSpacing", channelSpacing) | ||
| 180 | - .add("spacingMultiplier", spacingMultiplier) | ||
| 181 | - .add("slotGranularity", slotGranularity) | ||
| 182 | .toString(); | 118 | .toString(); |
| 183 | } | 119 | } |
| 184 | } | 120 | } | ... | ... |
| ... | @@ -16,13 +16,14 @@ | ... | @@ -16,13 +16,14 @@ |
| 16 | package org.onosproject.net.device; | 16 | package org.onosproject.net.device; |
| 17 | 17 | ||
| 18 | import com.google.common.base.MoreObjects; | 18 | import com.google.common.base.MoreObjects; |
| 19 | -import org.onosproject.net.ChannelSpacing; | 19 | +import org.onosproject.net.OchSignal; |
| 20 | -import org.onosproject.net.GridType; | 20 | +import org.onosproject.net.OduSignalType; |
| 21 | import org.onosproject.net.Port; | 21 | import org.onosproject.net.Port; |
| 22 | import org.onosproject.net.PortNumber; | 22 | import org.onosproject.net.PortNumber; |
| 23 | -import org.onosproject.net.OduSignalType; | ||
| 24 | import org.onosproject.net.SparseAnnotations; | 23 | import org.onosproject.net.SparseAnnotations; |
| 25 | 24 | ||
| 25 | +import static com.google.common.base.Preconditions.checkNotNull; | ||
| 26 | + | ||
| 26 | /** | 27 | /** |
| 27 | * Default implementation of immutable OCh port description. | 28 | * Default implementation of immutable OCh port description. |
| 28 | */ | 29 | */ |
| ... | @@ -30,61 +31,41 @@ public class OchPortDescription extends DefaultPortDescription { | ... | @@ -30,61 +31,41 @@ public class OchPortDescription extends DefaultPortDescription { |
| 30 | 31 | ||
| 31 | private final OduSignalType signalType; | 32 | private final OduSignalType signalType; |
| 32 | private final boolean isTunable; | 33 | private final boolean isTunable; |
| 33 | - private final GridType gridType; | 34 | + private final OchSignal lambda; |
| 34 | - private final ChannelSpacing channelSpacing; | ||
| 35 | - // Frequency = 193.1 THz + spacingMultiplier * channelSpacing | ||
| 36 | - private final int spacingMultiplier; | ||
| 37 | - // Slot width = slotGranularity * 12.5 GHz | ||
| 38 | - private final int slotGranularity; | ||
| 39 | 35 | ||
| 40 | /** | 36 | /** |
| 41 | * Creates OCH port description based on the supplied information. | 37 | * Creates OCH port description based on the supplied information. |
| 42 | * | 38 | * |
| 43 | - * @param number port number | 39 | + * @param number port number |
| 44 | - * @param isEnabled port enabled state | 40 | + * @param isEnabled port enabled state |
| 45 | - * @param signalType ODU signal type | 41 | + * @param signalType ODU signal type |
| 46 | - * @param isTunable tunable wavelength capability | 42 | + * @param isTunable tunable wavelength capability |
| 47 | - * @param gridType grid type | 43 | + * @param lambda Och signal |
| 48 | - * @param channelSpacing channel spacing | 44 | + * @param annotations optional key/value annotations map |
| 49 | - * @param spacingMultiplier channel spacing multiplier | ||
| 50 | - * @param slotGranularity slow width granularity | ||
| 51 | - * @param annotations optional key/value annotations map | ||
| 52 | */ | 45 | */ |
| 53 | public OchPortDescription(PortNumber number, boolean isEnabled, OduSignalType signalType, | 46 | public OchPortDescription(PortNumber number, boolean isEnabled, OduSignalType signalType, |
| 54 | - boolean isTunable, GridType gridType, | 47 | + boolean isTunable, OchSignal lambda, SparseAnnotations... annotations) { |
| 55 | - ChannelSpacing channelSpacing, | ||
| 56 | - int spacingMultiplier, int slotGranularity, SparseAnnotations... annotations) { | ||
| 57 | super(number, isEnabled, Port.Type.OCH, 0, annotations); | 48 | super(number, isEnabled, Port.Type.OCH, 0, annotations); |
| 58 | this.signalType = signalType; | 49 | this.signalType = signalType; |
| 59 | this.isTunable = isTunable; | 50 | this.isTunable = isTunable; |
| 60 | - this.gridType = gridType; | 51 | + this.lambda = checkNotNull(lambda); |
| 61 | - this.channelSpacing = channelSpacing; | ||
| 62 | - this.spacingMultiplier = spacingMultiplier; | ||
| 63 | - this.slotGranularity = slotGranularity; | ||
| 64 | } | 52 | } |
| 65 | 53 | ||
| 66 | /** | 54 | /** |
| 67 | * Creates OCH port description based on the supplied information. | 55 | * Creates OCH port description based on the supplied information. |
| 68 | * | 56 | * |
| 69 | - * @param base PortDescription to get basic information from | 57 | + * @param base PortDescription to get basic information from |
| 70 | - * @param signalType ODU signal type | 58 | + * @param signalType ODU signal type |
| 71 | - * @param isTunable tunable wavelength capability | 59 | + * @param isTunable tunable wavelength capability |
| 72 | - * @param gridType grid type | 60 | + * @param lambda OCh signal |
| 73 | - * @param channelSpacing channel spacing | 61 | + * @param annotations optional key/value annotations map |
| 74 | - * @param spacingMultiplier channel spacing multiplier | ||
| 75 | - * @param slotGranularity slot width granularity | ||
| 76 | - * @param annotations optional key/value annotations map | ||
| 77 | */ | 62 | */ |
| 78 | public OchPortDescription(PortDescription base, OduSignalType signalType, boolean isTunable, | 63 | public OchPortDescription(PortDescription base, OduSignalType signalType, boolean isTunable, |
| 79 | - GridType gridType, ChannelSpacing channelSpacing, | 64 | + OchSignal lambda, SparseAnnotations annotations) { |
| 80 | - int spacingMultiplier, int slotGranularity, SparseAnnotations annotations) { | ||
| 81 | super(base, annotations); | 65 | super(base, annotations); |
| 82 | this.signalType = signalType; | 66 | this.signalType = signalType; |
| 83 | this.isTunable = isTunable; | 67 | this.isTunable = isTunable; |
| 84 | - this.gridType = gridType; | 68 | + this.lambda = checkNotNull(lambda); |
| 85 | - this.channelSpacing = channelSpacing; | ||
| 86 | - this.spacingMultiplier = spacingMultiplier; | ||
| 87 | - this.slotGranularity = slotGranularity; | ||
| 88 | } | 69 | } |
| 89 | 70 | ||
| 90 | /** | 71 | /** |
| ... | @@ -106,39 +87,12 @@ public class OchPortDescription extends DefaultPortDescription { | ... | @@ -106,39 +87,12 @@ public class OchPortDescription extends DefaultPortDescription { |
| 106 | } | 87 | } |
| 107 | 88 | ||
| 108 | /** | 89 | /** |
| 109 | - * Returns grid type. | 90 | + * Returns OCh signal. |
| 110 | - * | ||
| 111 | - * @return grid type | ||
| 112 | - */ | ||
| 113 | - public GridType gridType() { | ||
| 114 | - return gridType; | ||
| 115 | - } | ||
| 116 | - | ||
| 117 | - /** | ||
| 118 | - * Returns channel spacing. | ||
| 119 | - * | ||
| 120 | - * @return channel spacing | ||
| 121 | - */ | ||
| 122 | - public ChannelSpacing channelSpacing() { | ||
| 123 | - return channelSpacing; | ||
| 124 | - } | ||
| 125 | - | ||
| 126 | - /** | ||
| 127 | - * Returns channel spacing multiplier. | ||
| 128 | - * | ||
| 129 | - * @return channel spacing multiplier | ||
| 130 | - */ | ||
| 131 | - public int spacingMultiplier() { | ||
| 132 | - return spacingMultiplier; | ||
| 133 | - } | ||
| 134 | - | ||
| 135 | - /** | ||
| 136 | - * Returns slot width granularity. | ||
| 137 | * | 91 | * |
| 138 | - * @return slot width granularity | 92 | + * @return OCh signal |
| 139 | */ | 93 | */ |
| 140 | - public int slotGranularity() { | 94 | + public OchSignal lambda() { |
| 141 | - return slotGranularity; | 95 | + return lambda; |
| 142 | } | 96 | } |
| 143 | 97 | ||
| 144 | @Override | 98 | @Override |
| ... | @@ -149,10 +103,7 @@ public class OchPortDescription extends DefaultPortDescription { | ... | @@ -149,10 +103,7 @@ public class OchPortDescription extends DefaultPortDescription { |
| 149 | .add("type", type()) | 103 | .add("type", type()) |
| 150 | .add("signalType", signalType) | 104 | .add("signalType", signalType) |
| 151 | .add("isTunable", isTunable) | 105 | .add("isTunable", isTunable) |
| 152 | - .add("gridType", gridType) | 106 | + .add("lambda", lambda) |
| 153 | - .add("channelSpacing", channelSpacing) | ||
| 154 | - .add("spacingMultiplier", spacingMultiplier) | ||
| 155 | - .add("slotGranularity", slotGranularity) | ||
| 156 | .add("annotations", annotations()) | 107 | .add("annotations", annotations()) |
| 157 | .toString(); | 108 | .toString(); |
| 158 | } | 109 | } | ... | ... |
| ... | @@ -1035,8 +1035,7 @@ public class GossipDeviceStore | ... | @@ -1035,8 +1035,7 @@ public class GossipDeviceStore |
| 1035 | case OCH: | 1035 | case OCH: |
| 1036 | OchPortDescription ochPortDesc = (OchPortDescription) portDesc.value(); | 1036 | OchPortDescription ochPortDesc = (OchPortDescription) portDesc.value(); |
| 1037 | return new OchPort(device, number, isEnabled, ochPortDesc.signalType(), | 1037 | return new OchPort(device, number, isEnabled, ochPortDesc.signalType(), |
| 1038 | - ochPortDesc.isTunable(), ochPortDesc.gridType(), ochPortDesc.channelSpacing(), | 1038 | + ochPortDesc.isTunable(), ochPortDesc.lambda(), annotations); |
| 1039 | - ochPortDesc.spacingMultiplier(), ochPortDesc.slotGranularity(), annotations); | ||
| 1040 | case ODUCLT: | 1039 | case ODUCLT: |
| 1041 | OduCltPortDescription oduCltPortDesc = (OduCltPortDescription) portDesc.value(); | 1040 | OduCltPortDescription oduCltPortDesc = (OduCltPortDescription) portDesc.value(); |
| 1042 | return new OduCltPort(device, number, isEnabled, oduCltPortDesc.signalType(), annotations); | 1041 | return new OduCltPort(device, number, isEnabled, oduCltPortDesc.signalType(), annotations); | ... | ... |
| ... | @@ -44,6 +44,7 @@ import org.onosproject.net.Link; | ... | @@ -44,6 +44,7 @@ import org.onosproject.net.Link; |
| 44 | import org.onosproject.net.Link.Type; | 44 | import org.onosproject.net.Link.Type; |
| 45 | import org.onosproject.net.LinkKey; | 45 | import org.onosproject.net.LinkKey; |
| 46 | import org.onosproject.net.OchPort; | 46 | import org.onosproject.net.OchPort; |
| 47 | +import org.onosproject.net.OchSignal; | ||
| 47 | import org.onosproject.net.OduCltPort; | 48 | import org.onosproject.net.OduCltPort; |
| 48 | import org.onosproject.net.OmsPort; | 49 | import org.onosproject.net.OmsPort; |
| 49 | import org.onosproject.net.PortNumber; | 50 | import org.onosproject.net.PortNumber; |
| ... | @@ -121,6 +122,8 @@ public class KryoSerializerTest { | ... | @@ -121,6 +122,8 @@ public class KryoSerializerTest { |
| 121 | .remove("A1") | 122 | .remove("A1") |
| 122 | .set("B3", "b3") | 123 | .set("B3", "b3") |
| 123 | .build(); | 124 | .build(); |
| 125 | + private static final OchSignal OCH_SIGNAL1 = (OchSignal) org.onosproject.net.Lambda.ochSignal( | ||
| 126 | + GridType.DWDM, ChannelSpacing.CHL_100GHZ, -8, 4); | ||
| 124 | 127 | ||
| 125 | private KryoSerializer serializer; | 128 | private KryoSerializer serializer; |
| 126 | 129 | ||
| ... | @@ -193,10 +196,8 @@ public class KryoSerializerTest { | ... | @@ -193,10 +196,8 @@ public class KryoSerializerTest { |
| 193 | 196 | ||
| 194 | @Test | 197 | @Test |
| 195 | public void testOchPort() { | 198 | public void testOchPort() { |
| 196 | - testSerializedEquals(new OchPort(DEV1, P1, true, OduSignalType.ODU0, false, GridType.DWDM, | 199 | + testSerializedEquals(new OchPort(DEV1, P1, true, OduSignalType.ODU0, false, OCH_SIGNAL1)); |
| 197 | - ChannelSpacing.CHL_100GHZ, -8, 4)); | 200 | + testSerializedEquals(new OchPort(DEV1, P1, true, OduSignalType.ODU0, false, OCH_SIGNAL1, A1_2)); |
| 198 | - testSerializedEquals(new OchPort(DEV1, P1, true, OduSignalType.ODU0, false, GridType.DWDM, | ||
| 199 | - ChannelSpacing.CHL_100GHZ, -8, 4, A1_2)); | ||
| 200 | } | 201 | } |
| 201 | 202 | ||
| 202 | @Test | 203 | @Test | ... | ... |
-
Please register or login to post a comment