Refactoring to eliminate duplicate DefaultTopology and DefaultTopologyGraph; eliminating a few fixmes.
Change-Id: Ie0e38dbf812bafdb7c94bba5278f0dd9af5be929
diff --git a/core/api/src/main/java/org/onosproject/net/topology/DefaultGraphDescription.java b/core/api/src/main/java/org/onosproject/net/topology/DefaultGraphDescription.java
index d635d74..f1e20da 100644
--- a/core/api/src/main/java/org/onosproject/net/topology/DefaultGraphDescription.java
+++ b/core/api/src/main/java/org/onosproject/net/topology/DefaultGraphDescription.java
@@ -27,6 +27,7 @@
import java.util.Map;
+import static com.google.common.base.Preconditions.checkArgument;
import static org.slf4j.LoggerFactory.getLogger;
/**
@@ -133,9 +134,7 @@
private TopologyVertex vertexOf(ConnectPoint connectPoint) {
DeviceId id = connectPoint.deviceId();
TopologyVertex vertex = vertexesById.get(id);
- if (vertex == null) {
- throw new IllegalArgumentException("Vertex missing for " + id);
- }
+ checkArgument(vertex != null, "Vertex missing for %s", id);
return vertex;
}
diff --git a/core/common/src/main/java/org/onosproject/common/DefaultTopology.java b/core/common/src/main/java/org/onosproject/common/DefaultTopology.java
index 51857c7..579f336 100644
--- a/core/common/src/main/java/org/onosproject/common/DefaultTopology.java
+++ b/core/common/src/main/java/org/onosproject/common/DefaultTopology.java
@@ -50,7 +50,9 @@
import java.util.Set;
import static com.google.common.base.MoreObjects.toStringHelper;
+import static com.google.common.base.Preconditions.checkArgument;
import static org.onlab.graph.GraphPathSearch.ALL_PATHS;
+import static org.onlab.util.Tools.isNullOrEmpty;
import static org.onosproject.core.CoreService.CORE_PROVIDER_ID;
import static org.onosproject.net.Link.State.ACTIVE;
import static org.onosproject.net.Link.State.INACTIVE;
@@ -228,15 +230,12 @@
// Find the cluster to which the device belongs.
TopologyCluster cluster = clustersByDevice().get(connectPoint.deviceId());
- if (cluster == null) {
- throw new IllegalArgumentException("No cluster found for device "
- + connectPoint.deviceId());
- }
+ checkArgument(cluster != null, "No cluster found for device %s", connectPoint.deviceId());
// If the broadcast set is null or empty, or if the point explicitly
- // belongs to it, return true;
+ // belongs to it, return true.
Set<ConnectPoint> points = broadcastSets.get().get(cluster.id());
- return (points == null) || points.isEmpty() || points.contains(connectPoint);
+ return isNullOrEmpty(points) || points.contains(connectPoint);
}
/**
@@ -250,6 +249,16 @@
}
/**
+ * Returns the set of the cluster broadcast points.
+ *
+ * @param clusterId cluster identifier
+ * @return set of cluster broadcast points
+ */
+ public Set<ConnectPoint> broadcastPoints(ClusterId clusterId) {
+ return broadcastSets.get().get(clusterId);
+ }
+
+ /**
* Returns the set of pre-computed shortest paths between source and
* destination devices.
*
diff --git a/core/net/src/main/java/org/onosproject/net/topology/impl/DefaultTopologyProvider.java b/core/net/src/main/java/org/onosproject/net/topology/impl/DefaultTopologyProvider.java
index e9ab196..20a5ad3 100644
--- a/core/net/src/main/java/org/onosproject/net/topology/impl/DefaultTopologyProvider.java
+++ b/core/net/src/main/java/org/onosproject/net/topology/impl/DefaultTopologyProvider.java
@@ -279,8 +279,7 @@
try {
buildTopology(reasons);
} catch (Exception e) {
- log.warn("Unable to compute topology due to: {}", e.getMessage());
- log.debug("Unable to compute topology", e);
+ log.warn("Unable to compute topology", e);
}
}
}
diff --git a/core/store/dist/src/main/java/org/onosproject/store/topology/impl/DistributedTopologyStore.java b/core/store/dist/src/main/java/org/onosproject/store/topology/impl/DistributedTopologyStore.java
index 928603c..3a0f185 100644
--- a/core/store/dist/src/main/java/org/onosproject/store/topology/impl/DistributedTopologyStore.java
+++ b/core/store/dist/src/main/java/org/onosproject/store/topology/impl/DistributedTopologyStore.java
@@ -65,7 +65,7 @@
private volatile DefaultTopology current =
new DefaultTopology(ProviderId.NONE,
- new DefaultGraphDescription(0L, 0L,
+ new DefaultGraphDescription(0L, System.currentTimeMillis(),
Collections.<Device>emptyList(),
Collections.<Link>emptyList()));
@@ -147,8 +147,7 @@
}
// Have the default topology construct self from the description data.
- DefaultTopology newTopology =
- new DefaultTopology(providerId, graphDescription);
+ DefaultTopology newTopology = new DefaultTopology(providerId, graphDescription);
// Promote the new topology to current and return a ready-to-send event.
synchronized (this) {