Re-organize intent related packages
- Delete classes under intent package except for ApplicaitonIntent,
PacketConnectivityIntent, and OpticalConnectivityIntent
- Move PacketConnectivityIntent and OpticalConnectivityIntent under
net.onrc.onos.api.newintent package
- Adapt BatchOperation related changes for Intent and IntentId class
This is for ONOS-1887.
Change-Id: I4d25a0f8cbba806e9dd6e00333b6c7157c854658
diff --git a/src/main/java/net/onrc/onos/api/newintent/Intent.java b/src/main/java/net/onrc/onos/api/newintent/Intent.java
index 009725c..671ad30 100644
--- a/src/main/java/net/onrc/onos/api/newintent/Intent.java
+++ b/src/main/java/net/onrc/onos/api/newintent/Intent.java
@@ -1,11 +1,13 @@
package net.onrc.onos.api.newintent;
+import net.onrc.onos.api.batchoperation.BatchOperationTarget;
+
/**
* Abstraction of an application level intent.
*
* Make sure that an Intent should be immutable when a new type is defined.
*/
-public interface Intent {
+public interface Intent extends BatchOperationTarget {
/**
* Returns the intent identifier.
*
diff --git a/src/main/java/net/onrc/onos/api/newintent/IntentBatchOperation.java b/src/main/java/net/onrc/onos/api/newintent/IntentBatchOperation.java
new file mode 100644
index 0000000..0e34deb
--- /dev/null
+++ b/src/main/java/net/onrc/onos/api/newintent/IntentBatchOperation.java
@@ -0,0 +1,42 @@
+package net.onrc.onos.api.newintent;
+
+import net.onrc.onos.api.batchoperation.BatchOperation;
+import net.onrc.onos.api.batchoperation.BatchOperationEntry;
+
+/**
+ * A list of intent operations.
+ */
+public class IntentBatchOperation extends
+ BatchOperation<BatchOperationEntry<IntentBatchOperation.Operator, ?>> {
+ /**
+ * The intent operators.
+ */
+ public enum Operator {
+ ADD,
+ REMOVE,
+ }
+
+ /**
+ * Adds an add-intent operation.
+ *
+ * @param intent the intent to be added
+ * @return the IntentBatchOperation object if succeeded, null otherwise
+ */
+ public IntentBatchOperation addAddIntentOperation(Intent intent) {
+ return (null == super.addOperation(
+ new BatchOperationEntry<Operator, Intent>(Operator.ADD, intent)))
+ ? null : this;
+ }
+
+ /**
+ * Adds a remove-intent operation.
+ *
+ * @param id the ID of intent to be removed
+ * @return the IntentBatchOperation object if succeeded, null otherwise
+ */
+ public IntentBatchOperation addRemoveIntentOperation(IntentId id) {
+ return (null == super.addOperation(
+ new BatchOperationEntry<Operator, IntentId>(Operator.REMOVE, id)))
+ ? null : this;
+ }
+}
diff --git a/src/main/java/net/onrc/onos/api/newintent/IntentId.java b/src/main/java/net/onrc/onos/api/newintent/IntentId.java
index 6d10b35..b7cdb01 100644
--- a/src/main/java/net/onrc/onos/api/newintent/IntentId.java
+++ b/src/main/java/net/onrc/onos/api/newintent/IntentId.java
@@ -1,11 +1,13 @@
package net.onrc.onos.api.newintent;
+import net.onrc.onos.api.batchoperation.BatchOperationTarget;
+
/**
* Intent identifier suitable as an external key.
*
* This class is immutable.
*/
-public final class IntentId {
+public final class IntentId implements BatchOperationTarget {
private static final int DEC = 10;
private static final int HEX = 16;
diff --git a/src/main/java/net/onrc/onos/api/newintent/IntentIdGenerator.java b/src/main/java/net/onrc/onos/api/newintent/IntentIdGenerator.java
new file mode 100644
index 0000000..ec75c7b
--- /dev/null
+++ b/src/main/java/net/onrc/onos/api/newintent/IntentIdGenerator.java
@@ -0,0 +1,19 @@
+package net.onrc.onos.api.newintent;
+
+/**
+ * This interface is for generator of IntentId.
+ *
+ * <p>
+ * {@link #getNewId()} generates a globally unique {@link IntentId} instance
+ * on each invocation. Application developers should not generate IntentId
+ * by themselves. Instead use an implementation of this interface.
+ * </p>
+ */
+public interface IntentIdGenerator {
+ /**
+ * Generates a globally unique {@link IntentId} instance.
+ *
+ * @return a globally unique {@link IntentId} instance.
+ */
+ public IntentId getNewId();
+}
diff --git a/src/main/java/net/onrc/onos/api/newintent/IntentState.java b/src/main/java/net/onrc/onos/api/newintent/IntentState.java
index f272320..65310ee 100644
--- a/src/main/java/net/onrc/onos/api/newintent/IntentState.java
+++ b/src/main/java/net/onrc/onos/api/newintent/IntentState.java
@@ -36,7 +36,7 @@
/**
* The intent is being withdrawn.
*
- * When {@link net.onrc.onos.api.newintent.IntentService#withdraw(Intent)} is called,
+ * When {@link IntentService#withdraw(Intent)} is called,
* the intent takes this state first.
*/
WITHDRAWING,
diff --git a/src/main/java/net/onrc/onos/api/newintent/OpticalConnectivityIntent.java b/src/main/java/net/onrc/onos/api/newintent/OpticalConnectivityIntent.java
new file mode 100644
index 0000000..174d8c0
--- /dev/null
+++ b/src/main/java/net/onrc/onos/api/newintent/OpticalConnectivityIntent.java
@@ -0,0 +1,49 @@
+package net.onrc.onos.api.newintent;
+
+import net.onrc.onos.core.util.SwitchPort;
+
+// TODO: consider if this intent should be sub-class of ConnectivityIntent
+/**
+ * An optical layer Intent for a connectivity from a transponder port to another
+ * transponder port.
+ * <p>
+ * This class doesn't accepts lambda specifier. This class computes path between
+ * ports and assign lambda automatically. The lambda can be specified using
+ * OpticalPathFlow class.
+ */
+public class OpticalConnectivityIntent extends AbstractIntent {
+ protected SwitchPort srcSwitchPort;
+ protected SwitchPort dstSwitchPort;
+
+ /**
+ * Constructor.
+ *
+ * @param id ID for this new Intent object.
+ * @param srcSwitchPort The source transponder port.
+ * @param dstSwitchPort The destination transponder port.
+ */
+ public OpticalConnectivityIntent(IntentId id,
+ SwitchPort srcSwitchPort, SwitchPort dstSwitchPort) {
+ super(id);
+ this.srcSwitchPort = srcSwitchPort;
+ this.dstSwitchPort = dstSwitchPort;
+ }
+
+ /**
+ * Gets source transponder port.
+ *
+ * @return The source transponder port.
+ */
+ public SwitchPort getSrcSwitchPort() {
+ return srcSwitchPort;
+ }
+
+ /**
+ * Gets destination transponder port.
+ *
+ * @return The source transponder port.
+ */
+ public SwitchPort getDstSwitchPort() {
+ return dstSwitchPort;
+ }
+}
diff --git a/src/main/java/net/onrc/onos/api/newintent/PacketConnectivityIntent.java b/src/main/java/net/onrc/onos/api/newintent/PacketConnectivityIntent.java
new file mode 100644
index 0000000..e03166c
--- /dev/null
+++ b/src/main/java/net/onrc/onos/api/newintent/PacketConnectivityIntent.java
@@ -0,0 +1,164 @@
+package net.onrc.onos.api.newintent;
+
+import net.onrc.onos.core.matchaction.match.PacketMatch;
+import net.onrc.onos.core.util.SwitchPort;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
+// TODO: consider if this intent should be sub-class of Connectivity intent
+/**
+ * A packet layer Intent for a connectivity from a set of ports to a set of
+ * ports.
+ * <p>
+ * TODO: Design methods to support the ReactiveForwarding and the SDN-IP. <br>
+ * NOTE: Should this class support modifier methods? Should this object a
+ * read-only object?
+ */
+public class PacketConnectivityIntent extends AbstractIntent {
+ protected Set<SwitchPort> srcSwitchPorts;
+ protected PacketMatch match;
+ protected Set<SwitchPort> dstSwitchPorts;
+ protected boolean canSetupOpticalFlow;
+ protected int idleTimeoutValue;
+ protected int hardTimeoutValue;
+
+ /**
+ * Creates a connectivity intent for the packet layer.
+ * <p>
+ * When the "canSetupOpticalFlow" option is true, this intent will compute
+ * the packet/optical converged path, decompose it to the OpticalPathFlow
+ * and the PacketPathFlow objects, and execute the operations to add them
+ * considering the dependency between the packet and optical layers.
+ *
+ * @param id ID for this new Intent object.
+ * @param srcSwitchPorts The set of source switch ports.
+ * @param match Traffic specifier for this object.
+ * @param dstSwitchPorts The set of destination switch ports.
+ * @param canSetupOpticalFlow The flag whether this intent can create
+ * optical flows if needed.
+ */
+ public PacketConnectivityIntent(IntentId id,
+ Collection<SwitchPort> srcSwitchPorts, PacketMatch match,
+ Collection<SwitchPort> dstSwitchPorts, boolean canSetupOpticalFlow) {
+ super(id);
+ this.srcSwitchPorts = new HashSet<SwitchPort>(srcSwitchPorts);
+ this.match = match;
+ this.dstSwitchPorts = new HashSet<SwitchPort>(dstSwitchPorts);
+ this.canSetupOpticalFlow = canSetupOpticalFlow;
+ this.idleTimeoutValue = 0;
+ this.hardTimeoutValue = 0;
+
+ // TODO: check consistency between these parameters.
+ }
+
+ /**
+ * Gets the set of source switch ports.
+ *
+ * @return the set of source switch ports.
+ */
+ public Collection<SwitchPort> getSrcSwitchPorts() {
+ return Collections.unmodifiableCollection(srcSwitchPorts);
+ }
+
+ /**
+ * Gets the traffic specifier.
+ *
+ * @return The traffic specifier.
+ */
+ public PacketMatch getMatch() {
+ return match;
+ }
+
+ /**
+ * Gets the set of destination switch ports.
+ *
+ * @return the set of destination switch ports.
+ */
+ public Collection<SwitchPort> getDstSwitchPorts() {
+ return Collections.unmodifiableCollection(dstSwitchPorts);
+ }
+
+ /**
+ * Adds the specified port to the set of source ports.
+ *
+ * @param port SwitchPort object to be added
+ */
+ public void addSrcSwitchPort(SwitchPort port) {
+ // TODO implement it.
+ }
+
+ /**
+ * Adds the specified port to the set of destination ports.
+ *
+ * @param port SwitchPort object to be added
+ */
+ public void addDstSwitchPort(SwitchPort port) {
+ // TODO implement it.
+ }
+
+ /**
+ * Removes the specified port from the set of source ports.
+ *
+ * @param port SwitchPort object to be removed
+ */
+ public void removeSrcSwitchPort(SwitchPort port) {
+ // TODO implement it.
+ }
+
+ /**
+ * Removes the specified port from the set of destination ports.
+ *
+ * @param port SwitchPort object to be removed
+ */
+ public void removeDstSwitchPort(SwitchPort port) {
+ // TODO implement it.
+ }
+
+ /**
+ * Sets idle-timeout value.
+ *
+ * @param timeout Idle-timeout value (seconds)
+ */
+ public void setIdleTimeout(int timeout) {
+ idleTimeoutValue = timeout;
+ }
+
+ /**
+ * Sets hard-timeout value.
+ *
+ * @param timeout Hard-timeout value (seconds)
+ */
+ public void setHardTimeout(int timeout) {
+ hardTimeoutValue = timeout;
+ }
+
+ /**
+ * Gets idle-timeout value.
+ *
+ * @return Idle-timeout value (seconds)
+ */
+ public int getIdleTimeout() {
+ return idleTimeoutValue;
+ }
+
+ /**
+ * Gets hard-timeout value.
+ *
+ * @return Hard-timeout value (seconds)
+ */
+ public int getHardTimeout() {
+ return hardTimeoutValue;
+ }
+
+ /**
+ * Returns whether this intent can create optical flows if needed.
+ *
+ * @return whether this intent can create optical flows.
+ */
+ public boolean canSetupOpticalFlow() {
+ return canSetupOpticalFlow;
+ }
+}