Reworked intent states to the new set of states.
Separate intent state from intent event type.
Implemented new state transitions in IntentManager.
Implemented ObjectiveTracker.
Re-route now works.
diff --git a/core/api/src/main/java/org/onlab/onos/net/intent/AbstractIntent.java b/core/api/src/main/java/org/onlab/onos/net/intent/AbstractIntent.java
index eefe750..c8a4a05 100644
--- a/core/api/src/main/java/org/onlab/onos/net/intent/AbstractIntent.java
+++ b/core/api/src/main/java/org/onlab/onos/net/intent/AbstractIntent.java
@@ -24,7 +24,7 @@
}
@Override
- public IntentId getId() {
+ public IntentId id() {
return id;
}
diff --git a/core/api/src/main/java/org/onlab/onos/net/intent/ConnectivityIntent.java b/core/api/src/main/java/org/onlab/onos/net/intent/ConnectivityIntent.java
index 70cec58..ed0c5cc 100644
--- a/core/api/src/main/java/org/onlab/onos/net/intent/ConnectivityIntent.java
+++ b/core/api/src/main/java/org/onlab/onos/net/intent/ConnectivityIntent.java
@@ -53,7 +53,7 @@
*
* @return traffic match
*/
- public TrafficSelector getTrafficSelector() {
+ public TrafficSelector selector() {
return selector;
}
@@ -62,7 +62,7 @@
*
* @return applied action
*/
- public TrafficTreatment getTrafficTreatment() {
+ public TrafficTreatment treatment() {
return treatment;
}
diff --git a/core/api/src/main/java/org/onlab/onos/net/intent/HostToHostIntent.java b/core/api/src/main/java/org/onlab/onos/net/intent/HostToHostIntent.java
index 7cef3da..f420fc2 100644
--- a/core/api/src/main/java/org/onlab/onos/net/intent/HostToHostIntent.java
+++ b/core/api/src/main/java/org/onlab/onos/net/intent/HostToHostIntent.java
@@ -80,9 +80,9 @@
@Override
public String toString() {
return MoreObjects.toStringHelper(getClass())
- .add("id", getId())
- .add("selector", getTrafficSelector())
- .add("treatment", getTrafficTreatment())
+ .add("id", id())
+ .add("selector", selector())
+ .add("treatment", treatment())
.add("one", one)
.add("two", two)
.toString();
diff --git a/core/api/src/main/java/org/onlab/onos/net/intent/Intent.java b/core/api/src/main/java/org/onlab/onos/net/intent/Intent.java
index d4c630a..3e339d1 100644
--- a/core/api/src/main/java/org/onlab/onos/net/intent/Intent.java
+++ b/core/api/src/main/java/org/onlab/onos/net/intent/Intent.java
@@ -11,5 +11,5 @@
*
* @return intent identifier
*/
- IntentId getId();
+ IntentId id();
}
diff --git a/core/api/src/main/java/org/onlab/onos/net/intent/IntentEvent.java b/core/api/src/main/java/org/onlab/onos/net/intent/IntentEvent.java
index c98e788..742a590 100644
--- a/core/api/src/main/java/org/onlab/onos/net/intent/IntentEvent.java
+++ b/core/api/src/main/java/org/onlab/onos/net/intent/IntentEvent.java
@@ -1,106 +1,55 @@
package org.onlab.onos.net.intent;
-import com.google.common.base.MoreObjects;
import org.onlab.onos.event.AbstractEvent;
-import java.util.Objects;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
/**
* A class to represent an intent related event.
*/
-public class IntentEvent extends AbstractEvent<IntentState, Intent> {
+public class IntentEvent extends AbstractEvent<IntentEvent.Type, Intent> {
- // TODO: determine a suitable parent class; if one does not exist, consider
- // introducing one
+ public enum Type {
+ /**
+ * Signifies that a new intent has been submitted to the system.
+ */
+ SUBMITTED,
- private final long time;
- private final Intent intent;
- private final IntentState state;
- private final IntentState previous;
+ /**
+ * Signifies that an intent has been successfully installed.
+ */
+ INSTALLED,
- /**
- * Creates an event describing a state change of an intent.
- *
- * @param intent subject intent
- * @param state new intent state
- * @param previous previous intent state
- * @param time time the event created in milliseconds since start of epoch
- * @throws NullPointerException if the intent or state is null
- */
- public IntentEvent(Intent intent, IntentState state, IntentState previous, long time) {
- super(state, intent);
- this.intent = checkNotNull(intent);
- this.state = checkNotNull(state);
- this.previous = previous;
- this.time = time;
+ /**
+ * Signifies that an intent has failed compilation or installation.
+ */
+ FAILED,
+
+ /**
+ * Signifies that an intent has been withdrawn from the system.
+ */
+ WITHDRAWN
}
/**
- * Returns the state of the intent which caused the event.
+ * Creates an event of a given type and for the specified intent and the
+ * current time.
*
- * @return the state of the intent
+ * @param type event type
+ * @param intent subject intent
+ * @param time time the event created in milliseconds since start of epoch
*/
- public IntentState getState() {
- return state;
+ public IntentEvent(Type type, Intent intent, long time) {
+ super(type, intent, time);
}
/**
- * Returns the previous state of the intent which caused the event.
+ * Creates an event of a given type and for the specified intent and the
+ * current time.
*
- * @return the previous state of the intent
+ * @param type event type
+ * @param intent subject intent
*/
- public IntentState getPreviousState() {
- return previous;
+ public IntentEvent(Type type, Intent intent) {
+ super(type, intent);
}
- /**
- * Returns the intent associated with the event.
- *
- * @return the intent
- */
- public Intent getIntent() {
- return intent;
- }
-
- /**
- * Returns the time at which the event was created.
- *
- * @return the time in milliseconds since start of epoch
- */
- public long getTime() {
- return time;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
-
- IntentEvent that = (IntentEvent) o;
- return Objects.equals(this.intent, that.intent)
- && Objects.equals(this.state, that.state)
- && Objects.equals(this.previous, that.previous)
- && Objects.equals(this.time, that.time);
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(intent, state, previous, time);
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("intent", intent)
- .add("state", state)
- .add("previous", previous)
- .add("time", time)
- .toString();
- }
}
diff --git a/core/api/src/main/java/org/onlab/onos/net/intent/IntentState.java b/core/api/src/main/java/org/onlab/onos/net/intent/IntentState.java
index 20476e5..bd140af 100644
--- a/core/api/src/main/java/org/onlab/onos/net/intent/IntentState.java
+++ b/core/api/src/main/java/org/onlab/onos/net/intent/IntentState.java
@@ -1,55 +1,70 @@
package org.onlab.onos.net.intent;
/**
- * This class represents the states of an intent.
- *
- * <p>
- * Note: The state is expressed as enum, but there is possibility
- * in the future that we define specific class instead of enum to improve
- * the extensibility of state definition.
- * </p>
+ * Representation of the phases an intent may attain during its lifecycle.
*/
public enum IntentState {
- // FIXME: requires discussion on State vs. EventType and a solid state-transition diagram
- // TODO: consider the impact of conflict detection
- // TODO: consider the impact that external events affect an installed intent
+
/**
- * The beginning state.
- *
+ * Signifies that the intent has been submitted and will start compiling
+ * shortly. However, this compilation may not necessarily occur on the
+ * local controller instance.
+ * <p/>
* All intent in the runtime take this state first.
*/
SUBMITTED,
/**
- * The intent compilation has been completed.
- *
- * An intent translation graph (tree) is completely created.
- * Leaves of the graph are installable intent type.
+ * Signifies that the intent is being compiled into installable intents.
+ * This is a transitional state after which the intent will enter either
+ * {@link #FAILED} state or {@link #INSTALLING} state.
*/
- COMPILED,
+ COMPILING,
/**
- * The intent has been successfully installed.
+ * Signifies that the resulting installable intents are being installed
+ * into the network environment. This is a transitional state after which
+ * the intent will enter either {@link #INSTALLED} state or
+ * {@link #RECOMPILING} state.
+ */
+ INSTALLING,
+
+ /**
+ * The intent has been successfully installed. This is a state where the
+ * intent may remain parked until it is withdrawn by the application or
+ * until the network environment changes in some way to make the original
+ * set of installable intents untenable.
*/
INSTALLED,
/**
- * The intent is being withdrawn.
- *
- * When {@link IntentService#withdraw(Intent)} is called,
- * the intent takes this state first.
+ * Signifies that the intent is being recompiled into installable intents
+ * as an attempt to adapt to an anomaly in the network environment.
+ * This is a transitional state after which the intent will enter either
+ * {@link #FAILED} state or {@link #INSTALLING} state.
+ * <p/>
+ * Exit to the {@link #FAILED} state may be caused by failure to compile
+ * or by compiling into the same set of installable intents which have
+ * previously failed to be installed.
+ */
+ RECOMPILING,
+
+ /**
+ * Indicates that the intent is being withdrawn. This is a transitional
+ * state, triggered by invocation of the
+ * {@link IntentService#withdraw(Intent)} but one with only one outcome,
+ * which is the the intent being placed in the {@link #WITHDRAWN} state.
*/
WITHDRAWING,
/**
- * The intent has been successfully withdrawn.
+ * Indicates that the intent has been successfully withdrawn.
*/
WITHDRAWN,
/**
- * The intent has failed to be compiled, installed, or withdrawn.
- *
- * When the intent failed to be withdrawn, it is still, at least partially installed.
+ * Signifies that the intent has failed compiling, installing or
+ * recompiling states.
*/
- FAILED,
+ FAILED
}
diff --git a/core/api/src/main/java/org/onlab/onos/net/intent/IntentStore.java b/core/api/src/main/java/org/onlab/onos/net/intent/IntentStore.java
index 037f179..fc023bb 100644
--- a/core/api/src/main/java/org/onlab/onos/net/intent/IntentStore.java
+++ b/core/api/src/main/java/org/onlab/onos/net/intent/IntentStore.java
@@ -10,10 +10,16 @@
public interface IntentStore extends Store<IntentEvent, IntentStoreDelegate> {
/**
- * Creates a new intent.
+ * Submits a new intent into the store. If the returned event is not
+ * null, the manager is expected to dispatch the event and then to kick
+ * off intent compilation process. Otherwise, another node has been elected
+ * to perform the compilation process and the node will learn about
+ * the submittal and results of the intent compilation via the delegate
+ * mechanism.
*
- * @param intent intent
- * @return appropriate event or null if no change resulted
+ * @param intent intent to be submitted
+ * @return event indicating the intent was submitted or null if no
+ * change resulted, e.g. duplicate intent
*/
IntentEvent createIntent(Intent intent);
@@ -68,10 +74,9 @@
*
* @param intentId original intent identifier
* @param installableIntents compiled installable intents
- * @return compiled state transition event
*/
- IntentEvent addInstallableIntents(IntentId intentId,
- List<InstallableIntent> installableIntents);
+ void addInstallableIntents(IntentId intentId,
+ List<InstallableIntent> installableIntents);
/**
* Returns the list of the installable events associated with the specified
diff --git a/core/api/src/main/java/org/onlab/onos/net/intent/MultiPointToSinglePointIntent.java b/core/api/src/main/java/org/onlab/onos/net/intent/MultiPointToSinglePointIntent.java
index af1e84b..be8d309 100644
--- a/core/api/src/main/java/org/onlab/onos/net/intent/MultiPointToSinglePointIntent.java
+++ b/core/api/src/main/java/org/onlab/onos/net/intent/MultiPointToSinglePointIntent.java
@@ -1,25 +1,24 @@
package org.onlab.onos.net.intent;
-import static com.google.common.base.Preconditions.checkArgument;
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.util.Objects;
-import java.util.Set;
-
+import com.google.common.base.MoreObjects;
+import com.google.common.collect.Sets;
import org.onlab.onos.net.ConnectPoint;
import org.onlab.onos.net.flow.TrafficSelector;
import org.onlab.onos.net.flow.TrafficTreatment;
-import com.google.common.base.MoreObjects;
-import com.google.common.collect.Sets;
+import java.util.Objects;
+import java.util.Set;
+
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkNotNull;
/**
* Abstraction of multiple source to single destination connectivity intent.
*/
public class MultiPointToSinglePointIntent extends ConnectivityIntent {
- private final Set<ConnectPoint> ingressPorts;
- private final ConnectPoint egressPort;
+ private final Set<ConnectPoint> ingressPoints;
+ private final ConnectPoint egressPoint;
/**
* Creates a new multi-to-single point connectivity intent for the specified
@@ -28,25 +27,25 @@
* @param id intent identifier
* @param match traffic match
* @param action action
- * @param ingressPorts set of ports from which ingress traffic originates
- * @param egressPort port to which traffic will egress
- * @throws NullPointerException if {@code ingressPorts} or
- * {@code egressPort} is null.
- * @throws IllegalArgumentException if the size of {@code ingressPorts} is
+ * @param ingressPoints set of ports from which ingress traffic originates
+ * @param egressPoint port to which traffic will egress
+ * @throws NullPointerException if {@code ingressPoints} or
+ * {@code egressPoint} is null.
+ * @throws IllegalArgumentException if the size of {@code ingressPoints} is
* not more than 1
*/
public MultiPointToSinglePointIntent(IntentId id, TrafficSelector match,
TrafficTreatment action,
- Set<ConnectPoint> ingressPorts,
- ConnectPoint egressPort) {
+ Set<ConnectPoint> ingressPoints,
+ ConnectPoint egressPoint) {
super(id, match, action);
- checkNotNull(ingressPorts);
- checkArgument(!ingressPorts.isEmpty(),
+ checkNotNull(ingressPoints);
+ checkArgument(!ingressPoints.isEmpty(),
"there should be at least one ingress port");
- this.ingressPorts = Sets.newHashSet(ingressPorts);
- this.egressPort = checkNotNull(egressPort);
+ this.ingressPoints = Sets.newHashSet(ingressPoints);
+ this.egressPoint = checkNotNull(egressPoint);
}
/**
@@ -54,8 +53,8 @@
*/
protected MultiPointToSinglePointIntent() {
super();
- this.ingressPorts = null;
- this.egressPort = null;
+ this.ingressPoints = null;
+ this.egressPoint = null;
}
/**
@@ -64,8 +63,8 @@
*
* @return set of ingress ports
*/
- public Set<ConnectPoint> getIngressPorts() {
- return ingressPorts;
+ public Set<ConnectPoint> ingressPoints() {
+ return ingressPoints;
}
/**
@@ -73,8 +72,8 @@
*
* @return egress port
*/
- public ConnectPoint getEgressPort() {
- return egressPort;
+ public ConnectPoint egressPoint() {
+ return egressPoint;
}
@Override
@@ -90,23 +89,23 @@
}
MultiPointToSinglePointIntent that = (MultiPointToSinglePointIntent) o;
- return Objects.equals(this.ingressPorts, that.ingressPorts)
- && Objects.equals(this.egressPort, that.egressPort);
+ return Objects.equals(this.ingressPoints, that.ingressPoints)
+ && Objects.equals(this.egressPoint, that.egressPoint);
}
@Override
public int hashCode() {
- return Objects.hash(super.hashCode(), ingressPorts, egressPort);
+ return Objects.hash(super.hashCode(), ingressPoints, egressPoint);
}
@Override
public String toString() {
return MoreObjects.toStringHelper(getClass())
- .add("id", getId())
- .add("match", getTrafficSelector())
- .add("action", getTrafficTreatment())
- .add("ingressPorts", getIngressPorts())
- .add("egressPort", getEgressPort())
+ .add("id", id())
+ .add("match", selector())
+ .add("action", treatment())
+ .add("ingressPoints", ingressPoints())
+ .add("egressPoint", egressPoint())
.toString();
}
}
diff --git a/core/api/src/main/java/org/onlab/onos/net/intent/PathIntent.java b/core/api/src/main/java/org/onlab/onos/net/intent/PathIntent.java
index 4c3486f..ff2e917 100644
--- a/core/api/src/main/java/org/onlab/onos/net/intent/PathIntent.java
+++ b/core/api/src/main/java/org/onlab/onos/net/intent/PathIntent.java
@@ -46,7 +46,7 @@
*
* @return traversed links
*/
- public Path getPath() {
+ public Path path() {
return path;
}
@@ -79,11 +79,11 @@
@Override
public String toString() {
return MoreObjects.toStringHelper(getClass())
- .add("id", getId())
- .add("match", getTrafficSelector())
- .add("action", getTrafficTreatment())
- .add("ingressPort", getIngressPort())
- .add("egressPort", getEgressPort())
+ .add("id", id())
+ .add("match", selector())
+ .add("action", treatment())
+ .add("ingressPort", ingressPoint())
+ .add("egressPort", egressPoint())
.add("path", path)
.toString();
}
diff --git a/core/api/src/main/java/org/onlab/onos/net/intent/PointToPointIntent.java b/core/api/src/main/java/org/onlab/onos/net/intent/PointToPointIntent.java
index 4c86bae..7b7c18a 100644
--- a/core/api/src/main/java/org/onlab/onos/net/intent/PointToPointIntent.java
+++ b/core/api/src/main/java/org/onlab/onos/net/intent/PointToPointIntent.java
@@ -14,27 +14,27 @@
*/
public class PointToPointIntent extends ConnectivityIntent {
- private final ConnectPoint ingressPort;
- private final ConnectPoint egressPort;
+ private final ConnectPoint ingressPoint;
+ private final ConnectPoint egressPoint;
/**
* Creates a new point-to-point intent with the supplied ingress/egress
* ports.
*
- * @param id intent identifier
- * @param selector traffic selector
- * @param treatment treatment
- * @param ingressPort ingress port
- * @param egressPort egress port
- * @throws NullPointerException if {@code ingressPort} or {@code egressPort} is null.
+ * @param id intent identifier
+ * @param selector traffic selector
+ * @param treatment treatment
+ * @param ingressPoint ingress port
+ * @param egressPoint egress port
+ * @throws NullPointerException if {@code ingressPoint} or {@code egressPoints} is null.
*/
public PointToPointIntent(IntentId id, TrafficSelector selector,
TrafficTreatment treatment,
- ConnectPoint ingressPort,
- ConnectPoint egressPort) {
+ ConnectPoint ingressPoint,
+ ConnectPoint egressPoint) {
super(id, selector, treatment);
- this.ingressPort = checkNotNull(ingressPort);
- this.egressPort = checkNotNull(egressPort);
+ this.ingressPoint = checkNotNull(ingressPoint);
+ this.egressPoint = checkNotNull(egressPoint);
}
/**
@@ -42,8 +42,8 @@
*/
protected PointToPointIntent() {
super();
- this.ingressPort = null;
- this.egressPort = null;
+ this.ingressPoint = null;
+ this.egressPoint = null;
}
/**
@@ -52,8 +52,8 @@
*
* @return ingress port
*/
- public ConnectPoint getIngressPort() {
- return ingressPort;
+ public ConnectPoint ingressPoint() {
+ return ingressPoint;
}
/**
@@ -61,8 +61,8 @@
*
* @return egress port
*/
- public ConnectPoint getEgressPort() {
- return egressPort;
+ public ConnectPoint egressPoint() {
+ return egressPoint;
}
@Override
@@ -78,23 +78,23 @@
}
PointToPointIntent that = (PointToPointIntent) o;
- return Objects.equals(this.ingressPort, that.ingressPort)
- && Objects.equals(this.egressPort, that.egressPort);
+ return Objects.equals(this.ingressPoint, that.ingressPoint)
+ && Objects.equals(this.egressPoint, that.egressPoint);
}
@Override
public int hashCode() {
- return Objects.hash(super.hashCode(), ingressPort, egressPort);
+ return Objects.hash(super.hashCode(), ingressPoint, egressPoint);
}
@Override
public String toString() {
return MoreObjects.toStringHelper(getClass())
- .add("id", getId())
- .add("match", getTrafficSelector())
- .add("action", getTrafficTreatment())
- .add("ingressPort", ingressPort)
- .add("egressPort", egressPort)
+ .add("id", id())
+ .add("match", selector())
+ .add("action", treatment())
+ .add("ingressPoint", ingressPoint)
+ .add("egressPoints", egressPoint)
.toString();
}
diff --git a/core/api/src/main/java/org/onlab/onos/net/intent/SinglePointToMultiPointIntent.java b/core/api/src/main/java/org/onlab/onos/net/intent/SinglePointToMultiPointIntent.java
index af2616b..2a17bfe 100644
--- a/core/api/src/main/java/org/onlab/onos/net/intent/SinglePointToMultiPointIntent.java
+++ b/core/api/src/main/java/org/onlab/onos/net/intent/SinglePointToMultiPointIntent.java
@@ -17,34 +17,34 @@
*/
public class SinglePointToMultiPointIntent extends ConnectivityIntent {
- private final ConnectPoint ingressPort;
- private final Set<ConnectPoint> egressPorts;
+ private final ConnectPoint ingressPoint;
+ private final Set<ConnectPoint> egressPoints;
/**
* Creates a new single-to-multi point connectivity intent.
*
- * @param id intent identifier
- * @param selector traffic selector
- * @param treatment treatment
- * @param ingressPort port on which traffic will ingress
- * @param egressPorts set of ports on which traffic will egress
- * @throws NullPointerException if {@code ingressPort} or
- * {@code egressPorts} is null
- * @throws IllegalArgumentException if the size of {@code egressPorts} is
+ * @param id intent identifier
+ * @param selector traffic selector
+ * @param treatment treatment
+ * @param ingressPoint port on which traffic will ingress
+ * @param egressPoints set of ports on which traffic will egress
+ * @throws NullPointerException if {@code ingressPoint} or
+ * {@code egressPoints} is null
+ * @throws IllegalArgumentException if the size of {@code egressPoints} is
* not more than 1
*/
public SinglePointToMultiPointIntent(IntentId id, TrafficSelector selector,
TrafficTreatment treatment,
- ConnectPoint ingressPort,
- Set<ConnectPoint> egressPorts) {
+ ConnectPoint ingressPoint,
+ Set<ConnectPoint> egressPoints) {
super(id, selector, treatment);
- checkNotNull(egressPorts);
- checkArgument(!egressPorts.isEmpty(),
+ checkNotNull(egressPoints);
+ checkArgument(!egressPoints.isEmpty(),
"there should be at least one egress port");
- this.ingressPort = checkNotNull(ingressPort);
- this.egressPorts = Sets.newHashSet(egressPorts);
+ this.ingressPoint = checkNotNull(ingressPoint);
+ this.egressPoints = Sets.newHashSet(egressPoints);
}
/**
@@ -52,8 +52,8 @@
*/
protected SinglePointToMultiPointIntent() {
super();
- this.ingressPort = null;
- this.egressPorts = null;
+ this.ingressPoint = null;
+ this.egressPoints = null;
}
/**
@@ -61,8 +61,8 @@
*
* @return ingress port
*/
- public ConnectPoint getIngressPort() {
- return ingressPort;
+ public ConnectPoint ingressPoint() {
+ return ingressPoint;
}
/**
@@ -70,8 +70,8 @@
*
* @return set of egress ports
*/
- public Set<ConnectPoint> getEgressPorts() {
- return egressPorts;
+ public Set<ConnectPoint> egressPoints() {
+ return egressPoints;
}
@Override
@@ -87,23 +87,23 @@
}
SinglePointToMultiPointIntent that = (SinglePointToMultiPointIntent) o;
- return Objects.equals(this.ingressPort, that.ingressPort)
- && Objects.equals(this.egressPorts, that.egressPorts);
+ return Objects.equals(this.ingressPoint, that.ingressPoint)
+ && Objects.equals(this.egressPoints, that.egressPoints);
}
@Override
public int hashCode() {
- return Objects.hash(super.hashCode(), ingressPort, egressPorts);
+ return Objects.hash(super.hashCode(), ingressPoint, egressPoints);
}
@Override
public String toString() {
return MoreObjects.toStringHelper(getClass())
- .add("id", getId())
- .add("match", getTrafficSelector())
- .add("action", getTrafficTreatment())
- .add("ingressPort", ingressPort)
- .add("egressPort", egressPorts)
+ .add("id", id())
+ .add("match", selector())
+ .add("action", treatment())
+ .add("ingressPoint", ingressPoint)
+ .add("egressPort", egressPoints)
.toString();
}