ONOS-4326: Working on topology topo2start processing.
- Added getPeers() to UiTopoLayoutService.
- Fixed wipe-out command to leave the default layout alone.
- Fixed handling of null-region (associated with default layout).
- Added refresh() method to model cache.
- Fixed regions-topo-2 device IDs
Change-Id: Iee49b47ff6702bed9751be7b63392577422d4763
diff --git a/core/api/src/main/java/org/onosproject/ui/model/topo/UiRegion.java b/core/api/src/main/java/org/onosproject/ui/model/topo/UiRegion.java
index 023300c..c478424 100644
--- a/core/api/src/main/java/org/onosproject/ui/model/topo/UiRegion.java
+++ b/core/api/src/main/java/org/onosproject/ui/model/topo/UiRegion.java
@@ -29,12 +29,27 @@
import java.util.Set;
import static com.google.common.base.MoreObjects.toStringHelper;
+import static org.onosproject.net.region.RegionId.regionId;
/**
* Represents a region.
*/
public class UiRegion extends UiNode {
+ private static final String NULL_NAME = "<null-region>";
+
+ /**
+ * The identifier for the null-region. That is, a container for devices,
+ * hosts, and links for those that belong to no region.
+ */
+ public static final RegionId NULL_ID = regionId(NULL_NAME);
+
+ private static final String[] DEFAULT_LAYER_TAGS = {
+ UiNode.LAYER_OPTICAL,
+ UiNode.LAYER_PACKET,
+ UiNode.LAYER_DEFAULT
+ };
+
// loose bindings to things in this region
private final Set<DeviceId> deviceIds = new HashSet<>();
private final Set<HostId> hostIds = new HashSet<>();
@@ -53,10 +68,12 @@
* @param region backing region
*/
public UiRegion(UiTopology topology, Region region) {
+ // Implementation Note: if region is null, this UiRegion is being used
+ // as a container for devices, hosts, links that belong to no region.
this.topology = topology;
this.region = region;
- // unless told otherwise, we'll use a single, default layer
- layerOrder.add(UiNode.LAYER_DEFAULT);
+
+ setLayerOrder(DEFAULT_LAYER_TAGS);
}
@Override
@@ -83,7 +100,7 @@
* @return region ID
*/
public RegionId id() {
- return region.id();
+ return region == null ? NULL_ID : region.id();
}
@Override
@@ -93,11 +110,12 @@
@Override
public String name() {
- return region.name();
+ return region == null ? NULL_NAME : region.name();
}
/**
- * Returns the region instance backing this UI region.
+ * Returns the region instance backing this UI region. If this instance
+ * represents the "null-region", the value returned will be null.
*
* @return the backing region instance
*/
@@ -132,7 +150,17 @@
* @return region type
*/
public Region.Type type() {
- return region.type();
+ return region == null ? null : region.type();
+ }
+
+
+ /**
+ * Returns the count of devices in this region.
+ *
+ * @return the device count
+ */
+ public int deviceCount() {
+ return deviceIds.size();
}
/**
@@ -195,7 +223,7 @@
* optical layer should be rendered "below" nodes in the packet layer,
* this method should return:
* <pre>
- * [UiNode.LAYER_OPTICAL, UiNode.LAYER_PACKET]
+ * [UiNode.LAYER_OPTICAL, UiNode.LAYER_PACKET, UiNode.LAYER_DEFAULT]
* </pre>
*
* @return layer ordering