Gather topology element info to TopologyImpl
- Moved all the self-contained topology elements (*Event) to
TopologyImpl. (ONOS-1651)
Now {Switch, Port, Link, Host}Impl is just a handler attached to
TopologyImpl.
- BugFix: TopologyManager.addHost(HostEvent)
HostEvent could be pushed to reorder queue multiple times,
if multiple attachment point was given.
- BugFix: TopologyManager.{addLink, removePort}
Properly handle if Host attachment point was removed as side-effect.
- BugFix: Copy HostEvent#lastSeenTime
- BugFix: Event instance notified to listeners (api*Events) should be
the event which was/will be in the replica. (TopologyManager)
- Added/Modified debug log in TopologyManager so that log will be in
same format for each event type.
"{Added, Update, Removed} <Self-contained>"
- Removed backdoor method and use TestUtils instead.
Change-Id: If053d6f11f39574a188e7a52cb6194114f8afe5d
diff --git a/src/main/java/net/onrc/onos/core/topology/SwitchImpl.java b/src/main/java/net/onrc/onos/core/topology/SwitchImpl.java
index b0486b0..6be8b13 100644
--- a/src/main/java/net/onrc/onos/core/topology/SwitchImpl.java
+++ b/src/main/java/net/onrc/onos/core/topology/SwitchImpl.java
@@ -14,53 +14,30 @@
import org.apache.commons.lang.Validate;
/**
- * Switch Object stored in In-memory Topology.
+ * Handler to Switch object stored in In-memory Topology snapshot.
* <p/>
- * TODO REMOVE following design memo: This object itself may hold the DBObject,
- * but this Object itself will not issue any read/write to the DataStore.
+ *
*/
public class SwitchImpl extends TopologyObject implements Switch {
- //////////////////////////////////////////////////////
- /// Topology element attributes
- /// - any changes made here needs to be replicated.
- //////////////////////////////////////////////////////
- private SwitchEvent switchObj;
+ private final Dpid id;
/**
- * Creates a Switch object with empty attributes.
+ * Creates a Switch handler object.
*
* @param topology Topology instance this object belongs to
* @param dpid DPID
*/
- public SwitchImpl(Topology topology, Dpid dpid) {
- this(topology, new SwitchEvent(dpid).freeze());
- }
-
- /**
- * Creates a Switch object based on {@link SwitchEvent}.
- *
- * @param topology Topology instance this object belongs to
- * @param scSw self contained {@link SwitchEvent}
- */
- public SwitchImpl(Topology topology, SwitchEvent scSw) {
+ SwitchImpl(TopologyInternal topology, Dpid dpid) {
super(topology);
- Validate.notNull(scSw);
-
- // TODO should we assume switchObj is already frozen before this call
- // or expect attribute update will happen after .
- if (scSw.isFrozen()) {
- this.switchObj = scSw;
- } else {
- this.switchObj = new SwitchEvent(scSw);
- this.switchObj.freeze();
- }
+ Validate.notNull(dpid);
+ this.id = dpid;
}
@Override
public Dpid getDpid() {
- return switchObj.getDpid();
+ return this.id;
}
@Override
@@ -121,18 +98,6 @@
return hosts;
}
- void replaceStringAttributes(SwitchEvent updated) {
- Validate.isTrue(this.getDpid().equals(updated.getDpid()),
- "Wrong SwitchEvent given.");
-
- // XXX simply replacing whole self-contained object for now
- if (updated.isFrozen()) {
- this.switchObj = updated;
- } else {
- this.switchObj = new SwitchEvent(updated).freeze();
- }
- }
-
@Override
public Iterable<Link> getOutgoingLinks() {
LinkedList<Link> links = new LinkedList<Link>();
@@ -159,7 +124,7 @@
@Override
public String getStringAttribute(String attr) {
- return this.switchObj.getStringAttribute(attr);
+ return this.topology.getSwitchEvent(getDpid()).getStringAttribute(attr);
}
@Override
@@ -174,7 +139,7 @@
@Override
public Map<String, String> getAllStringAttributes() {
- return this.switchObj.getAllStringAttributes();
+ return this.topology.getSwitchEvent(getDpid()).getAllStringAttributes();
}
@Override