Sho SHIMIZU

Pull out enums from OchPort

The following enums are pulled out
- SignalType (renamed to OduSignalType)
- GridType
- ChannelSpacing

Change-Id: Id30e582df9c3c2c5e239df57499ffe9436dd6237
/*
* Copyright 2015 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.net;
import org.onlab.util.Frequency;
/**
* Represents interval frequency between two neighboring wavelengths.
*/
public enum ChannelSpacing {
CHL_100GHZ(100), // 100 GHz
CHL_50GHZ(50), // 50 GHz
CHL_25GHZ(25), // 25 GHz
CHL_12P5GHZ(12.5), // 12.5 GHz
CHL_6P25GHZ(6.5); // 6.25 GHz
private final Frequency frequency;
/**
* Creates an instance with the specified interval in GHz.
*
* @param value interval of neighboring wavelengths in GHz.
*/
ChannelSpacing(double value) {
this.frequency = Frequency.ofGHz(value);
}
public Frequency frequency() {
return frequency;
}
}
/*
* Copyright 2015 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.net;
/**
* Represents type of wavelength grid.
*
* <p>
* See Open Networking Foundation "Optical Transport Protocol Extensions Version 1.0".
* </p>
*/
public enum GridType {
RES, // ??
DWDM, // Dense Wavelength Division Multiplexing
CWDM, // Coarse WDM
FLEX // Flex Grid
}
......@@ -31,41 +31,7 @@ public class OchPort extends DefaultPort {
public static final Frequency CENTER_FREQUENCY = Frequency.ofTHz(193.1);
public static final Frequency FLEX_GRID_SLOT = Frequency.ofGHz(12.5);
public enum SignalType {
ODU0,
ODU1,
ODU2,
ODU2e,
ODU3,
ODU4
}
public enum GridType {
RES, // ??
DWDM, // Dense Wavelength Division Multiplexing
CWDM, // Coarse WDM
FLEX // Flex Grid
}
public enum ChannelSpacing {
CHL_100GHZ(100), // 100 GHz
CHL_50GHZ(50), // 50 GHz
CHL_25GHZ(25), // 25 GHz
CHL_12P5GHZ(12.5), // 12.5 GHz
CHL_6P25GHZ(6.5); // 6.25 GHz
private final Frequency frequency;
ChannelSpacing(double value) {
this.frequency = Frequency.ofGHz(value);
}
public Frequency frequency() {
return frequency;
}
}
private final SignalType signalType;
private final OduSignalType signalType;
private final boolean isTunable;
private final GridType gridType;
private final ChannelSpacing channelSpacing;
......@@ -89,7 +55,7 @@ public class OchPort extends DefaultPort {
* @param slotGranularity slot width granularity
* @param annotations optional key/value annotations
*/
public OchPort(Element element, PortNumber number, boolean isEnabled, SignalType signalType,
public OchPort(Element element, PortNumber number, boolean isEnabled, OduSignalType signalType,
boolean isTunable, GridType gridType, ChannelSpacing channelSpacing,
int spacingMultiplier, int slotGranularity, Annotations... annotations) {
super(element, number, isEnabled, Type.OCH, 0, annotations);
......@@ -106,7 +72,7 @@ public class OchPort extends DefaultPort {
*
* @return ODU signal type
*/
public SignalType signalType() {
public OduSignalType signalType() {
return signalType;
}
......
/*
* Copyright 2015 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.net;
/**
* Represents ODU (Optical channel Data Unit) signal type.
*
* <p>
* See ITU G.709 "Interfaces for the Optical Transport Network (OTN)" and
* Open Networking Foundation "Optical Transport Protocol Extensions Version 1.0".
* </p>
*/
public enum OduSignalType {
ODU0,
ODU1,
ODU2,
ODU2e,
ODU3,
ODU4
}
......@@ -16,9 +16,11 @@
package org.onosproject.net.device;
import com.google.common.base.MoreObjects;
import org.onosproject.net.OchPort;
import org.onosproject.net.ChannelSpacing;
import org.onosproject.net.GridType;
import org.onosproject.net.Port;
import org.onosproject.net.PortNumber;
import org.onosproject.net.OduSignalType;
import org.onosproject.net.SparseAnnotations;
/**
......@@ -26,10 +28,10 @@ import org.onosproject.net.SparseAnnotations;
*/
public class OchPortDescription extends DefaultPortDescription {
private final OchPort.SignalType signalType;
private final OduSignalType signalType;
private final boolean isTunable;
private final OchPort.GridType gridType;
private final OchPort.ChannelSpacing channelSpacing;
private final GridType gridType;
private final ChannelSpacing channelSpacing;
// Frequency = 193.1 THz + spacingMultiplier * channelSpacing
private final int spacingMultiplier;
// Slot width = slotGranularity * 12.5 GHz
......@@ -48,9 +50,9 @@ public class OchPortDescription extends DefaultPortDescription {
* @param slotGranularity slow width granularity
* @param annotations optional key/value annotations map
*/
public OchPortDescription(PortNumber number, boolean isEnabled, OchPort.SignalType signalType,
boolean isTunable, OchPort.GridType gridType,
OchPort.ChannelSpacing channelSpacing,
public OchPortDescription(PortNumber number, boolean isEnabled, OduSignalType signalType,
boolean isTunable, GridType gridType,
ChannelSpacing channelSpacing,
int spacingMultiplier, int slotGranularity, SparseAnnotations... annotations) {
super(number, isEnabled, Port.Type.OCH, 0, annotations);
this.signalType = signalType;
......@@ -73,8 +75,8 @@ public class OchPortDescription extends DefaultPortDescription {
* @param slotGranularity slot width granularity
* @param annotations optional key/value annotations map
*/
public OchPortDescription(PortDescription base, OchPort.SignalType signalType, boolean isTunable,
OchPort.GridType gridType, OchPort.ChannelSpacing channelSpacing,
public OchPortDescription(PortDescription base, OduSignalType signalType, boolean isTunable,
GridType gridType, ChannelSpacing channelSpacing,
int spacingMultiplier, int slotGranularity, SparseAnnotations annotations) {
super(base, annotations);
this.signalType = signalType;
......@@ -90,7 +92,7 @@ public class OchPortDescription extends DefaultPortDescription {
*
* @return ODU signal type
*/
public OchPort.SignalType signalType() {
public OduSignalType signalType() {
return signalType;
}
......@@ -108,7 +110,7 @@ public class OchPortDescription extends DefaultPortDescription {
*
* @return grid type
*/
public OchPort.GridType gridType() {
public GridType gridType() {
return gridType;
}
......@@ -117,7 +119,7 @@ public class OchPortDescription extends DefaultPortDescription {
*
* @return channel spacing
*/
public OchPort.ChannelSpacing channelSpacing() {
public ChannelSpacing channelSpacing() {
return channelSpacing;
}
......
......@@ -43,6 +43,7 @@ import org.onosproject.core.DefaultGroupId;
import org.onosproject.core.Version;
import org.onosproject.mastership.MastershipTerm;
import org.onosproject.net.Annotations;
import org.onosproject.net.ChannelSpacing;
import org.onosproject.net.ConnectPoint;
import org.onosproject.net.DefaultAnnotations;
import org.onosproject.net.DefaultDevice;
......@@ -53,6 +54,7 @@ import org.onosproject.net.DefaultPort;
import org.onosproject.net.Device;
import org.onosproject.net.DeviceId;
import org.onosproject.net.Element;
import org.onosproject.net.GridType;
import org.onosproject.net.HostId;
import org.onosproject.net.HostLocation;
import org.onosproject.net.Link;
......@@ -62,6 +64,7 @@ import org.onosproject.net.OduCltPort;
import org.onosproject.net.OmsPort;
import org.onosproject.net.Port;
import org.onosproject.net.PortNumber;
import org.onosproject.net.OduSignalType;
import org.onosproject.net.device.DefaultDeviceDescription;
import org.onosproject.net.device.DefaultPortDescription;
import org.onosproject.net.flow.CompletedBatchOperation;
......@@ -376,9 +379,9 @@ public final class KryoNamespaces {
.register(Annotations.class)
.register(OmsPort.class)
.register(OchPort.class)
.register(OchPort.SignalType.class)
.register(OchPort.GridType.class)
.register(OchPort.ChannelSpacing.class)
.register(OduSignalType.class)
.register(GridType.class)
.register(ChannelSpacing.class)
.register(OduCltPort.class)
.register(OduCltPort.SignalType.class)
.register(
......
......@@ -30,6 +30,7 @@ import org.onosproject.cluster.RoleInfo;
import org.onosproject.core.DefaultGroupId;
import org.onosproject.mastership.MastershipTerm;
import org.onosproject.net.Annotations;
import org.onosproject.net.ChannelSpacing;
import org.onosproject.net.ConnectPoint;
import org.onosproject.net.DefaultAnnotations;
import org.onosproject.net.DefaultDevice;
......@@ -37,6 +38,7 @@ import org.onosproject.net.DefaultLink;
import org.onosproject.net.DefaultPort;
import org.onosproject.net.Device;
import org.onosproject.net.DeviceId;
import org.onosproject.net.GridType;
import org.onosproject.net.HostLocation;
import org.onosproject.net.Link;
import org.onosproject.net.Link.Type;
......@@ -45,6 +47,7 @@ import org.onosproject.net.OchPort;
import org.onosproject.net.OduCltPort;
import org.onosproject.net.OmsPort;
import org.onosproject.net.PortNumber;
import org.onosproject.net.OduSignalType;
import org.onosproject.net.SparseAnnotations;
import org.onosproject.net.flow.DefaultFlowRule;
import org.onosproject.net.flow.DefaultTrafficSelector;
......@@ -190,10 +193,10 @@ public class KryoSerializerTest {
@Test
public void testOchPort() {
testSerializedEquals(new OchPort(DEV1, P1, true, OchPort.SignalType.ODU0, false, OchPort.GridType.DWDM,
OchPort.ChannelSpacing.CHL_100GHZ, -8, 4));
testSerializedEquals(new OchPort(DEV1, P1, true, OchPort.SignalType.ODU0, false, OchPort.GridType.DWDM,
OchPort.ChannelSpacing.CHL_100GHZ, -8, 4, A1_2));
testSerializedEquals(new OchPort(DEV1, P1, true, OduSignalType.ODU0, false, GridType.DWDM,
ChannelSpacing.CHL_100GHZ, -8, 4));
testSerializedEquals(new OchPort(DEV1, P1, true, OduSignalType.ODU0, false, GridType.DWDM,
ChannelSpacing.CHL_100GHZ, -8, 4, A1_2));
}
@Test
......