blob: 773762a65e19bfba9caf9b711ff9fe6637864e62 [file] [log] [blame]
tomcfde0622014-09-09 11:02:42 -07001package org.onlab.onos.net.trivial.impl;
2
3import com.google.common.collect.ImmutableSet;
4import com.google.common.collect.Multimap;
5import org.onlab.graph.Graph;
6import org.onlab.graph.GraphPathSearch;
7import org.onlab.onos.net.DeviceId;
8import org.onlab.onos.net.Link;
9import org.onlab.onos.net.topology.ClusterId;
10import org.onlab.onos.net.topology.TopoEdge;
11import org.onlab.onos.net.topology.TopoVertex;
12import org.onlab.onos.net.topology.TopologyCluster;
13import org.onlab.onos.net.topology.TopologyDescription;
14
15import java.util.Map;
16import java.util.Set;
17
18/**
19 * Default implementation of an immutable topology data carrier.
20 */
21public class DefaultTopologyDescription implements TopologyDescription {
22
23 private final long nanos;
24 private final Graph<TopoVertex, TopoEdge> graph;
25 private final Map<DeviceId, GraphPathSearch.Result<TopoVertex, TopoEdge>> results;
26 private final Map<ClusterId, TopologyCluster> clusters;
27 private final Multimap<ClusterId, DeviceId> clusterDevices;
28 private final Multimap<ClusterId, Link> clusterLinks;
29 private final Map<DeviceId, TopologyCluster> deviceClusters;
30
31 public DefaultTopologyDescription(long nanos, Graph<TopoVertex, TopoEdge> graph,
32 Map<DeviceId, GraphPathSearch.Result<TopoVertex, TopoEdge>> results,
33 Map<ClusterId, TopologyCluster> clusters,
34 Multimap<ClusterId, DeviceId> clusterDevices,
35 Multimap<ClusterId, Link> clusterLinks,
36 Map<DeviceId, TopologyCluster> deviceClusters) {
37 this.nanos = nanos;
38 this.graph = graph;
39 this.results = results;
40 this.clusters = clusters;
41 this.clusterDevices = clusterDevices;
42 this.clusterLinks = clusterLinks;
43 this.deviceClusters = deviceClusters;
44 }
45
46 @Override
47 public long timestamp() {
48 return nanos;
49 }
50
51 @Override
52 public Graph<TopoVertex, TopoEdge> graph() {
53 return graph;
54 }
55
56 @Override
57 public GraphPathSearch.Result<TopoVertex, TopoEdge> pathResults(DeviceId srcDeviceId) {
58 return results.get(srcDeviceId);
59 }
60
61 @Override
62 public Set<TopologyCluster> clusters() {
63 return ImmutableSet.copyOf(clusters.values());
64 }
65
66 @Override
67 public Set<DeviceId> clusterDevices(TopologyCluster cluster) {
68 return null; // clusterDevices.get(cluster.id());
69 }
70
71 @Override
72 public Set<Link> clusterLinks(TopologyCluster cluster) {
73 return null; // clusterLinks.get(cluster.id());
74 }
75
76 @Override
77 public TopologyCluster clusterFor(DeviceId deviceId) {
78 return deviceClusters.get(deviceId);
79 }
80}