Support for OTN using optical circuit intents.
Refined DeviceResourceService.
Change-Id: I489f368a0fac5f4a8d0a1a1cb716f845558db35e
diff --git a/core/api/src/main/java/org/onosproject/net/flow/criteria/OchSignalTypeCriterion.java b/core/api/src/main/java/org/onosproject/net/flow/criteria/OchSignalTypeCriterion.java
index f70a504..cf838bf 100644
--- a/core/api/src/main/java/org/onosproject/net/flow/criteria/OchSignalTypeCriterion.java
+++ b/core/api/src/main/java/org/onosproject/net/flow/criteria/OchSignalTypeCriterion.java
@@ -23,7 +23,7 @@
import static com.google.common.base.Preconditions.checkNotNull;
/**
- * Implementation of OCh (Optical Channel) singal type criterion.
+ * Implementation of OCh (Optical Channel) signal type criterion.
*/
public class OchSignalTypeCriterion implements Criterion {
diff --git a/core/api/src/main/java/org/onosproject/net/intent/OpticalCircuitIntent.java b/core/api/src/main/java/org/onosproject/net/intent/OpticalCircuitIntent.java
new file mode 100644
index 0000000..5f95d70
--- /dev/null
+++ b/core/api/src/main/java/org/onosproject/net/intent/OpticalCircuitIntent.java
@@ -0,0 +1,190 @@
+/*
+ * 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.intent;
+
+import com.google.common.base.MoreObjects;
+import org.onosproject.core.ApplicationId;
+import org.onosproject.net.ConnectPoint;
+import org.onosproject.net.OduCltPort;
+
+import java.util.Collections;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+/**
+ * An optical layer intent for circuits between two OduClt ports.
+ * No traffic selector or traffic treatment are needed.
+ */
+public class OpticalCircuitIntent extends Intent {
+ private final ConnectPoint src;
+ private final ConnectPoint dst;
+ private final OduCltPort.SignalType signalType;
+
+ /**
+ * Creates an optical circuit intent between the specified
+ * connection points.
+ *
+ * @param appId application identification
+ * @param key intent key
+ * @param src the source transponder port
+ * @param dst the destination transponder port
+ * @param signalType ODU signal type
+ * @param priority priority to use for flows from this intent
+ */
+ protected OpticalCircuitIntent(ApplicationId appId, Key key, ConnectPoint src, ConnectPoint dst,
+ OduCltPort.SignalType signalType, int priority) {
+ super(appId, key, Collections.emptyList(), priority);
+ this.src = checkNotNull(src);
+ this.dst = checkNotNull(dst);
+ this.signalType = checkNotNull(signalType);
+ }
+
+ /**
+ * Returns a new optical circuit intent builder.
+ *
+ * @return host to host intent builder
+ */
+ public static Builder builder() {
+ return new Builder();
+ }
+
+
+ /**
+ * Builder for optical circuit intents.
+ */
+ public static class Builder extends Intent.Builder {
+ private ConnectPoint src;
+ private ConnectPoint dst;
+ private OduCltPort.SignalType signalType;
+
+ @Override
+ public Builder appId(ApplicationId appId) {
+ return (Builder) super.appId(appId);
+ }
+
+ @Override
+ public Builder key(Key key) {
+ return (Builder) super.key(key);
+ }
+
+ @Override
+ public Builder priority(int priority) {
+ return (Builder) super.priority(priority);
+ }
+
+ /**
+ * Sets the source for the intent that will be built.
+ *
+ * @param src source to use for built intent
+ * @return this builder
+ */
+ public Builder src(ConnectPoint src) {
+ this.src = src;
+ return this;
+ }
+
+ /**
+ * Sets the destination for the intent that will be built.
+ *
+ * @param dst dest to use for built intent
+ * @return this builder
+ */
+ public Builder dst(ConnectPoint dst) {
+ this.dst = dst;
+ return this;
+ }
+
+ /**
+ * Sets the ODU signal type for the intent that will be built.
+ *
+ * @param signalType signal type to use for built intent
+ * @return this builder
+ */
+ public Builder signalType(OduCltPort.SignalType signalType) {
+ this.signalType = signalType;
+ return this;
+ }
+
+ /**
+ * Builds an optical circuit intent from the accumulated parameters.
+ *
+ * @return point to point intent
+ */
+ public OpticalCircuitIntent build() {
+
+ return new OpticalCircuitIntent(
+ appId,
+ key,
+ src,
+ dst,
+ signalType,
+ priority
+ );
+ }
+ }
+
+ /**
+ * Constructor for serializer.
+ */
+ protected OpticalCircuitIntent() {
+ super();
+ this.src = null;
+ this.dst = null;
+ this.signalType = null;
+ }
+
+ /**
+ * Returns the source transponder port.
+ *
+ * @return source transponder port
+ */
+ public ConnectPoint getSrc() {
+ return src;
+ }
+
+ /**
+ * Returns the destination transponder port.
+ *
+ * @return source transponder port
+ */
+ public ConnectPoint getDst() {
+ return dst;
+ }
+
+ /**
+ * Returns the ODU signal type.
+ *
+ * @return ODU signal type
+ */
+ public OduCltPort.SignalType getSignalType() {
+ return signalType;
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(this)
+ .add("id", id())
+ .add("key", key())
+ .add("appId", appId())
+ .add("priority", priority())
+ .add("resources", resources())
+ .add("src", src)
+ .add("dst", dst)
+ .add("signalType", signalType)
+ .toString();
+ }
+
+}
diff --git a/core/api/src/main/java/org/onosproject/net/intent/OpticalConnectivityIntent.java b/core/api/src/main/java/org/onosproject/net/intent/OpticalConnectivityIntent.java
index c2b84ab..f28fd29 100644
--- a/core/api/src/main/java/org/onosproject/net/intent/OpticalConnectivityIntent.java
+++ b/core/api/src/main/java/org/onosproject/net/intent/OpticalConnectivityIntent.java
@@ -18,6 +18,7 @@
import com.google.common.base.MoreObjects;
import org.onosproject.core.ApplicationId;
import org.onosproject.net.ConnectPoint;
+import org.onosproject.net.OduSignalType;
import java.util.Collections;
@@ -30,6 +31,7 @@
public final class OpticalConnectivityIntent extends Intent {
private final ConnectPoint src;
private final ConnectPoint dst;
+ private final OduSignalType signalType;
/**
* Creates an optical connectivity intent between the specified
@@ -42,13 +44,15 @@
* @param priority priority to use for flows from this intent
*/
protected OpticalConnectivityIntent(ApplicationId appId,
- Key key,
- ConnectPoint src,
- ConnectPoint dst,
- int priority) {
+ Key key,
+ ConnectPoint src,
+ ConnectPoint dst,
+ OduSignalType signalType,
+ int priority) {
super(appId, key, Collections.emptyList(), priority);
this.src = checkNotNull(src);
this.dst = checkNotNull(dst);
+ this.signalType = checkNotNull(signalType);
}
/**
@@ -67,6 +71,7 @@
public static class Builder extends Intent.Builder {
private ConnectPoint src;
private ConnectPoint dst;
+ private OduSignalType signalType;
@Override
public Builder appId(ApplicationId appId) {
@@ -106,6 +111,17 @@
}
/**
+ * Sets the ODU signal type for the intent that will be built.
+ *
+ * @param signalType ODU signal type
+ * @return this builder
+ */
+ public Builder signalType(OduSignalType signalType) {
+ this.signalType = signalType;
+ return this;
+ }
+
+ /**
* Builds an optical connectivity intent from the accumulated parameters.
*
* @return point to point intent
@@ -117,6 +133,7 @@
key,
src,
dst,
+ signalType,
priority
);
}
@@ -129,6 +146,7 @@
super();
this.src = null;
this.dst = null;
+ this.signalType = null;
}
/**
@@ -149,6 +167,15 @@
return dst;
}
+ /**
+ * Returns the ODU signal type.
+ *
+ * @return ODU signal type
+ */
+ public OduSignalType getSignalType() {
+ return signalType;
+ }
+
@Override
public String toString() {
return MoreObjects.toStringHelper(this)
@@ -159,6 +186,7 @@
.add("resources", resources())
.add("src", src)
.add("dst", dst)
+ .add("signalType", signalType)
.toString();
}
}
diff --git a/core/api/src/main/java/org/onosproject/net/resource/device/DeviceResourceService.java b/core/api/src/main/java/org/onosproject/net/resource/device/DeviceResourceService.java
index acbc486..81bd1b7 100644
--- a/core/api/src/main/java/org/onosproject/net/resource/device/DeviceResourceService.java
+++ b/core/api/src/main/java/org/onosproject/net/resource/device/DeviceResourceService.java
@@ -28,10 +28,46 @@
/**
* Request a set of ports needed to satisfy the intent.
*
+ * @param ports set of ports to allocate
* @param intent the intent
- * @return set of ports
+ * @return true if ports were successfully allocated, false otherwise
*/
- Set<Port> requestPorts(Intent intent);
+ boolean requestPorts(Set<Port> ports, Intent intent);
+
+ /**
+ * Returns the set of ports allocated for an intent.
+ *
+ * @param intentId the intent ID
+ * @return set of allocated ports
+ */
+ Set<Port> getAllocations(IntentId intentId);
+
+ /**
+ * Returns the intent allocated to a port.
+ *
+ * @param port the port
+ * @return intent ID allocated to the port
+ */
+ IntentId getAllocations(Port port);
+
+ /**
+ * Request a mapping between the given intents.
+ *
+ * @param keyIntentId the key intent ID
+ * @param valIntentId the value intent ID
+ * @return true if mapping was successful, false otherwise
+ */
+ boolean requestMapping(IntentId keyIntentId, IntentId valIntentId);
+
+ /**
+ * Returns the intents mapped to a lower intent.
+ *
+ * @param intentId the intent ID
+ * @return the set of intent IDs
+ */
+ Set<IntentId> getMapping(IntentId intentId);
+
+ void releaseMapping(IntentId keyIntentId, IntentId valIntentId);
/**
* Release ports associated with given intent ID.
diff --git a/core/api/src/main/java/org/onosproject/net/resource/device/DeviceResourceStore.java b/core/api/src/main/java/org/onosproject/net/resource/device/DeviceResourceStore.java
index 3437f4b..c73cab7 100644
--- a/core/api/src/main/java/org/onosproject/net/resource/device/DeviceResourceStore.java
+++ b/core/api/src/main/java/org/onosproject/net/resource/device/DeviceResourceStore.java
@@ -24,7 +24,60 @@
public interface DeviceResourceStore {
Set<Port> getFreePorts(DeviceId deviceId);
- void allocatePorts(Set<Port> port, IntentId intent);
+ /**
+ * Allocates the given ports to the given intent.
+ * @param ports set of ports to allocate
+ * @param intentId intent ID
+ * @return true if allocation was successful, false otherwise
+ */
+ boolean allocatePorts(Set<Port> ports, IntentId intentId);
- void releasePorts(IntentId intent);
+ /**
+ * Returns set of ports allocated for an intent.
+ *
+ * @param intentId the intent ID
+ * @return set of allocated ports
+ */
+ Set<Port> getAllocations(IntentId intentId);
+
+ /**
+ * Returns intent allocated to a port.
+ *
+ * @param port the port
+ * @return intent ID allocated to the port
+ */
+ IntentId getAllocations(Port port);
+
+ /**
+ * Allocates the mapping between the given intents.
+ *
+ * @param keyIntentId key intent ID
+ * @param valIntentId value intent ID
+ * @return true if mapping was successful, false otherwise
+ */
+ boolean allocateMapping(IntentId keyIntentId, IntentId valIntentId);
+
+ /**
+ * Returns the set of intents mapped to a lower intent.
+ *
+ * @param intentId intent ID
+ * @return set of intent IDs
+ */
+ Set<IntentId> getMapping(IntentId intentId);
+
+ /**
+ * Releases the mapping between the given intents.
+ *
+ * @param keyIntentId key intent ID
+ * @param valIntentId value intent ID
+ */
+ void releaseMapping(IntentId keyIntentId, IntentId valIntentId);
+
+ /**
+ * Releases the ports allocated to the given intent.
+ *
+ * @param intentId intent ID
+ * @return true if release was successful, false otherwise
+ */
+ boolean releasePorts(IntentId intentId);
}