Change the definition of the base class of intent
- Remove compile() for decoupling how to translate a high level
intent to lower level intents
- Add a field to define expiration duration of an intent
Change-Id: I770426a41c78d35b010111e911562af0b68cc3bf
diff --git a/src/main/java/net/onrc/onos/api/intent/Intent.java b/src/main/java/net/onrc/onos/api/intent/Intent.java
index be34ba8..0488b35 100644
--- a/src/main/java/net/onrc/onos/api/intent/Intent.java
+++ b/src/main/java/net/onrc/onos/api/intent/Intent.java
@@ -1,40 +1,38 @@
package net.onrc.onos.api.intent;
-import java.util.List;
-
-import net.onrc.onos.api.batchoperation.BatchOperation;
+import com.google.common.base.Objects;
import net.onrc.onos.api.batchoperation.IBatchOperationTarget;
-import net.onrc.onos.api.flowmanager.IFlow;
import static com.google.common.base.Preconditions.checkNotNull;
/**
- * The base class for the connectivity abstraction. It allows applications to
- * specify end hosts, apply some basic filtering to traffic, and constrain
- * traffic.
- * <p>
+ * The base class of an intent type.
+
* This class is sub-classed to provide other intent types like shortest path
* connectivity and bandwidth constrained shortest path connectivity.
- * <p>
+
* The reasoning behind "intent" is that the applications can provide some
* abstract representation of how traffic should flow be handled by the
* networking, allowing the network OS to compile, reserve and optimize the
* data-plane to satisfy those constraints.
+ *
+ * It is assumed that any kinds of intents are immutable.
+ * Developers that will define a new intent type should ensure its immutability.
*/
public abstract class Intent implements IBatchOperationTarget {
private final IntentId id;
/**
- * Constructor.
+ * Constructs an intent, which is activated permanently until it is removed explicitly.
*
- * @param id ID for this Intent object.
+ * @param id ID for this intent object.
*/
protected Intent(IntentId id) {
this.id = checkNotNull(id);
}
/**
- * Gets ID for this Intent object.
+ * Returns ID for this Intent object.
*
* @return ID for this Intent object.
*/
@@ -43,13 +41,29 @@
return id;
}
- /**
- * Compiles this Intent object to the list of FlowOperations.
- * <p>
- * All Intent object must implement this method and IntentRuntimeModule use
- * this method to process this Intent.
- *
- * @return The list of FlowOperations of this Intent.
- */
- public abstract List<BatchOperation<IFlow>> compile();
+ @Override
+ public int hashCode() {
+ return id.hashCode();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj == this) {
+ return true;
+ }
+
+ if (!(obj instanceof Intent)) {
+ return false;
+ }
+
+ Intent that = (Intent) obj;
+ return Objects.equal(this.id, that.id);
+ }
+
+ @Override
+ public String toString() {
+ return Objects.toStringHelper(this)
+ .add("id", id)
+ .toString();
+ }
}
diff --git a/src/main/java/net/onrc/onos/api/intent/OpticalConnectivityIntent.java b/src/main/java/net/onrc/onos/api/intent/OpticalConnectivityIntent.java
index e9d6171..256fa44 100644
--- a/src/main/java/net/onrc/onos/api/intent/OpticalConnectivityIntent.java
+++ b/src/main/java/net/onrc/onos/api/intent/OpticalConnectivityIntent.java
@@ -1,9 +1,5 @@
package net.onrc.onos.api.intent;
-import java.util.List;
-
-import net.onrc.onos.api.batchoperation.BatchOperation;
-import net.onrc.onos.api.flowmanager.IFlow;
import net.onrc.onos.core.util.SwitchPort;
/**
@@ -49,10 +45,4 @@
public SwitchPort getDstSwitchPort() {
return dstSwitchPort;
}
-
- @Override
- public List<BatchOperation<IFlow>> compile() {
- // TODO Auto-generated method stub
- return null;
- }
}
diff --git a/src/main/java/net/onrc/onos/api/intent/PacketConnectivityIntent.java b/src/main/java/net/onrc/onos/api/intent/PacketConnectivityIntent.java
index 020dd56..77a2a13 100644
--- a/src/main/java/net/onrc/onos/api/intent/PacketConnectivityIntent.java
+++ b/src/main/java/net/onrc/onos/api/intent/PacketConnectivityIntent.java
@@ -1,16 +1,13 @@
package net.onrc.onos.api.intent;
+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.List;
import java.util.Set;
-import net.onrc.onos.api.batchoperation.BatchOperation;
-import net.onrc.onos.api.flowmanager.IFlow;
-import net.onrc.onos.core.matchaction.match.PacketMatch;
-import net.onrc.onos.core.util.SwitchPort;
-
/**
* A packet layer Intent for a connectivity from a set of ports to a set of
* ports.
@@ -163,10 +160,4 @@
public boolean canSetupOpticalFlow() {
return canSetupOpticalFlow;
}
-
- @Override
- public List<BatchOperation<IFlow>> compile() {
- // TODO Auto-generated method stub
- return null;
- }
}