Starting to experiment with flow tracking.
diff --git a/core/api/src/main/java/org/onlab/onos/net/LinkKey.java b/core/api/src/main/java/org/onlab/onos/net/LinkKey.java
index dee4e88..d3ff0f4 100644
--- a/core/api/src/main/java/org/onlab/onos/net/LinkKey.java
+++ b/core/api/src/main/java/org/onlab/onos/net/LinkKey.java
@@ -6,6 +6,7 @@
// TODO Consider renaming.
// it's an identifier for a Link, but it's not ElementId, so not using LinkId.
+
/**
* Immutable representation of a link identity.
*/
@@ -43,6 +44,15 @@
this.dst = dst;
}
+ /**
+ * Creates a link identifier for the specified link.
+ *
+ * @param link link descriptor
+ */
+ public LinkKey(Link link) {
+ this(link.src(), link.dst());
+ }
+
@Override
public int hashCode() {
return Objects.hash(src(), dst);
diff --git a/core/api/src/main/java/org/onlab/onos/net/intent/InstallableIntent.java b/core/api/src/main/java/org/onlab/onos/net/intent/InstallableIntent.java
index 66bc759..488695c 100644
--- a/core/api/src/main/java/org/onlab/onos/net/intent/InstallableIntent.java
+++ b/core/api/src/main/java/org/onlab/onos/net/intent/InstallableIntent.java
@@ -1,8 +1,22 @@
package org.onlab.onos.net.intent;
+import org.onlab.onos.net.Link;
+
+import java.util.Collection;
+
/**
* Abstraction of an intent that can be installed into
* the underlying system without additional compilation.
*/
public interface InstallableIntent extends Intent {
+
+ /**
+ * Returns the collection of links that are required for this installable
+ * intent to exist.
+ *
+ * @return collection of links
+ */
+ // FIXME: replace this with 'NetworkResource'
+ Collection<Link> requiredLinks();
+
}
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 6809ce2..4c3486f 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
@@ -1,13 +1,14 @@
package org.onlab.onos.net.intent;
-import java.util.Objects;
-
+import com.google.common.base.MoreObjects;
import org.onlab.onos.net.ConnectPoint;
+import org.onlab.onos.net.Link;
import org.onlab.onos.net.Path;
import org.onlab.onos.net.flow.TrafficSelector;
import org.onlab.onos.net.flow.TrafficTreatment;
-import com.google.common.base.MoreObjects;
+import java.util.Collection;
+import java.util.Objects;
/**
* Abstraction of explicitly path specified connectivity intent.
@@ -86,4 +87,10 @@
.add("path", path)
.toString();
}
+
+ @Override
+ public Collection<Link> requiredLinks() {
+ return path.links();
+ }
+
}
diff --git a/core/api/src/main/java/org/onlab/onos/net/topology/TopologyEvent.java b/core/api/src/main/java/org/onlab/onos/net/topology/TopologyEvent.java
index 0be5323..268b6ac 100644
--- a/core/api/src/main/java/org/onlab/onos/net/topology/TopologyEvent.java
+++ b/core/api/src/main/java/org/onlab/onos/net/topology/TopologyEvent.java
@@ -1,12 +1,17 @@
package org.onlab.onos.net.topology;
import org.onlab.onos.event.AbstractEvent;
+import org.onlab.onos.event.Event;
+
+import java.util.List;
/**
* Describes network topology event.
*/
public class TopologyEvent extends AbstractEvent<TopologyEvent.Type, Topology> {
+ private final List<Event> reasons;
+
/**
* Type of topology events.
*/
@@ -23,9 +28,11 @@
*
* @param type topology event type
* @param topology event topology subject
+ * @param reasons list of events that triggered topology change
*/
- public TopologyEvent(Type type, Topology topology) {
+ public TopologyEvent(Type type, Topology topology, List<Event> reasons) {
super(type, topology);
+ this.reasons = reasons;
}
/**
@@ -33,10 +40,24 @@
*
* @param type link event type
* @param topology event topology subject
+ * @param reasons list of events that triggered topology change
* @param time occurrence time
*/
- public TopologyEvent(Type type, Topology topology, long time) {
+ public TopologyEvent(Type type, Topology topology, List<Event> reasons,
+ long time) {
super(type, topology, time);
+ this.reasons = reasons;
+ }
+
+
+ /**
+ * Returns the list of events that triggered the topology change.
+ *
+ * @return list of events responsible for change in topology; null if
+ * initial topology computation
+ */
+ public List<Event> reasons() {
+ return reasons;
}
}