Re-assembled the topology subsystem.
diff --git a/core/api/src/main/java/org/onlab/onos/net/DefaultLink.java b/core/api/src/main/java/org/onlab/onos/net/DefaultLink.java
index 1f7783c..e937bf3 100644
--- a/core/api/src/main/java/org/onlab/onos/net/DefaultLink.java
+++ b/core/api/src/main/java/org/onlab/onos/net/DefaultLink.java
@@ -16,7 +16,7 @@
private final Type type;
/**
- * Creates a link description using the supplied information.
+ * Creates an infrastructure link using the supplied information.
*
* @param providerId provider identity
* @param src link source
diff --git a/core/api/src/main/java/org/onlab/onos/net/DefaultPath.java b/core/api/src/main/java/org/onlab/onos/net/DefaultPath.java
new file mode 100644
index 0000000..63c9e88
--- /dev/null
+++ b/core/api/src/main/java/org/onlab/onos/net/DefaultPath.java
@@ -0,0 +1,71 @@
+package org.onlab.onos.net;
+
+import com.google.common.collect.ImmutableList;
+import org.onlab.onos.net.provider.ProviderId;
+
+import java.util.List;
+import java.util.Objects;
+
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+/**
+ * Default implementation of a network path.
+ */
+public class DefaultPath extends DefaultLink implements Path {
+
+ private final List<Link> links;
+ private final double cost;
+
+ /**
+ * Creates a path from the specified source and destination using the
+ * supplied list of links.
+ *
+ * @param providerId provider identity
+ * @param links contiguous links that comprise the path
+ * @param cost unit-less path cost
+ */
+ public DefaultPath(ProviderId providerId, List<Link> links, double cost) {
+ super(providerId, source(links), destination(links), Type.INDIRECT);
+ this.links = ImmutableList.copyOf(links);
+ this.cost = cost;
+ }
+
+ @Override
+ public List<Link> links() {
+ return links;
+ }
+
+ @Override
+ public double cost() {
+ return cost;
+ }
+
+ // Returns the source of the first link.
+ private static ConnectPoint source(List<Link> links) {
+ checkNotNull(links, "List of path links cannot be null");
+ checkArgument(!links.isEmpty(), "List of path links cannot be empty");
+ return links.get(0).src();
+ }
+
+ // Returns the destination of the last link.
+ private static ConnectPoint destination(List<Link> links) {
+ checkNotNull(links, "List of path links cannot be null");
+ checkArgument(!links.isEmpty(), "List of path links cannot be empty");
+ return links.get(links.size() - 1).dst();
+ }
+
+ @Override
+ public int hashCode() {
+ return 31 * super.hashCode() + Objects.hash(links);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj instanceof DefaultPath) {
+ final DefaultPath other = (DefaultPath) obj;
+ return Objects.equals(this.links, other.links);
+ }
+ return false;
+ }
+}
diff --git a/core/api/src/main/java/org/onlab/onos/net/Path.java b/core/api/src/main/java/org/onlab/onos/net/Path.java
index 22a363a..acf8170 100644
--- a/core/api/src/main/java/org/onlab/onos/net/Path.java
+++ b/core/api/src/main/java/org/onlab/onos/net/Path.java
@@ -17,4 +17,11 @@
*/
List<Link> links();
+ /**
+ * Returns the path cost as a unit-less value.
+ *
+ * @return unit-less path cost
+ */
+ double cost();
+
}
diff --git a/core/api/src/main/java/org/onlab/onos/net/topology/ClusterId.java b/core/api/src/main/java/org/onlab/onos/net/topology/ClusterId.java
index af8f122..502eee1 100644
--- a/core/api/src/main/java/org/onlab/onos/net/topology/ClusterId.java
+++ b/core/api/src/main/java/org/onlab/onos/net/topology/ClusterId.java
@@ -27,6 +27,15 @@
return new ClusterId(id);
}
+ /**
+ * Returns the backing integer index.
+ *
+ * @return backing integer index
+ */
+ public int index() {
+ return id;
+ }
+
@Override
public int hashCode() {
return Objects.hash(id);
diff --git a/core/api/src/main/java/org/onlab/onos/net/topology/GraphDescription.java b/core/api/src/main/java/org/onlab/onos/net/topology/GraphDescription.java
new file mode 100644
index 0000000..2b846a0
--- /dev/null
+++ b/core/api/src/main/java/org/onlab/onos/net/topology/GraphDescription.java
@@ -0,0 +1,34 @@
+package org.onlab.onos.net.topology;
+
+import com.google.common.collect.ImmutableSet;
+import org.onlab.onos.net.Description;
+
+/**
+ * Describes attribute(s) of a network graph.
+ */
+public interface GraphDescription extends Description {
+
+ /**
+ * Returns the creation timestamp of the graph description. This is
+ * expressed in system nanos to allow proper sequencing.
+ *
+ * @return graph description creation timestamp
+ */
+ long timestamp();
+
+ /**
+ * Returns the set of topology graph vertexes.
+ *
+ * @return set of graph vertexes
+ */
+ ImmutableSet<TopologyVertex> vertexes();
+
+ /**
+ * Returns the set of topology graph edges.
+ *
+ * @return set of graph edges
+ */
+ ImmutableSet<TopologyEdge> edges();
+
+}
+
diff --git a/core/api/src/main/java/org/onlab/onos/net/topology/LinkWeight.java b/core/api/src/main/java/org/onlab/onos/net/topology/LinkWeight.java
index 89ef577..5e18dfb 100644
--- a/core/api/src/main/java/org/onlab/onos/net/topology/LinkWeight.java
+++ b/core/api/src/main/java/org/onlab/onos/net/topology/LinkWeight.java
@@ -6,5 +6,5 @@
* Entity capable of determining cost or weight of a specified topology
* graph edge.
*/
-public interface LinkWeight extends EdgeWeight<TopoVertex, TopoEdge> {
+public interface LinkWeight extends EdgeWeight<TopologyVertex, TopologyEdge> {
}
diff --git a/core/api/src/main/java/org/onlab/onos/net/topology/TopologyDescription.java b/core/api/src/main/java/org/onlab/onos/net/topology/TopologyDescription.java
deleted file mode 100644
index bcb199d..0000000
--- a/core/api/src/main/java/org/onlab/onos/net/topology/TopologyDescription.java
+++ /dev/null
@@ -1,62 +0,0 @@
-package org.onlab.onos.net.topology;
-
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.ImmutableSetMultimap;
-import org.onlab.graph.Graph;
-import org.onlab.onos.net.Description;
-import org.onlab.onos.net.DeviceId;
-import org.onlab.onos.net.Link;
-
-import static org.onlab.graph.GraphPathSearch.Result;
-
-/**
- * Describes attribute(s) of a network topology.
- */
-public interface TopologyDescription extends Description {
-
- /**
- * Returns the creation timestamp of the topology description. This is
- * expressed in system nanos to allow proper sequencing.
- *
- * @return topology description creation timestamp
- */
- long timestamp();
-
- /**
- * Returns the topology graph in immutable form.
- *
- * @return network graph
- */
- Graph<TopoVertex, TopoEdge> graph();
-
- /**
- * Returns an immutable map of path search results for each source device.
- *
- * @return map of path search result for each source node
- */
- ImmutableMap<DeviceId, Result<TopoVertex, TopoEdge>> pathsBySource();
-
- /**
- * Returns the set of topology SCC clusters.
- *
- * @return set of SCC clusters
- */
- ImmutableSet<TopologyCluster> clusters();
-
- /**
- * Returns an immutable set multi-map of devices for each cluster.
- *
- * @return set multi-map of devices that belong to each cluster
- */
- ImmutableSetMultimap<TopologyCluster, DeviceId> devicesByCluster();
-
- /**
- * Returns an immutable set multi-map of links for each cluster.
- *
- * @return set multi-map of links that belong to each cluster
- */
- ImmutableSetMultimap<TopologyCluster, Link> linksByCluster();
-
-}
-
diff --git a/core/api/src/main/java/org/onlab/onos/net/topology/TopoEdge.java b/core/api/src/main/java/org/onlab/onos/net/topology/TopologyEdge.java
similarity index 82%
rename from core/api/src/main/java/org/onlab/onos/net/topology/TopoEdge.java
rename to core/api/src/main/java/org/onlab/onos/net/topology/TopologyEdge.java
index ef94eca..d9cd6f4 100644
--- a/core/api/src/main/java/org/onlab/onos/net/topology/TopoEdge.java
+++ b/core/api/src/main/java/org/onlab/onos/net/topology/TopologyEdge.java
@@ -6,7 +6,7 @@
/**
* Represents an edge in the topology graph.
*/
-public interface TopoEdge extends Edge<TopoVertex> {
+public interface TopologyEdge extends Edge<TopologyVertex> {
/**
* Returns the associated infrastructure link.
diff --git a/core/api/src/main/java/org/onlab/onos/net/topology/TopologyGraph.java b/core/api/src/main/java/org/onlab/onos/net/topology/TopologyGraph.java
new file mode 100644
index 0000000..70139cd
--- /dev/null
+++ b/core/api/src/main/java/org/onlab/onos/net/topology/TopologyGraph.java
@@ -0,0 +1,10 @@
+package org.onlab.onos.net.topology;
+
+import org.onlab.graph.Graph;
+
+/**
+ * Represents an immutable topology graph.
+ */
+public interface TopologyGraph extends Graph<TopologyVertex, TopologyEdge> {
+
+}
diff --git a/core/api/src/main/java/org/onlab/onos/net/topology/TopologyProviderService.java b/core/api/src/main/java/org/onlab/onos/net/topology/TopologyProviderService.java
index 0e03767..c81a871 100644
--- a/core/api/src/main/java/org/onlab/onos/net/topology/TopologyProviderService.java
+++ b/core/api/src/main/java/org/onlab/onos/net/topology/TopologyProviderService.java
@@ -10,16 +10,13 @@
*/
public interface TopologyProviderService extends ProviderService<TopologyProvider> {
- // What can be conveyed in a topology that isn't by individual
- // providers?
-
/**
* Signals the core that some aspect of the topology has changed.
*
- * @param topoDescription information about topology
- * @param reasons events that triggered topology change
+ * @param graphDescription information about the network graph
+ * @param reasons events that triggered topology change
*/
- void topologyChanged(TopologyDescription topoDescription,
+ void topologyChanged(GraphDescription graphDescription,
List<Event> reasons);
}
diff --git a/core/api/src/main/java/org/onlab/onos/net/topology/TopologyService.java b/core/api/src/main/java/org/onlab/onos/net/topology/TopologyService.java
index 149804b..d8470e7 100644
--- a/core/api/src/main/java/org/onlab/onos/net/topology/TopologyService.java
+++ b/core/api/src/main/java/org/onlab/onos/net/topology/TopologyService.java
@@ -1,6 +1,5 @@
package org.onlab.onos.net.topology;
-import org.onlab.graph.Graph;
import org.onlab.onos.net.ConnectPoint;
import org.onlab.onos.net.DeviceId;
import org.onlab.onos.net.Path;
@@ -41,7 +40,7 @@
* @param topology topology descriptor
* @return topology graph view
*/
- Graph<TopoVertex, TopoEdge> getGraph(Topology topology);
+ TopologyGraph getGraph(Topology topology);
/**
* Returns the set of all shortest paths, precomputed in terms of hop-count,
diff --git a/core/api/src/main/java/org/onlab/onos/net/topology/TopoVertex.java b/core/api/src/main/java/org/onlab/onos/net/topology/TopologyVertex.java
similarity index 86%
rename from core/api/src/main/java/org/onlab/onos/net/topology/TopoVertex.java
rename to core/api/src/main/java/org/onlab/onos/net/topology/TopologyVertex.java
index d5a8b95..96a918f 100644
--- a/core/api/src/main/java/org/onlab/onos/net/topology/TopoVertex.java
+++ b/core/api/src/main/java/org/onlab/onos/net/topology/TopologyVertex.java
@@ -6,7 +6,7 @@
/**
* Represents a vertex in the topology graph.
*/
-public interface TopoVertex extends Vertex {
+public interface TopologyVertex extends Vertex {
/**
* Returns the associated infrastructure device identification.