Thomas Vachuska
Committed by Gerrit Code Review

Refactoring to eliminate duplicate DefaultTopology and DefaultTopologyGraph; eli…

…minating a few fixmes.

Change-Id: I4461b6f1c8ae60d39f5da909bf6995294cbfa84d
...@@ -15,10 +15,8 @@ ...@@ -15,10 +15,8 @@
15 */ 15 */
16 package org.onosproject.net.topology; 16 package org.onosproject.net.topology;
17 17
18 -import static org.slf4j.LoggerFactory.getLogger; 18 +import com.google.common.collect.ImmutableSet;
19 - 19 +import com.google.common.collect.Maps;
20 -import java.util.Map;
21 -
22 import org.onosproject.net.AbstractDescription; 20 import org.onosproject.net.AbstractDescription;
23 import org.onosproject.net.ConnectPoint; 21 import org.onosproject.net.ConnectPoint;
24 import org.onosproject.net.Device; 22 import org.onosproject.net.Device;
...@@ -27,14 +25,15 @@ import org.onosproject.net.Link; ...@@ -27,14 +25,15 @@ import org.onosproject.net.Link;
27 import org.onosproject.net.SparseAnnotations; 25 import org.onosproject.net.SparseAnnotations;
28 import org.slf4j.Logger; 26 import org.slf4j.Logger;
29 27
30 -import com.google.common.collect.ImmutableSet; 28 +import java.util.Map;
31 -import com.google.common.collect.Maps; 29 +
30 +import static org.slf4j.LoggerFactory.getLogger;
32 31
33 /** 32 /**
34 * Default implementation of an immutable topology graph data carrier. 33 * Default implementation of an immutable topology graph data carrier.
35 */ 34 */
36 public class DefaultGraphDescription extends AbstractDescription 35 public class DefaultGraphDescription extends AbstractDescription
37 -implements GraphDescription { 36 + implements GraphDescription {
38 37
39 private static final Logger log = getLogger(DefaultGraphDescription.class); 38 private static final Logger log = getLogger(DefaultGraphDescription.class);
40 39
...@@ -43,19 +42,15 @@ implements GraphDescription { ...@@ -43,19 +42,15 @@ implements GraphDescription {
43 private final ImmutableSet<TopologyVertex> vertexes; 42 private final ImmutableSet<TopologyVertex> vertexes;
44 private final ImmutableSet<TopologyEdge> edges; 43 private final ImmutableSet<TopologyEdge> edges;
45 44
46 - private final Map<DeviceId, TopologyVertex> vertexesById = Maps 45 + private final Map<DeviceId, TopologyVertex> vertexesById = Maps.newHashMap();
47 - .newHashMap();
48 46
49 /** 47 /**
50 * Creates a minimal topology graph description to allow core to construct 48 * Creates a minimal topology graph description to allow core to construct
51 * and process the topology graph. 49 * and process the topology graph.
52 * 50 *
53 * @param nanos time in nanos of when the topology description was created 51 * @param nanos time in nanos of when the topology description was created
54 - *
55 * @param devices collection of infrastructure devices 52 * @param devices collection of infrastructure devices
56 - *
57 * @param links collection of infrastructure links 53 * @param links collection of infrastructure links
58 - *
59 * @param annotations optional key/value annotations map 54 * @param annotations optional key/value annotations map
60 * @deprecated in Cardinal Release 55 * @deprecated in Cardinal Release
61 */ 56 */
...@@ -71,15 +66,10 @@ implements GraphDescription { ...@@ -71,15 +66,10 @@ implements GraphDescription {
71 * and process the topology graph. 66 * and process the topology graph.
72 * 67 *
73 * @param nanos time in nanos of when the topology description was created 68 * @param nanos time in nanos of when the topology description was created
74 - *
75 * @param millis time in millis of when the topology description was created 69 * @param millis time in millis of when the topology description was created
76 - *
77 * @param devices collection of infrastructure devices 70 * @param devices collection of infrastructure devices
78 - *
79 * @param links collection of infrastructure links 71 * @param links collection of infrastructure links
80 - *
81 * @param annotations optional key/value annotations map 72 * @param annotations optional key/value annotations map
82 - *
83 */ 73 */
84 public DefaultGraphDescription(long nanos, long millis, 74 public DefaultGraphDescription(long nanos, long millis,
85 Iterable<Device> devices, 75 Iterable<Device> devices,
...@@ -114,8 +104,7 @@ implements GraphDescription { ...@@ -114,8 +104,7 @@ implements GraphDescription {
114 } 104 }
115 105
116 // Builds a set of topology vertexes from the specified list of devices 106 // Builds a set of topology vertexes from the specified list of devices
117 - private ImmutableSet<TopologyVertex> 107 + private ImmutableSet<TopologyVertex> buildVertexes(Iterable<Device> devices) {
118 - buildVertexes(Iterable<Device> devices) {
119 ImmutableSet.Builder<TopologyVertex> vertexes = ImmutableSet.builder(); 108 ImmutableSet.Builder<TopologyVertex> vertexes = ImmutableSet.builder();
120 for (Device device : devices) { 109 for (Device device : devices) {
121 TopologyVertex vertex = new DefaultTopologyVertex(device.id()); 110 TopologyVertex vertex = new DefaultTopologyVertex(device.id());
......
...@@ -13,20 +13,14 @@ ...@@ -13,20 +13,14 @@
13 * See the License for the specific language governing permissions and 13 * See the License for the specific language governing permissions and
14 * limitations under the License. 14 * limitations under the License.
15 */ 15 */
16 -package org.onosproject.store.topology.impl; 16 +package org.onosproject.common;
17 -
18 -import static com.google.common.base.MoreObjects.toStringHelper;
19 -import static org.onlab.graph.GraphPathSearch.ALL_PATHS;
20 -import static org.onosproject.core.CoreService.CORE_PROVIDER_ID;
21 -import static org.onosproject.net.Link.State.ACTIVE;
22 -import static org.onosproject.net.Link.State.INACTIVE;
23 -import static org.onosproject.net.Link.Type.INDIRECT;
24 -
25 -import java.util.ArrayList;
26 -import java.util.List;
27 -import java.util.Map;
28 -import java.util.Set;
29 17
18 +import com.google.common.base.Supplier;
19 +import com.google.common.base.Suppliers;
20 +import com.google.common.collect.ImmutableMap;
21 +import com.google.common.collect.ImmutableSet;
22 +import com.google.common.collect.ImmutableSetMultimap;
23 +import com.google.common.collect.ImmutableSetMultimap.Builder;
30 import org.onlab.graph.DijkstraGraphSearch; 24 import org.onlab.graph.DijkstraGraphSearch;
31 import org.onlab.graph.GraphPathSearch; 25 import org.onlab.graph.GraphPathSearch;
32 import org.onlab.graph.GraphPathSearch.Result; 26 import org.onlab.graph.GraphPathSearch.Result;
...@@ -50,14 +44,18 @@ import org.onosproject.net.topology.TopologyEdge; ...@@ -50,14 +44,18 @@ import org.onosproject.net.topology.TopologyEdge;
50 import org.onosproject.net.topology.TopologyGraph; 44 import org.onosproject.net.topology.TopologyGraph;
51 import org.onosproject.net.topology.TopologyVertex; 45 import org.onosproject.net.topology.TopologyVertex;
52 46
53 -import com.google.common.base.Supplier; 47 +import java.util.ArrayList;
54 -import com.google.common.base.Suppliers; 48 +import java.util.List;
55 -import com.google.common.collect.ImmutableMap; 49 +import java.util.Map;
56 -import com.google.common.collect.ImmutableSet; 50 +import java.util.Set;
57 -import com.google.common.collect.ImmutableSetMultimap; 51 +
58 -import com.google.common.collect.ImmutableSetMultimap.Builder; 52 +import static com.google.common.base.MoreObjects.toStringHelper;
53 +import static org.onlab.graph.GraphPathSearch.ALL_PATHS;
54 +import static org.onosproject.core.CoreService.CORE_PROVIDER_ID;
55 +import static org.onosproject.net.Link.State.ACTIVE;
56 +import static org.onosproject.net.Link.State.INACTIVE;
57 +import static org.onosproject.net.Link.Type.INDIRECT;
59 58
60 -// FIXME: Move to onos-core-common when ready
61 /** 59 /**
62 * Default implementation of the topology descriptor. This carries the backing 60 * Default implementation of the topology descriptor. This carries the backing
63 * topology data. 61 * topology data.
...@@ -83,12 +81,10 @@ public class DefaultTopology extends AbstractModel implements Topology { ...@@ -83,12 +81,10 @@ public class DefaultTopology extends AbstractModel implements Topology {
83 /** 81 /**
84 * Creates a topology descriptor attributed to the specified provider. 82 * Creates a topology descriptor attributed to the specified provider.
85 * 83 *
86 - * @param providerId 84 + * @param providerId identity of the provider
87 - * identity of the provider 85 + * @param description data describing the new topology
88 - * @param description
89 - * data describing the new topology
90 */ 86 */
91 - DefaultTopology(ProviderId providerId, GraphDescription description) { 87 + public DefaultTopology(ProviderId providerId, GraphDescription description) {
92 super(providerId); 88 super(providerId);
93 this.time = description.timestamp(); 89 this.time = description.timestamp();
94 this.creationTime = description.creationTime(); 90 this.creationTime = description.creationTime();
...@@ -104,8 +100,7 @@ public class DefaultTopology extends AbstractModel implements Topology { ...@@ -104,8 +100,7 @@ public class DefaultTopology extends AbstractModel implements Topology {
104 100
105 this.weight = new HopCountLinkWeight(graph.getVertexes().size()); 101 this.weight = new HopCountLinkWeight(graph.getVertexes().size());
106 this.broadcastSets = Suppliers.memoize(() -> buildBroadcastSets()); 102 this.broadcastSets = Suppliers.memoize(() -> buildBroadcastSets());
107 - this.infrastructurePoints = Suppliers 103 + this.infrastructurePoints = Suppliers.memoize(() -> findInfrastructurePoints());
108 - .memoize(() -> findInfrastructurePoints());
109 this.computeCost = Math.max(0, System.nanoTime() - time); 104 this.computeCost = Math.max(0, System.nanoTime() - time);
110 } 105 }
111 106
...@@ -156,7 +151,7 @@ public class DefaultTopology extends AbstractModel implements Topology { ...@@ -156,7 +151,7 @@ public class DefaultTopology extends AbstractModel implements Topology {
156 * 151 *
157 * @return topology graph 152 * @return topology graph
158 */ 153 */
159 - TopologyGraph getGraph() { 154 + public TopologyGraph getGraph() {
160 return graph; 155 return graph;
161 } 156 }
162 157
...@@ -165,7 +160,7 @@ public class DefaultTopology extends AbstractModel implements Topology { ...@@ -165,7 +160,7 @@ public class DefaultTopology extends AbstractModel implements Topology {
165 * 160 *
166 * @return set of clusters 161 * @return set of clusters
167 */ 162 */
168 - Set<TopologyCluster> getClusters() { 163 + public Set<TopologyCluster> getClusters() {
169 return ImmutableSet.copyOf(clusters.get().values()); 164 return ImmutableSet.copyOf(clusters.get().values());
170 } 165 }
171 166
...@@ -173,10 +168,9 @@ public class DefaultTopology extends AbstractModel implements Topology { ...@@ -173,10 +168,9 @@ public class DefaultTopology extends AbstractModel implements Topology {
173 * Returns the specified topology cluster. 168 * Returns the specified topology cluster.
174 * 169 *
175 * @param clusterId cluster identifier 170 * @param clusterId cluster identifier
176 - *
177 * @return topology cluster 171 * @return topology cluster
178 */ 172 */
179 - TopologyCluster getCluster(ClusterId clusterId) { 173 + public TopologyCluster getCluster(ClusterId clusterId) {
180 return clusters.get().get(clusterId); 174 return clusters.get().get(clusterId);
181 } 175 }
182 176
...@@ -184,10 +178,9 @@ public class DefaultTopology extends AbstractModel implements Topology { ...@@ -184,10 +178,9 @@ public class DefaultTopology extends AbstractModel implements Topology {
184 * Returns the topology cluster that contains the given device. 178 * Returns the topology cluster that contains the given device.
185 * 179 *
186 * @param deviceId device identifier 180 * @param deviceId device identifier
187 - *
188 * @return topology cluster 181 * @return topology cluster
189 */ 182 */
190 - TopologyCluster getCluster(DeviceId deviceId) { 183 + public TopologyCluster getCluster(DeviceId deviceId) {
191 return clustersByDevice().get(deviceId); 184 return clustersByDevice().get(deviceId);
192 } 185 }
193 186
...@@ -195,10 +188,9 @@ public class DefaultTopology extends AbstractModel implements Topology { ...@@ -195,10 +188,9 @@ public class DefaultTopology extends AbstractModel implements Topology {
195 * Returns the set of cluster devices. 188 * Returns the set of cluster devices.
196 * 189 *
197 * @param cluster topology cluster 190 * @param cluster topology cluster
198 - *
199 * @return cluster devices 191 * @return cluster devices
200 */ 192 */
201 - Set<DeviceId> getClusterDevices(TopologyCluster cluster) { 193 + public Set<DeviceId> getClusterDevices(TopologyCluster cluster) {
202 return devicesByCluster().get(cluster); 194 return devicesByCluster().get(cluster);
203 } 195 }
204 196
...@@ -206,10 +198,9 @@ public class DefaultTopology extends AbstractModel implements Topology { ...@@ -206,10 +198,9 @@ public class DefaultTopology extends AbstractModel implements Topology {
206 * Returns the set of cluster links. 198 * Returns the set of cluster links.
207 * 199 *
208 * @param cluster topology cluster 200 * @param cluster topology cluster
209 - *
210 * @return cluster links 201 * @return cluster links
211 */ 202 */
212 - Set<Link> getClusterLinks(TopologyCluster cluster) { 203 + public Set<Link> getClusterLinks(TopologyCluster cluster) {
213 return linksByCluster().get(cluster); 204 return linksByCluster().get(cluster);
214 } 205 }
215 206
...@@ -217,10 +208,9 @@ public class DefaultTopology extends AbstractModel implements Topology { ...@@ -217,10 +208,9 @@ public class DefaultTopology extends AbstractModel implements Topology {
217 * Indicates whether the given point is an infrastructure link end-point. 208 * Indicates whether the given point is an infrastructure link end-point.
218 * 209 *
219 * @param connectPoint connection point 210 * @param connectPoint connection point
220 - *
221 * @return true if infrastructure 211 * @return true if infrastructure
222 */ 212 */
223 - boolean isInfrastructure(ConnectPoint connectPoint) { 213 + public boolean isInfrastructure(ConnectPoint connectPoint) {
224 return infrastructurePoints.get().contains(connectPoint); 214 return infrastructurePoints.get().contains(connectPoint);
225 } 215 }
226 216
...@@ -228,10 +218,9 @@ public class DefaultTopology extends AbstractModel implements Topology { ...@@ -228,10 +218,9 @@ public class DefaultTopology extends AbstractModel implements Topology {
228 * Indicates whether the given point is part of a broadcast set. 218 * Indicates whether the given point is part of a broadcast set.
229 * 219 *
230 * @param connectPoint connection point 220 * @param connectPoint connection point
231 - *
232 * @return true if in broadcast set 221 * @return true if in broadcast set
233 */ 222 */
234 - boolean isBroadcastPoint(ConnectPoint connectPoint) { 223 + public boolean isBroadcastPoint(ConnectPoint connectPoint) {
235 // Any non-infrastructure, i.e. edge points are assumed to be OK. 224 // Any non-infrastructure, i.e. edge points are assumed to be OK.
236 if (!isInfrastructure(connectPoint)) { 225 if (!isInfrastructure(connectPoint)) {
237 return true; 226 return true;
...@@ -254,10 +243,9 @@ public class DefaultTopology extends AbstractModel implements Topology { ...@@ -254,10 +243,9 @@ public class DefaultTopology extends AbstractModel implements Topology {
254 * Returns the size of the cluster broadcast set. 243 * Returns the size of the cluster broadcast set.
255 * 244 *
256 * @param clusterId cluster identifier 245 * @param clusterId cluster identifier
257 - *
258 * @return size of the cluster broadcast set 246 * @return size of the cluster broadcast set
259 */ 247 */
260 - int broadcastSetSize(ClusterId clusterId) { 248 + public int broadcastSetSize(ClusterId clusterId) {
261 return broadcastSets.get().get(clusterId).size(); 249 return broadcastSets.get().get(clusterId).size();
262 } 250 }
263 251
...@@ -266,12 +254,10 @@ public class DefaultTopology extends AbstractModel implements Topology { ...@@ -266,12 +254,10 @@ public class DefaultTopology extends AbstractModel implements Topology {
266 * destination devices. 254 * destination devices.
267 * 255 *
268 * @param src source device 256 * @param src source device
269 - *
270 * @param dst destination device 257 * @param dst destination device
271 - *
272 * @return set of shortest paths 258 * @return set of shortest paths
273 */ 259 */
274 - Set<Path> getPaths(DeviceId src, DeviceId dst) { 260 + public Set<Path> getPaths(DeviceId src, DeviceId dst) {
275 return getPaths(src, dst, null); 261 return getPaths(src, dst, null);
276 } 262 }
277 263
...@@ -280,14 +266,11 @@ public class DefaultTopology extends AbstractModel implements Topology { ...@@ -280,14 +266,11 @@ public class DefaultTopology extends AbstractModel implements Topology {
280 * destination devices. 266 * destination devices.
281 * 267 *
282 * @param src source device 268 * @param src source device
283 - *
284 * @param dst destination device 269 * @param dst destination device
285 - *
286 * @param weight link weight function 270 * @param weight link weight function
287 - *
288 * @return set of shortest paths 271 * @return set of shortest paths
289 */ 272 */
290 - Set<Path> getPaths(DeviceId src, DeviceId dst, LinkWeight weight) { 273 + public Set<Path> getPaths(DeviceId src, DeviceId dst, LinkWeight weight) {
291 final DefaultTopologyVertex srcV = new DefaultTopologyVertex(src); 274 final DefaultTopologyVertex srcV = new DefaultTopologyVertex(src);
292 final DefaultTopologyVertex dstV = new DefaultTopologyVertex(dst); 275 final DefaultTopologyVertex dstV = new DefaultTopologyVertex(dst);
293 Set<TopologyVertex> vertices = graph.getVertexes(); 276 Set<TopologyVertex> vertices = graph.getVertexes();
...@@ -470,8 +453,7 @@ public class DefaultTopology extends AbstractModel implements Topology { ...@@ -470,8 +453,7 @@ public class DefaultTopology extends AbstractModel implements Topology {
470 final ImmutableSetMultimap<TopologyCluster, DeviceId> devicesByCluster; 453 final ImmutableSetMultimap<TopologyCluster, DeviceId> devicesByCluster;
471 final ImmutableSetMultimap<TopologyCluster, Link> linksByCluster; 454 final ImmutableSetMultimap<TopologyCluster, Link> linksByCluster;
472 455
473 - public ClusterIndexes( 456 + public ClusterIndexes(ImmutableMap<DeviceId, TopologyCluster> clustersByDevice,
474 - ImmutableMap<DeviceId, TopologyCluster> clustersByDevice,
475 ImmutableSetMultimap<TopologyCluster, DeviceId> devicesByCluster, 457 ImmutableSetMultimap<TopologyCluster, DeviceId> devicesByCluster,
476 ImmutableSetMultimap<TopologyCluster, Link> linksByCluster) { 458 ImmutableSetMultimap<TopologyCluster, Link> linksByCluster) {
477 this.clustersByDevice = clustersByDevice; 459 this.clustersByDevice = clustersByDevice;
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
13 * See the License for the specific language governing permissions and 13 * See the License for the specific language governing permissions and
14 * limitations under the License. 14 * limitations under the License.
15 */ 15 */
16 -package org.onosproject.store.trivial; 16 +package org.onosproject.common;
17 17
18 import org.onlab.graph.AdjacencyListsGraph; 18 import org.onlab.graph.AdjacencyListsGraph;
19 import org.onosproject.net.topology.TopologyEdge; 19 import org.onosproject.net.topology.TopologyEdge;
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
13 * See the License for the specific language governing permissions and 13 * See the License for the specific language governing permissions and
14 * limitations under the License. 14 * limitations under the License.
15 */ 15 */
16 -package org.onosproject.store.trivial; 16 +package org.onosproject.common;
17 17
18 import org.junit.Before; 18 import org.junit.Before;
19 import org.junit.Test; 19 import org.junit.Test;
......
...@@ -19,6 +19,7 @@ import org.apache.felix.scr.annotations.Activate; ...@@ -19,6 +19,7 @@ import org.apache.felix.scr.annotations.Activate;
19 import org.apache.felix.scr.annotations.Component; 19 import org.apache.felix.scr.annotations.Component;
20 import org.apache.felix.scr.annotations.Deactivate; 20 import org.apache.felix.scr.annotations.Deactivate;
21 import org.apache.felix.scr.annotations.Service; 21 import org.apache.felix.scr.annotations.Service;
22 +import org.onosproject.common.DefaultTopology;
22 import org.onosproject.event.Event; 23 import org.onosproject.event.Event;
23 import org.onosproject.net.ConnectPoint; 24 import org.onosproject.net.ConnectPoint;
24 import org.onosproject.net.DeviceId; 25 import org.onosproject.net.DeviceId;
......
1 -/*
2 - * Copyright 2014 Open Networking Laboratory
3 - *
4 - * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with the License.
6 - * You may obtain a copy of the License at
7 - *
8 - * http://www.apache.org/licenses/LICENSE-2.0
9 - *
10 - * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and
14 - * limitations under the License.
15 - */
16 -package org.onosproject.store.topology.impl;
17 -
18 -import org.onlab.graph.AdjacencyListsGraph;
19 -import org.onosproject.net.topology.TopologyEdge;
20 -import org.onosproject.net.topology.TopologyGraph;
21 -import org.onosproject.net.topology.TopologyVertex;
22 -
23 -import java.util.Set;
24 -
25 -/**
26 - * Default implementation of an immutable topology graph based on a generic
27 - * implementation of adjacency lists graph.
28 - */
29 -public class DefaultTopologyGraph
30 - extends AdjacencyListsGraph<TopologyVertex, TopologyEdge>
31 - implements TopologyGraph {
32 -
33 - /**
34 - * Creates a topology graph comprising of the specified vertexes and edges.
35 - *
36 - * @param vertexes set of graph vertexes
37 - * @param edges set of graph edges
38 - */
39 - public DefaultTopologyGraph(Set<TopologyVertex> vertexes, Set<TopologyEdge> edges) {
40 - super(vertexes, edges);
41 - }
42 -
43 -}
...@@ -15,6 +15,8 @@ ...@@ -15,6 +15,8 @@
15 */ 15 */
16 package org.onosproject.store.topology.impl; 16 package org.onosproject.store.topology.impl;
17 17
18 +import static com.google.common.base.Preconditions.checkArgument;
19 +import static org.onosproject.net.topology.TopologyEvent.Type.TOPOLOGY_CHANGED;
18 import static org.slf4j.LoggerFactory.getLogger; 20 import static org.slf4j.LoggerFactory.getLogger;
19 21
20 import java.util.Collections; 22 import java.util.Collections;
...@@ -25,6 +27,7 @@ import org.apache.felix.scr.annotations.Activate; ...@@ -25,6 +27,7 @@ import org.apache.felix.scr.annotations.Activate;
25 import org.apache.felix.scr.annotations.Component; 27 import org.apache.felix.scr.annotations.Component;
26 import org.apache.felix.scr.annotations.Deactivate; 28 import org.apache.felix.scr.annotations.Deactivate;
27 import org.apache.felix.scr.annotations.Service; 29 import org.apache.felix.scr.annotations.Service;
30 +import org.onosproject.common.DefaultTopology;
28 import org.onosproject.event.Event; 31 import org.onosproject.event.Event;
29 import org.onosproject.net.ConnectPoint; 32 import org.onosproject.net.ConnectPoint;
30 import org.onosproject.net.Device; 33 import org.onosproject.net.Device;
...@@ -48,21 +51,21 @@ import org.slf4j.Logger; ...@@ -48,21 +51,21 @@ import org.slf4j.Logger;
48 /** 51 /**
49 * Manages inventory of topology snapshots using trivial in-memory 52 * Manages inventory of topology snapshots using trivial in-memory
50 * structures implementation. 53 * structures implementation.
51 - * 54 + * <p>
52 * Note: This component is not distributed per-se. It runs on every 55 * Note: This component is not distributed per-se. It runs on every
53 * instance and feeds off of other distributed stores. 56 * instance and feeds off of other distributed stores.
54 */ 57 */
55 @Component(immediate = true) 58 @Component(immediate = true)
56 @Service 59 @Service
57 public class DistributedTopologyStore 60 public class DistributedTopologyStore
58 -extends AbstractStore<TopologyEvent, TopologyStoreDelegate> 61 + extends AbstractStore<TopologyEvent, TopologyStoreDelegate>
59 -implements TopologyStore { 62 + implements TopologyStore {
60 63
61 private final Logger log = getLogger(getClass()); 64 private final Logger log = getLogger(getClass());
62 65
63 private volatile DefaultTopology current = 66 private volatile DefaultTopology current =
64 new DefaultTopology(ProviderId.NONE, 67 new DefaultTopology(ProviderId.NONE,
65 - new DefaultGraphDescription(0L, 68 + new DefaultGraphDescription(0L, 0L,
66 Collections.<Device>emptyList(), 69 Collections.<Device>emptyList(),
67 Collections.<Link>emptyList())); 70 Collections.<Link>emptyList()));
68 71
...@@ -75,6 +78,7 @@ implements TopologyStore { ...@@ -75,6 +78,7 @@ implements TopologyStore {
75 public void deactivate() { 78 public void deactivate() {
76 log.info("Stopped"); 79 log.info("Stopped");
77 } 80 }
81 +
78 @Override 82 @Override
79 public Topology currentTopology() { 83 public Topology currentTopology() {
80 return current; 84 return current;
...@@ -149,18 +153,15 @@ implements TopologyStore { ...@@ -149,18 +153,15 @@ implements TopologyStore {
149 // Promote the new topology to current and return a ready-to-send event. 153 // Promote the new topology to current and return a ready-to-send event.
150 synchronized (this) { 154 synchronized (this) {
151 current = newTopology; 155 current = newTopology;
152 - return new TopologyEvent(TopologyEvent.Type.TOPOLOGY_CHANGED, 156 + return new TopologyEvent(TOPOLOGY_CHANGED, current, reasons);
153 - current, reasons);
154 } 157 }
155 } 158 }
156 159
157 // Validates the specified topology and returns it as a default 160 // Validates the specified topology and returns it as a default
158 private DefaultTopology defaultTopology(Topology topology) { 161 private DefaultTopology defaultTopology(Topology topology) {
159 - if (topology instanceof DefaultTopology) { 162 + checkArgument(topology instanceof DefaultTopology,
163 + "Topology class %s not supported", topology.getClass());
160 return (DefaultTopology) topology; 164 return (DefaultTopology) topology;
161 } 165 }
162 - throw new IllegalArgumentException("Topology class " + topology.getClass() +
163 - " not supported");
164 - }
165 166
166 } 167 }
......