Improvements of roadm application:
1.Fix the bug of Treating path index as port number for APS;
2.Creating APS switching operations dynamically, instead of hard code;
3.Change APS interface for general using;
4.Compatible test base on the devices of OPENFLOW and NETCONF protocol.
Change-Id: Ib750d40ed28fc184a96b58e97715beab3d80ff17
diff --git a/apps/roadm/src/main/java/org/onosproject/roadm/RoadmManager.java b/apps/roadm/src/main/java/org/onosproject/roadm/RoadmManager.java
index 7f44e23..081dedf 100644
--- a/apps/roadm/src/main/java/org/onosproject/roadm/RoadmManager.java
+++ b/apps/roadm/src/main/java/org/onosproject/roadm/RoadmManager.java
@@ -15,6 +15,7 @@
*/
package org.onosproject.roadm;
+import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Range;
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
@@ -52,7 +53,6 @@
import org.onosproject.net.flow.TrafficTreatment;
import org.onosproject.net.flow.criteria.Criteria;
import org.onosproject.net.flow.instructions.Instructions;
-import org.onosproject.net.optical.OpticalAnnotations;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -62,12 +62,14 @@
import java.util.Map;
import java.util.Optional;
import java.util.Set;
-import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
-
import static com.google.common.base.Preconditions.checkNotNull;
+import static org.onosproject.net.optical.OpticalAnnotations.INPUT_PORT_STATUS;
+import static org.onosproject.roadm.RoadmUtil.OPS_OPT_AUTO;
+import static org.onosproject.roadm.RoadmUtil.OPS_OPT_FORCE;
+import static org.onosproject.roadm.RoadmUtil.OPS_OPT_MANUAL;
/**
* Application for monitoring and configuring ROADM devices.
@@ -111,6 +113,7 @@
log.info("Stopped");
}
+ @Deprecated
@Override
public void setProtectionSwitchWorkingPath(DeviceId deviceId, int index) {
checkNotNull(deviceId);
@@ -130,6 +133,7 @@
behaviour.switchWorkingPath(map.keySet().toArray(new ConnectPoint[0])[0], index);
}
+ @Deprecated
@Override
public String getProtectionSwitchPortState(DeviceId deviceId, PortNumber portNumber) {
checkNotNull(deviceId);
@@ -145,7 +149,7 @@
for (ProtectedTransportEndpointState state : map.values()) {
for (TransportEndpointState element : state.pathStates()) {
if (element.description().output().connectPoint().port().equals(portNumber)) {
- return element.attributes().get(OpticalAnnotations.INPUT_PORT_STATUS);
+ return element.attributes().get(INPUT_PORT_STATUS);
}
}
}
@@ -155,6 +159,37 @@
}
@Override
+ public void configProtectionSwitch(DeviceId deviceId, String operation, ConnectPoint identifier, int index) {
+ checkNotNull(deviceId);
+ ProtectionConfigBehaviour behaviour = getProtectionConfig(deviceId);
+ if (behaviour == null) {
+ return;
+ }
+ // automatic operation
+ if (OPS_OPT_AUTO.equals(operation)) {
+ behaviour.switchToAutomatic(identifier);
+ return;
+ }
+ // force or manual operation
+ if (OPS_OPT_MANUAL.equals(operation)) {
+ behaviour.switchToManual(identifier, index);
+ } else if (OPS_OPT_FORCE.equals(operation)) {
+ behaviour.switchToForce(identifier, index);
+ }
+ }
+
+ @Override
+ public Map<ConnectPoint, ProtectedTransportEndpointState> getProtectionSwitchStates(DeviceId deviceId) {
+ checkNotNull(deviceId);
+ ProtectionConfigBehaviour behaviour = getProtectionConfig(deviceId);
+ if (behaviour == null) {
+ return ImmutableMap.of();
+ }
+ return getProtectionSwitchStates(behaviour);
+ }
+
+
+ @Override
public void setTargetPortPower(DeviceId deviceId, PortNumber portNumber, long power) {
checkNotNull(deviceId);
checkNotNull(portNumber);
@@ -547,6 +582,7 @@
TimeUnit.SECONDS.sleep(1);
} catch (InterruptedException e) {
log.warn("Thread interrupted. Setting attenuation early.");
+ Thread.currentThread().interrupt();
}
setAttenuation(deviceId, outPort, ochSignal, attenuation);
};
@@ -556,17 +592,16 @@
// get protection endpoint states
private Map<ConnectPoint, ProtectedTransportEndpointState> getProtectionSwitchStates(
ProtectionConfigBehaviour behaviour) {
- CompletableFuture<Map<ConnectPoint, ProtectedTransportEndpointState>>
- states = behaviour.getProtectionEndpointStates();
Map<ConnectPoint, ProtectedTransportEndpointState> map;
try {
- map = states.get();
+ map = behaviour.getProtectionEndpointStates().get();
} catch (InterruptedException e1) {
log.error("Interrupted.", e1);
- return null;
+ Thread.currentThread().interrupt();
+ return ImmutableMap.of();
} catch (ExecutionException e1) {
log.error("Exception caught.", e1);
- return null;
+ return ImmutableMap.of();
}
return map;
}