Marc De Leenheer
Committed by Gerrit Code Review

Generic ROADM port models and descriptions

Change-Id: I053d61c7a057d6298b7990373448df28b3aaa5a5
...@@ -38,6 +38,26 @@ public final class DefaultAnnotations implements SparseAnnotations { ...@@ -38,6 +38,26 @@ public final class DefaultAnnotations implements SparseAnnotations {
38 this.map = null; 38 this.map = null;
39 } 39 }
40 40
41 + @Override
42 + public boolean equals(Object o) {
43 + if (this == o) {
44 + return true;
45 + }
46 + if (o == null || getClass() != o.getClass()) {
47 + return false;
48 + }
49 +
50 + DefaultAnnotations that = (DefaultAnnotations) o;
51 +
52 + return Objects.equals(this.map, that.map);
53 +
54 + }
55 +
56 + @Override
57 + public int hashCode() {
58 + return Objects.hashCode(this.map);
59 + }
60 +
41 /** 61 /**
42 * Creates a new set of annotations using clone of the specified hash map. 62 * Creates a new set of annotations using clone of the specified hash map.
43 * 63 *
......
...@@ -54,7 +54,7 @@ public class DefaultDevice extends AbstractElement implements Device { ...@@ -54,7 +54,7 @@ public class DefaultDevice extends AbstractElement implements Device {
54 * @param hwVersion device HW version 54 * @param hwVersion device HW version
55 * @param swVersion device SW version 55 * @param swVersion device SW version
56 * @param serialNumber device serial number 56 * @param serialNumber device serial number
57 - * @param chassisId chasis id 57 + * @param chassisId chassis id
58 * @param annotations optional key/value annotations 58 * @param annotations optional key/value annotations
59 */ 59 */
60 public DefaultDevice(ProviderId providerId, DeviceId id, Type type, 60 public DefaultDevice(ProviderId providerId, DeviceId id, Type type,
......
...@@ -64,7 +64,6 @@ public class DefaultPort extends AbstractAnnotated implements Port { ...@@ -64,7 +64,6 @@ public class DefaultPort extends AbstractAnnotated implements Port {
64 this.isEnabled = isEnabled; 64 this.isEnabled = isEnabled;
65 this.type = type; 65 this.type = type;
66 this.portSpeed = portSpeed; 66 this.portSpeed = portSpeed;
67 -
68 } 67 }
69 68
70 @Override 69 @Override
...@@ -94,7 +93,7 @@ public class DefaultPort extends AbstractAnnotated implements Port { ...@@ -94,7 +93,7 @@ public class DefaultPort extends AbstractAnnotated implements Port {
94 93
95 @Override 94 @Override
96 public int hashCode() { 95 public int hashCode() {
97 - return Objects.hash(number, isEnabled, type, portSpeed); 96 + return Objects.hash(number, isEnabled, type, portSpeed, annotations());
98 } 97 }
99 98
100 @Override 99 @Override
...@@ -108,7 +107,8 @@ public class DefaultPort extends AbstractAnnotated implements Port { ...@@ -108,7 +107,8 @@ public class DefaultPort extends AbstractAnnotated implements Port {
108 Objects.equals(this.number, other.number) && 107 Objects.equals(this.number, other.number) &&
109 Objects.equals(this.isEnabled, other.isEnabled) && 108 Objects.equals(this.isEnabled, other.isEnabled) &&
110 Objects.equals(this.type, other.type) && 109 Objects.equals(this.type, other.type) &&
111 - Objects.equals(this.portSpeed, other.portSpeed); 110 + Objects.equals(this.portSpeed, other.portSpeed) &&
111 + Objects.equals(this.annotations(), other.annotations());
112 } 112 }
113 return false; 113 return false;
114 } 114 }
......
1 +/*
2 + * Copyright 2015 Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +package org.onosproject.net;
17 +
18 +import org.onlab.util.Frequency;
19 +
20 +import java.util.Objects;
21 +
22 +import static com.google.common.base.MoreObjects.toStringHelper;
23 +
24 +/**
25 + * Implementation of OCh port (Optical Channel).
26 + * Also referred to as a line side port (L-port) or narrow band port.
27 + * See ITU G.709 "Interfaces for the Optical Transport Network (OTN)"
28 + */
29 +public class OchPort extends DefaultPort {
30 +
31 + public static final Frequency CENTER_FREQUENCY = Frequency.ofTHz(193.1);
32 + public static final Frequency FLEX_GRID_SLOT = Frequency.ofGHz(12.5);
33 +
34 + public enum SignalType {
35 + ODU0,
36 + ODU1,
37 + ODU2,
38 + ODU2e,
39 + ODU3,
40 + ODU4
41 + }
42 +
43 + public enum GridType {
44 + RES, // ??
45 + DWDM, // Dense Wavelength Division Multiplexing
46 + CWDM, // Coarse WDM
47 + FLEX // Flex Grid
48 + }
49 +
50 + public enum ChannelSpacing {
51 + CHL_100GHZ(100), // 100 GHz
52 + CHL_50GHZ(50), // 50 GHz
53 + CHL_25GHZ(25), // 25 GHz
54 + CHL_12P5GHZ(12.5), // 12.5 GHz
55 + CHL_6P25GHZ(6.5); // 6.25 GHz
56 +
57 + private final Frequency frequency;
58 +
59 + ChannelSpacing(double value) {
60 + this.frequency = Frequency.ofGHz(value);
61 + }
62 +
63 + public Frequency frequency() {
64 + return frequency;
65 + }
66 + }
67 +
68 + private final SignalType signalType;
69 + private final boolean isTunable;
70 + private final GridType gridType;
71 + private final ChannelSpacing channelSpacing;
72 + // Frequency = 193.1 THz + spacingMultiplier * channelSpacing
73 + private final int spacingMultiplier;
74 + // Slot width = slotGranularity * 12.5 GHz
75 + private final int slotGranularity;
76 +
77 +
78 + /**
79 + * Creates an OCh port in the specified network element.
80 + *
81 + * @param element parent network element
82 + * @param number port number
83 + * @param isEnabled port enabled state
84 + * @param signalType ODU signal type
85 + * @param isTunable maximum frequency in MHz
86 + * @param gridType grid type
87 + * @param channelSpacing channel spacing
88 + * @param spacingMultiplier channel spacing multiplier
89 + * @param slotGranularity slot width granularity
90 + * @param annotations optional key/value annotations
91 + */
92 + public OchPort(Element element, PortNumber number, boolean isEnabled, SignalType signalType,
93 + boolean isTunable, GridType gridType, ChannelSpacing channelSpacing,
94 + int spacingMultiplier, int slotGranularity, Annotations... annotations) {
95 + super(element, number, isEnabled, Type.OCH, 0, annotations);
96 + this.signalType = signalType;
97 + this.isTunable = isTunable;
98 + this.gridType = gridType;
99 + this.channelSpacing = channelSpacing;
100 + this.spacingMultiplier = spacingMultiplier;
101 + this.slotGranularity = slotGranularity;
102 + }
103 +
104 + /**
105 + * Returns ODU signal type.
106 + *
107 + * @return ODU signal type
108 + */
109 + public SignalType signalType() {
110 + return signalType;
111 + }
112 +
113 + /**
114 + * Returns true if port is wavelength tunable.
115 + *
116 + * @return tunable wavelength capability
117 + */
118 + public boolean isTunable() {
119 + return isTunable;
120 + }
121 +
122 + /**
123 + * Returns grid type.
124 + *
125 + * @return grid type
126 + */
127 + public GridType gridType() {
128 + return gridType;
129 + }
130 +
131 + /**
132 + * Returns channel spacing.
133 + *
134 + * @return channel spacing
135 + */
136 + public ChannelSpacing channelSpacing() {
137 + return channelSpacing;
138 + }
139 +
140 + /**
141 + * Returns spacing multiplier.
142 + *
143 + * @return spacing multiplier
144 + */
145 + public int spacingMultiplier() {
146 + return spacingMultiplier;
147 + }
148 +
149 + /**
150 + * Returns slow width granularity.
151 + *
152 + * @return slow width granularity
153 + */
154 + public int slotGranularity() {
155 + return slotGranularity;
156 + }
157 +
158 + /**
159 + * Returns central frequency in MHz.
160 + *
161 + * @return frequency in MHz
162 + */
163 + public Frequency centralFrequency() {
164 + return CENTER_FREQUENCY.add(channelSpacing().frequency().multiply(spacingMultiplier));
165 + }
166 +
167 + /**
168 + * Returns slot width.
169 + *
170 + * @return slot width
171 + */
172 + public Frequency slotWidth() {
173 + return FLEX_GRID_SLOT.multiply(slotGranularity);
174 + }
175 +
176 + @Override
177 + public int hashCode() {
178 + return Objects.hash(number(), isEnabled(), type(), signalType, isTunable,
179 + gridType, channelSpacing, spacingMultiplier, slotGranularity, annotations());
180 + }
181 +
182 + @Override
183 + public boolean equals(Object obj) {
184 + if (this == obj) {
185 + return true;
186 + }
187 + if (obj instanceof OchPort) {
188 + final OchPort other = (OchPort) obj;
189 + return Objects.equals(this.element().id(), other.element().id()) &&
190 + Objects.equals(this.number(), other.number()) &&
191 + Objects.equals(this.isEnabled(), other.isEnabled()) &&
192 + Objects.equals(this.signalType, other.signalType) &&
193 + Objects.equals(this.isTunable, other.isTunable) &&
194 + Objects.equals(this.gridType, other.gridType) &&
195 + Objects.equals(this.channelSpacing, other.channelSpacing) &&
196 + Objects.equals(this.spacingMultiplier, other.spacingMultiplier) &&
197 + Objects.equals(this.slotGranularity, other.slotGranularity) &&
198 + Objects.equals(this.annotations(), other.annotations());
199 + }
200 + return false;
201 + }
202 +
203 + @Override
204 + public String toString() {
205 + return toStringHelper(this)
206 + .add("element", element().id())
207 + .add("number", number())
208 + .add("isEnabled", isEnabled())
209 + .add("type", type())
210 + .add("signalType", signalType)
211 + .add("isTunable", isTunable)
212 + .add("gridType", gridType)
213 + .add("channelSpacing", channelSpacing)
214 + .add("spacingMultiplier", spacingMultiplier)
215 + .add("slotGranularity", slotGranularity)
216 + .toString();
217 + }
218 +}
1 +/*
2 + * Copyright 2015 Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +package org.onosproject.net;
17 +
18 +import java.util.Objects;
19 +
20 +import static com.google.common.base.MoreObjects.toStringHelper;
21 +
22 +/**
23 + * Implementation of ODU client port (Optical channel Data Unit).
24 + * Also referred to as a T-port or wide band port.
25 + * See ITU G.709 "Interfaces for the Optical Transport Network (OTN)"
26 + */
27 +
28 +public class OduCltPort extends DefaultPort {
29 +
30 + public enum SignalType {
31 + CLT_1GBE,
32 + CLT_10GBE,
33 + CLT_40GBE,
34 + CLT_100GBE
35 + }
36 +
37 + private final SignalType signalType;
38 +
39 +
40 + /**
41 + * Creates an ODU client port in the specified network element.
42 + *
43 + * @param element parent network element
44 + * @param number port number
45 + * @param isEnabled port enabled state
46 + * @param signalType ODU client signal type
47 + * @param annotations optional key/value annotations
48 + */
49 + public OduCltPort(Element element, PortNumber number, boolean isEnabled,
50 + SignalType signalType, Annotations... annotations) {
51 + super(element, number, isEnabled, Type.ODUCLT, 0, annotations);
52 + this.signalType = signalType;
53 + }
54 +
55 + /**
56 + * Returns ODU client signal type.
57 + *
58 + * @return ODU client signal type
59 + */
60 + public SignalType signalType() {
61 + return signalType;
62 + }
63 +
64 + @Override
65 + public int hashCode() {
66 + return Objects.hash(number(), isEnabled(), type(), signalType, annotations());
67 + }
68 +
69 + @Override
70 + public boolean equals(Object obj) {
71 + if (this == obj) {
72 + return true;
73 + }
74 + if (obj instanceof OduCltPort) {
75 + final OduCltPort other = (OduCltPort) obj;
76 + return Objects.equals(this.element().id(), other.element().id()) &&
77 + Objects.equals(this.number(), other.number()) &&
78 + Objects.equals(this.isEnabled(), other.isEnabled()) &&
79 + Objects.equals(this.signalType, other.signalType) &&
80 + Objects.equals(this.annotations(), other.annotations());
81 + }
82 + return false;
83 + }
84 +
85 +
86 + @Override
87 + public String toString() {
88 + return toStringHelper(this)
89 + .add("element", element().id())
90 + .add("number", number())
91 + .add("isEnabled", isEnabled())
92 + .add("type", type())
93 + .add("signalType", signalType)
94 + .toString();
95 + }
96 +
97 +}
1 +/*
2 + * Copyright 2015 Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +package org.onosproject.net;
17 +
18 +import org.onlab.util.Frequency;
19 +
20 +import java.util.Objects;
21 +
22 +import static com.google.common.base.MoreObjects.toStringHelper;
23 +
24 +/**
25 + * Implementation of OMS port (Optical Multiplexing Section).
26 + * Also referred to as a WDM port or W-port.
27 + * See ITU G.709 "Interfaces for the Optical Transport Network (OTN)"
28 + *
29 + * Assumes we only support fixed grid for now.
30 + */
31 +public class OmsPort extends DefaultPort {
32 +
33 + private final Frequency minFrequency; // Minimum frequency
34 + private final Frequency maxFrequency; // Maximum frequency
35 + private final Frequency grid; // Grid spacing frequency
36 +
37 +
38 + /**
39 + * Creates an OMS port in the specified network element.
40 + *
41 + * @param element parent network element
42 + * @param number port number
43 + * @param isEnabled port enabled state
44 + * @param minFrequency minimum frequency
45 + * @param maxFrequency maximum frequency
46 + * @param grid grid spacing frequency
47 + * @param annotations optional key/value annotations
48 + */
49 + public OmsPort(Element element, PortNumber number, boolean isEnabled,
50 + Frequency minFrequency, Frequency maxFrequency, Frequency grid, Annotations... annotations) {
51 + super(element, number, isEnabled, Type.OMS, 0, annotations);
52 + this.minFrequency = minFrequency;
53 + this.maxFrequency = maxFrequency;
54 + this.grid = grid;
55 + }
56 +
57 + /**
58 + * Returns the total number of channels on the port.
59 + *
60 + * @return total number of channels
61 + */
62 + public short totalChannels() {
63 + Frequency diff = maxFrequency.subtract(minFrequency);
64 + return (short) (diff.asHz() / (grid.asHz() + 1));
65 + }
66 +
67 + /**
68 + * Returns the minimum frequency.
69 + *
70 + * @return minimum frequency
71 + */
72 + public Frequency minFrequency() {
73 + return minFrequency;
74 + }
75 +
76 + /**
77 + * Returns the maximum frequency.
78 + *
79 + * @return maximum frequency
80 + */
81 + public Frequency maxFrequency() {
82 + return maxFrequency;
83 + }
84 +
85 + /**
86 + * Returns the grid spacing frequency.
87 + *
88 + * @return grid spacing frequency
89 + */
90 + public Frequency grid() {
91 + return grid;
92 + }
93 +
94 + @Override
95 + public int hashCode() {
96 + return Objects.hash(number(), isEnabled(), type(),
97 + minFrequency, maxFrequency, grid, annotations());
98 + }
99 +
100 + @Override
101 + public boolean equals(Object obj) {
102 + if (this == obj) {
103 + return true;
104 + }
105 + if (obj instanceof OmsPort) {
106 + final OmsPort other = (OmsPort) obj;
107 + return Objects.equals(this.element().id(), other.element().id()) &&
108 + Objects.equals(this.number(), other.number()) &&
109 + Objects.equals(this.isEnabled(), other.isEnabled()) &&
110 + Objects.equals(this.minFrequency, other.minFrequency) &&
111 + Objects.equals(this.maxFrequency, other.maxFrequency) &&
112 + Objects.equals(this.grid, other.grid) &&
113 + Objects.equals(this.annotations(), other.annotations());
114 + }
115 + return false;
116 + }
117 +
118 + @Override
119 + public String toString() {
120 + return toStringHelper(this)
121 + .add("element", element().id())
122 + .add("number", number())
123 + .add("isEnabled", isEnabled())
124 + .add("type", type())
125 + .add("minFrequency", minFrequency)
126 + .add("maxFrequency", maxFrequency)
127 + .add("grid", grid)
128 + .toString();
129 + }
130 +
131 +}
...@@ -54,7 +54,6 @@ public interface Port extends Annotated { ...@@ -54,7 +54,6 @@ public interface Port extends Annotated {
54 * Optical Multiplexing Section (See ITU G.709). 54 * Optical Multiplexing Section (See ITU G.709).
55 */ 55 */
56 OMS 56 OMS
57 -
58 } 57 }
59 58
60 /** 59 /**
......
...@@ -34,7 +34,7 @@ public interface SparseAnnotations extends Annotations { ...@@ -34,7 +34,7 @@ public interface SparseAnnotations extends Annotations {
34 34
35 /** 35 /**
36 * Indicates whether the specified key has been tagged as removed. This is 36 * Indicates whether the specified key has been tagged as removed. This is
37 - * used to for merging sparse annotation sets. 37 + * used for merging sparse annotation sets.
38 * 38 *
39 * @param key annotation key 39 * @param key annotation key
40 * @return true if the previous annotation has been tagged for removal 40 * @return true if the previous annotation has been tagged for removal
......
1 +/*
2 + * Copyright 2015 Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +package org.onosproject.net.device;
17 +
18 +import com.google.common.base.MoreObjects;
19 +import org.onosproject.net.OchPort;
20 +import org.onosproject.net.Port;
21 +import org.onosproject.net.PortNumber;
22 +import org.onosproject.net.SparseAnnotations;
23 +
24 +/**
25 + * Default implementation of immutable OCh port description.
26 + */
27 +public class OchPortDescription extends DefaultPortDescription {
28 +
29 + private final OchPort.SignalType signalType;
30 + private final boolean isTunable;
31 + private final OchPort.GridType gridType;
32 + private final OchPort.ChannelSpacing channelSpacing;
33 + // Frequency = 193.1 THz + spacingMultiplier * channelSpacing
34 + private final int spacingMultiplier;
35 + // Slot width = slotGranularity * 12.5 GHz
36 + private final int slotGranularity;
37 +
38 + /**
39 + * Creates OCH port description based on the supplied information.
40 + *
41 + * @param number port number
42 + * @param isEnabled port enabled state
43 + * @param signalType ODU signal type
44 + * @param isTunable tunable wavelength capability
45 + * @param gridType grid type
46 + * @param channelSpacing channel spacing
47 + * @param spacingMultiplier channel spacing multiplier
48 + * @param slotGranularity slow width granularity
49 + * @param annotations optional key/value annotations map
50 + */
51 + public OchPortDescription(PortNumber number, boolean isEnabled, OchPort.SignalType signalType,
52 + boolean isTunable, OchPort.GridType gridType,
53 + OchPort.ChannelSpacing channelSpacing,
54 + int spacingMultiplier, int slotGranularity, SparseAnnotations... annotations) {
55 + super(number, isEnabled, Port.Type.OCH, 0, annotations);
56 + this.signalType = signalType;
57 + this.isTunable = isTunable;
58 + this.gridType = gridType;
59 + this.channelSpacing = channelSpacing;
60 + this.spacingMultiplier = spacingMultiplier;
61 + this.slotGranularity = slotGranularity;
62 + }
63 +
64 + /**
65 + * Creates OCH port description based on the supplied information.
66 + *
67 + * @param base PortDescription to get basic information from
68 + * @param signalType ODU signal type
69 + * @param isTunable tunable wavelength capability
70 + * @param gridType grid type
71 + * @param channelSpacing channel spacing
72 + * @param spacingMultiplier channel spacing multiplier
73 + * @param slotGranularity slot width granularity
74 + * @param annotations optional key/value annotations map
75 + */
76 + public OchPortDescription(PortDescription base, OchPort.SignalType signalType, boolean isTunable,
77 + OchPort.GridType gridType, OchPort.ChannelSpacing channelSpacing,
78 + int spacingMultiplier, int slotGranularity, SparseAnnotations annotations) {
79 + super(base, annotations);
80 + this.signalType = signalType;
81 + this.isTunable = isTunable;
82 + this.gridType = gridType;
83 + this.channelSpacing = channelSpacing;
84 + this.spacingMultiplier = spacingMultiplier;
85 + this.slotGranularity = slotGranularity;
86 + }
87 +
88 + /**
89 + * Returns ODU signal type.
90 + *
91 + * @return ODU signal type
92 + */
93 + public OchPort.SignalType signalType() {
94 + return signalType;
95 + }
96 +
97 + /**
98 + * Returns true if port is wavelength tunable.
99 + *
100 + * @return tunable wavelength capability
101 + */
102 + public boolean isTunable() {
103 + return isTunable;
104 + }
105 +
106 + /**
107 + * Returns grid type.
108 + *
109 + * @return grid type
110 + */
111 + public OchPort.GridType gridType() {
112 + return gridType;
113 + }
114 +
115 + /**
116 + * Returns channel spacing.
117 + *
118 + * @return channel spacing
119 + */
120 + public OchPort.ChannelSpacing channelSpacing() {
121 + return channelSpacing;
122 + }
123 +
124 + /**
125 + * Returns channel spacing multiplier.
126 + *
127 + * @return channel spacing multiplier
128 + */
129 + public int spacingMultiplier() {
130 + return spacingMultiplier;
131 + }
132 +
133 + /**
134 + * Returns slot width granularity.
135 + *
136 + * @return slot width granularity
137 + */
138 + public int slotGranularity() {
139 + return slotGranularity;
140 + }
141 +
142 + @Override
143 + public String toString() {
144 + return MoreObjects.toStringHelper(getClass())
145 + .add("number", portNumber())
146 + .add("isEnabled", isEnabled())
147 + .add("type", type())
148 + .add("signalType", signalType)
149 + .add("isTunable", isTunable)
150 + .add("gridType", gridType)
151 + .add("channelSpacing", channelSpacing)
152 + .add("spacingMultiplier", spacingMultiplier)
153 + .add("slotGranularity", slotGranularity)
154 + .add("annotations", annotations())
155 + .toString();
156 + }
157 +
158 +}
1 +/*
2 + * Copyright 2015 Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +package org.onosproject.net.device;
17 +
18 +import com.google.common.base.MoreObjects;
19 +import org.onosproject.net.OduCltPort;
20 +import org.onosproject.net.Port;
21 +import org.onosproject.net.PortNumber;
22 +import org.onosproject.net.SparseAnnotations;
23 +
24 +/**
25 + * Default implementation of immutable ODU client port description.
26 + */
27 +public class OduCltPortDescription extends DefaultPortDescription {
28 +
29 + private final OduCltPort.SignalType signalType;
30 +
31 + /**
32 + * Creates ODU client port description based on the supplied information.
33 + *
34 + * @param number port number
35 + * @param isEnabled port enabled state
36 + * @param signalType ODU client signal type
37 + * @param annotations optional key/value annotations map
38 + */
39 + public OduCltPortDescription(PortNumber number, boolean isEnabled, OduCltPort.SignalType signalType,
40 + SparseAnnotations... annotations) {
41 + super(number, isEnabled, Port.Type.ODUCLT, 0, annotations);
42 + this.signalType = signalType;
43 + }
44 +
45 + /**
46 + * Creates ODU client port description based on the supplied information.
47 + *
48 + * @param base PortDescription to get basic information from
49 + * @param signalType ODU client signal type
50 + * @param annotations optional key/value annotations map
51 + */
52 + public OduCltPortDescription(PortDescription base, OduCltPort.SignalType signalType,
53 + SparseAnnotations annotations) {
54 + super(base, annotations);
55 + this.signalType = signalType;
56 + }
57 +
58 + /**
59 + * Returns ODU client signal type.
60 + *
61 + * @return ODU client signal type
62 + */
63 + public OduCltPort.SignalType signalType() {
64 + return signalType;
65 + }
66 +
67 + @Override
68 + public String toString() {
69 + return MoreObjects.toStringHelper(getClass())
70 + .add("number", portNumber())
71 + .add("isEnabled", isEnabled())
72 + .add("type", type())
73 + .add("signalType", signalType)
74 + .toString();
75 + }
76 +
77 +}
1 +/*
2 + * Copyright 2015 Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +package org.onosproject.net.device;
17 +
18 +import com.google.common.base.MoreObjects;
19 +import org.onlab.util.Frequency;
20 +import org.onosproject.net.Port;
21 +import org.onosproject.net.PortNumber;
22 +import org.onosproject.net.SparseAnnotations;
23 +
24 +/**
25 + * Default implementation of immutable OMS port description.
26 + */
27 +public class OmsPortDescription extends DefaultPortDescription {
28 +
29 + private final Frequency minFrequency;
30 + private final Frequency maxFrequency;
31 + private final Frequency grid;
32 +
33 + /**
34 + * Creates OMS port description based on the supplied information.
35 + *
36 + * @param number port number
37 + * @param isEnabled port enabled state
38 + * @param minFrequency minimum frequency
39 + * @param maxFrequency maximum frequency
40 + * @param grid grid spacing frequency
41 + * @param annotations optional key/value annotations map
42 + */
43 + public OmsPortDescription(PortNumber number, boolean isEnabled, Frequency minFrequency, Frequency maxFrequency,
44 + Frequency grid, SparseAnnotations... annotations) {
45 + super(number, isEnabled, Port.Type.OMS, 0, annotations);
46 + this.minFrequency = minFrequency;
47 + this.maxFrequency = maxFrequency;
48 + this.grid = grid;
49 + }
50 +
51 + /**
52 + * Creates OMS port description based on the supplied information.
53 + *
54 + * @param base PortDescription to get basic information from
55 + * @param minFrequency minimum frequency
56 + * @param maxFrequency maximum frequency
57 + * @param grid grid spacing frequency
58 + * @param annotations optional key/value annotations map
59 + */
60 + public OmsPortDescription(PortDescription base, Frequency minFrequency, Frequency maxFrequency,
61 + Frequency grid, SparseAnnotations annotations) {
62 + super(base, annotations);
63 + this.minFrequency = minFrequency;
64 + this.maxFrequency = maxFrequency;
65 + this.grid = grid;
66 + }
67 +
68 + /**
69 + * Returns minimum frequency.
70 + *
71 + * @return minimum frequency
72 + */
73 + public Frequency minFrequency() {
74 + return minFrequency;
75 + }
76 +
77 + /**
78 + * Returns maximum frequency.
79 + *
80 + * @return maximum frequency
81 + */
82 + public Frequency maxFrequency() {
83 + return maxFrequency;
84 + }
85 +
86 + /**
87 + * Returns grid spacing frequency.
88 + *
89 + * @return grid spacing frequency
90 + */
91 + public Frequency grid() {
92 + return grid;
93 + }
94 +
95 + @Override
96 + public String toString() {
97 + return MoreObjects.toStringHelper(getClass())
98 + .add("number", portNumber())
99 + .add("isEnabled", isEnabled())
100 + .add("type", type())
101 + .add("minFrequency", minFrequency)
102 + .add("maxFrequency", maxFrequency)
103 + .add("grid", grid)
104 + .add("annotations", annotations())
105 + .toString();
106 + }
107 +
108 +}
109 +
...@@ -15,8 +15,10 @@ ...@@ -15,8 +15,10 @@
15 */ 15 */
16 package org.onosproject.store.serializers; 16 package org.onosproject.store.serializers;
17 17
18 +import org.onosproject.net.Annotations;
18 import org.onosproject.net.DefaultPort; 19 import org.onosproject.net.DefaultPort;
19 import org.onosproject.net.Element; 20 import org.onosproject.net.Element;
21 +import org.onosproject.net.Port;
20 import org.onosproject.net.PortNumber; 22 import org.onosproject.net.PortNumber;
21 23
22 import com.esotericsoftware.kryo.Kryo; 24 import com.esotericsoftware.kryo.Kryo;
...@@ -43,15 +45,21 @@ public final class DefaultPortSerializer extends ...@@ -43,15 +45,21 @@ public final class DefaultPortSerializer extends
43 kryo.writeClassAndObject(output, object.element()); 45 kryo.writeClassAndObject(output, object.element());
44 kryo.writeObject(output, object.number()); 46 kryo.writeObject(output, object.number());
45 output.writeBoolean(object.isEnabled()); 47 output.writeBoolean(object.isEnabled());
48 + kryo.writeObject(output, object.type());
49 + output.writeLong(object.portSpeed());
50 + kryo.writeClassAndObject(output, object.annotations());
46 } 51 }
47 52
48 @Override 53 @Override
49 - public DefaultPort read(Kryo kryo, Input input, 54 + public DefaultPort read(Kryo kryo, Input input, Class<DefaultPort> aClass) {
50 - Class<DefaultPort> type) {
51 Element element = (Element) kryo.readClassAndObject(input); 55 Element element = (Element) kryo.readClassAndObject(input);
52 PortNumber number = kryo.readObject(input, PortNumber.class); 56 PortNumber number = kryo.readObject(input, PortNumber.class);
53 boolean isEnabled = input.readBoolean(); 57 boolean isEnabled = input.readBoolean();
58 + Port.Type type = kryo.readObject(input, Port.Type.class);
59 + long portSpeed = input.readLong();
60 + Annotations annotations = (Annotations) kryo.readClassAndObject(input);
54 61
55 - return new DefaultPort(element, number, isEnabled); 62 + return new DefaultPort(element, number, isEnabled, type, portSpeed, annotations);
56 } 63 }
64 +
57 } 65 }
......
...@@ -28,6 +28,7 @@ import org.onlab.packet.IpAddress; ...@@ -28,6 +28,7 @@ import org.onlab.packet.IpAddress;
28 import org.onlab.packet.IpPrefix; 28 import org.onlab.packet.IpPrefix;
29 import org.onlab.packet.MacAddress; 29 import org.onlab.packet.MacAddress;
30 import org.onlab.packet.VlanId; 30 import org.onlab.packet.VlanId;
31 +import org.onlab.util.Frequency;
31 import org.onlab.util.KryoNamespace; 32 import org.onlab.util.KryoNamespace;
32 import org.onosproject.app.ApplicationState; 33 import org.onosproject.app.ApplicationState;
33 import org.onosproject.cluster.ControllerNode; 34 import org.onosproject.cluster.ControllerNode;
...@@ -41,6 +42,7 @@ import org.onosproject.core.DefaultApplicationId; ...@@ -41,6 +42,7 @@ import org.onosproject.core.DefaultApplicationId;
41 import org.onosproject.core.DefaultGroupId; 42 import org.onosproject.core.DefaultGroupId;
42 import org.onosproject.core.Version; 43 import org.onosproject.core.Version;
43 import org.onosproject.mastership.MastershipTerm; 44 import org.onosproject.mastership.MastershipTerm;
45 +import org.onosproject.net.Annotations;
44 import org.onosproject.net.ConnectPoint; 46 import org.onosproject.net.ConnectPoint;
45 import org.onosproject.net.DefaultAnnotations; 47 import org.onosproject.net.DefaultAnnotations;
46 import org.onosproject.net.DefaultDevice; 48 import org.onosproject.net.DefaultDevice;
...@@ -55,6 +57,9 @@ import org.onosproject.net.HostId; ...@@ -55,6 +57,9 @@ import org.onosproject.net.HostId;
55 import org.onosproject.net.HostLocation; 57 import org.onosproject.net.HostLocation;
56 import org.onosproject.net.Link; 58 import org.onosproject.net.Link;
57 import org.onosproject.net.LinkKey; 59 import org.onosproject.net.LinkKey;
60 +import org.onosproject.net.OchPort;
61 +import org.onosproject.net.OduCltPort;
62 +import org.onosproject.net.OmsPort;
58 import org.onosproject.net.Port; 63 import org.onosproject.net.Port;
59 import org.onosproject.net.PortNumber; 64 import org.onosproject.net.PortNumber;
60 import org.onosproject.net.device.DefaultDeviceDescription; 65 import org.onosproject.net.device.DefaultDeviceDescription;
...@@ -348,7 +353,9 @@ public final class KryoNamespaces { ...@@ -348,7 +353,9 @@ public final class KryoNamespaces {
348 AnnotationConstraint.class, 353 AnnotationConstraint.class,
349 BooleanConstraint.class, 354 BooleanConstraint.class,
350 IntentOperation.class, 355 IntentOperation.class,
351 - FlowRuleExtPayLoad.class 356 + FlowRuleExtPayLoad.class,
357 + Frequency.class,
358 + DefaultAnnotations.class
352 ) 359 )
353 .register(new DefaultApplicationIdSerializer(), DefaultApplicationId.class) 360 .register(new DefaultApplicationIdSerializer(), DefaultApplicationId.class)
354 .register(new URISerializer(), URI.class) 361 .register(new URISerializer(), URI.class)
...@@ -365,6 +372,14 @@ public final class KryoNamespaces { ...@@ -365,6 +372,14 @@ public final class KryoNamespaces {
365 .register(new DefaultOutboundPacketSerializer(), DefaultOutboundPacket.class) 372 .register(new DefaultOutboundPacketSerializer(), DefaultOutboundPacket.class)
366 .register(Versioned.class) 373 .register(Versioned.class)
367 .register(DefaultGroupId.class) 374 .register(DefaultGroupId.class)
375 + .register(Annotations.class)
376 + .register(OmsPort.class)
377 + .register(OchPort.class)
378 + .register(OchPort.SignalType.class)
379 + .register(OchPort.GridType.class)
380 + .register(OchPort.ChannelSpacing.class)
381 + .register(OduCltPort.class)
382 + .register(OduCltPort.SignalType.class)
368 .register( 383 .register(
369 MplsIntent.class, 384 MplsIntent.class,
370 MplsPathIntent.class, 385 MplsPathIntent.class,
......
...@@ -24,6 +24,7 @@ import org.junit.After; ...@@ -24,6 +24,7 @@ import org.junit.After;
24 import org.junit.Before; 24 import org.junit.Before;
25 import org.junit.BeforeClass; 25 import org.junit.BeforeClass;
26 import org.junit.Test; 26 import org.junit.Test;
27 +import org.onlab.util.Frequency;
27 import org.onosproject.cluster.NodeId; 28 import org.onosproject.cluster.NodeId;
28 import org.onosproject.cluster.RoleInfo; 29 import org.onosproject.cluster.RoleInfo;
29 import org.onosproject.core.DefaultGroupId; 30 import org.onosproject.core.DefaultGroupId;
...@@ -40,6 +41,9 @@ import org.onosproject.net.HostLocation; ...@@ -40,6 +41,9 @@ import org.onosproject.net.HostLocation;
40 import org.onosproject.net.Link; 41 import org.onosproject.net.Link;
41 import org.onosproject.net.Link.Type; 42 import org.onosproject.net.Link.Type;
42 import org.onosproject.net.LinkKey; 43 import org.onosproject.net.LinkKey;
44 +import org.onosproject.net.OchPort;
45 +import org.onosproject.net.OduCltPort;
46 +import org.onosproject.net.OmsPort;
43 import org.onosproject.net.PortNumber; 47 import org.onosproject.net.PortNumber;
44 import org.onosproject.net.SparseAnnotations; 48 import org.onosproject.net.SparseAnnotations;
45 import org.onosproject.net.flow.DefaultFlowRule; 49 import org.onosproject.net.flow.DefaultFlowRule;
...@@ -177,6 +181,28 @@ public class KryoSerializerTest { ...@@ -177,6 +181,28 @@ public class KryoSerializerTest {
177 } 181 }
178 182
179 @Test 183 @Test
184 + public void testOmsPort() {
185 + testSerializedEquals(new OmsPort(DEV1, P1, true, Frequency.ofGHz(190_100), Frequency.ofGHz(197_300),
186 + Frequency.ofGHz(100)));
187 + testSerializedEquals(new OmsPort(DEV1, P1, true, Frequency.ofGHz(190_100), Frequency.ofGHz(197_300),
188 + Frequency.ofGHz(100), A1_2));
189 + }
190 +
191 + @Test
192 + public void testOchPort() {
193 + testSerializedEquals(new OchPort(DEV1, P1, true, OchPort.SignalType.ODU0, false, OchPort.GridType.DWDM,
194 + OchPort.ChannelSpacing.CHL_100GHZ, -8, 4));
195 + testSerializedEquals(new OchPort(DEV1, P1, true, OchPort.SignalType.ODU0, false, OchPort.GridType.DWDM,
196 + OchPort.ChannelSpacing.CHL_100GHZ, -8, 4, A1_2));
197 + }
198 +
199 + @Test
200 + public void testOduCltPort() {
201 + testSerializedEquals(new OduCltPort(DEV1, P1, true, OduCltPort.SignalType.CLT_10GBE));
202 + testSerializedEquals(new OduCltPort(DEV1, P1, true, OduCltPort.SignalType.CLT_10GBE, A1_2));
203 + }
204 +
205 + @Test
180 public void testDeviceId() { 206 public void testDeviceId() {
181 testSerializedEquals(DID1); 207 testSerializedEquals(DID1);
182 } 208 }
......