Network GraphRefactoring: Removed unused interface and code.
* Removed interface NetworkGraphReplicationInterface, because it is not
needed anymore.
* Removed the ONOS Instance Origin ID for each notification, because
it won't be needed.
Change-Id: Ia2035cc34ea1c1b8cefa90d35eab5a10f5f8a2eb
diff --git a/src/main/java/net/onrc/onos/ofcontroller/networkgraph/NetworkGraphReplicationInterface.java b/src/main/java/net/onrc/onos/ofcontroller/networkgraph/NetworkGraphReplicationInterface.java
deleted file mode 100644
index 6b77ece..0000000
--- a/src/main/java/net/onrc/onos/ofcontroller/networkgraph/NetworkGraphReplicationInterface.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package net.onrc.onos.ofcontroller.networkgraph;
-
-/**
- * Interface to use to update Network Graph triggered by notification.
- *
- * Requested change by these methods will not be propagated down to DataStore
- */
-public interface NetworkGraphReplicationInterface {
- public void putSwitchReplicationEvent(SwitchEvent switchEvent);
- public void removeSwitchReplicationEvent(SwitchEvent switchEvent);
- public void putPortReplicationEvent(PortEvent portEvent);
- public void removePortReplicationEvent(PortEvent portEvent);
- public void putLinkReplicationEvent(LinkEvent linkEvent);
- public void removeLinkReplicationEvent(LinkEvent linkEvent);
- public void putDeviceReplicationEvent(DeviceEvent deviceEvent);
- public void removeDeviceReplicationEvent(DeviceEvent deviceEvent);
-}
diff --git a/src/main/java/net/onrc/onos/ofcontroller/networkgraph/TopologyEvent.java b/src/main/java/net/onrc/onos/ofcontroller/networkgraph/TopologyEvent.java
index 2892e0c..68da896 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/networkgraph/TopologyEvent.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/networkgraph/TopologyEvent.java
@@ -8,8 +8,6 @@
* in a single transaction.
*/
public class TopologyEvent {
- public static final String NOBODY = "";
- String originID = NOBODY;
SwitchEvent switchEvent = null; // Set for Switch event
PortEvent portEvent = null; // Set for Port event
LinkEvent linkEvent = null; // Set for Link event
@@ -26,9 +24,8 @@
*
* @param switchEvent the Switch event to use.
*/
- TopologyEvent(SwitchEvent switchEvent, String originID) {
+ TopologyEvent(SwitchEvent switchEvent) {
this.switchEvent = switchEvent;
- setOriginID(originID);
}
/**
@@ -36,9 +33,8 @@
*
* @param portEvent the Port event to use.
*/
- TopologyEvent(PortEvent portEvent, String originID) {
+ TopologyEvent(PortEvent portEvent) {
this.portEvent = portEvent;
- setOriginID(originID);
}
/**
@@ -46,9 +42,8 @@
*
* @param linkEvent the Link event to use.
*/
- TopologyEvent(LinkEvent linkEvent, String originID) {
+ TopologyEvent(LinkEvent linkEvent) {
this.linkEvent = linkEvent;
- setOriginID(originID);
}
/**
@@ -56,9 +51,8 @@
*
* @param deviceEvent the Device event to use.
*/
- TopologyEvent(DeviceEvent deviceEvent, String originID) {
+ TopologyEvent(DeviceEvent deviceEvent) {
this.deviceEvent = deviceEvent;
- setOriginID(originID);
}
/**
@@ -95,16 +89,4 @@
return deviceEvent.getID();
return null;
}
-
- public String getOriginID() {
- return originID;
- }
-
- void setOriginID(String originID) {
- if (originID != null) {
- this.originID = originID;
- } else {
- this.originID = NOBODY;
- }
- }
}
diff --git a/src/main/java/net/onrc/onos/ofcontroller/networkgraph/TopologyManager.java b/src/main/java/net/onrc/onos/ofcontroller/networkgraph/TopologyManager.java
index a01057b..f620614 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/networkgraph/TopologyManager.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/networkgraph/TopologyManager.java
@@ -39,8 +39,7 @@
* re-ordering. e.g.) Link Add came in, but Switch was not there.
*
*/
-public class TopologyManager implements NetworkGraphDiscoveryInterface,
- NetworkGraphReplicationInterface {
+public class TopologyManager implements NetworkGraphDiscoveryInterface {
private static final Logger log = LoggerFactory
.getLogger(TopologyManager.class);
@@ -142,10 +141,6 @@
*/
private void processEvents(Collection<EventEntry<TopologyEvent>> events) {
for (EventEntry<TopologyEvent> event : events) {
- if (event.eventData().getOriginID().equals(registryService.getControllerId())) {
- // ignore event triggered by myself
- continue;
- }
TopologyEvent topologyEvent = event.eventData();
switch (event.eventType()) {
case ENTRY_ADD:
@@ -251,8 +246,7 @@
public void putSwitchDiscoveryEvent(SwitchEvent switchEvent) {
if (datastore.addSwitch(switchEvent)) {
// Send out notification
- TopologyEvent topologyEvent =
- new TopologyEvent(switchEvent, registryService.getControllerId());
+ TopologyEvent topologyEvent = new TopologyEvent(switchEvent);
eventChannel.addEntry(topologyEvent.getID(), topologyEvent);
}
}
@@ -269,8 +263,7 @@
public void putPortDiscoveryEvent(PortEvent portEvent) {
if (datastore.addPort(portEvent)) {
// Send out notification
- TopologyEvent topologyEvent =
- new TopologyEvent(portEvent, registryService.getControllerId());
+ TopologyEvent topologyEvent = new TopologyEvent(portEvent);
}
}
@@ -286,8 +279,7 @@
public void putLinkDiscoveryEvent(LinkEvent linkEvent) {
if (datastore.addLink(linkEvent)) {
// Send out notification
- TopologyEvent topologyEvent =
- new TopologyEvent(linkEvent, registryService.getControllerId());
+ TopologyEvent topologyEvent = new TopologyEvent(linkEvent);
eventChannel.addEntry(topologyEvent.getID(), topologyEvent);
}
}
@@ -304,9 +296,7 @@
public void putDeviceDiscoveryEvent(DeviceEvent deviceEvent) {
if (datastore.addDevice(deviceEvent)) {
// Send out notification
- TopologyEvent topologyEvent =
- new TopologyEvent(deviceEvent,
- registryService.getControllerId());
+ TopologyEvent topologyEvent = new TopologyEvent(deviceEvent);
eventChannel.addEntry(topologyEvent.getID(), topologyEvent);
}
}
@@ -319,6 +309,82 @@
}
}
+ /* ************************************************
+ * Internal methods for processing the replication events
+ * ************************************************/
+
+ private void putSwitchReplicationEvent(SwitchEvent switchEvent) {
+ if (prepareForAddSwitchEvent(switchEvent)) {
+ putSwitch(switchEvent);
+ }
+ // TODO handle invariant violation
+ // trigger instance local topology event handler
+ dispatchPutSwitchEvent(switchEvent);
+ }
+
+ private void removeSwitchReplicationEvent(SwitchEvent switchEvent) {
+ if (prepareForRemoveSwitchEvent(switchEvent)) {
+ removeSwitch(switchEvent);
+ }
+ // TODO handle invariant violation
+ // trigger instance local topology event handler
+ dispatchRemoveSwitchEvent(switchEvent);
+ }
+
+ private void putPortReplicationEvent(PortEvent portEvent) {
+ if (prepareForAddPortEvent(portEvent)) {
+ putPort(portEvent);
+ }
+ // TODO handle invariant violation
+ // trigger instance local topology event handler
+ dispatchPutPortEvent(portEvent);
+ }
+
+ private void removePortReplicationEvent(PortEvent portEvent) {
+ if (prepareForRemovePortEvent(portEvent)) {
+ removePort(portEvent);
+ }
+ // TODO handle invariant violation
+ // trigger instance local topology event handler
+ dispatchRemovePortEvent(portEvent);
+ }
+
+ private void putLinkReplicationEvent(LinkEvent linkEvent) {
+ if (prepareForAddLinkEvent(linkEvent)) {
+ putLink(linkEvent);
+ }
+ // TODO handle invariant violation
+ // trigger instance local topology event handler
+ dispatchPutLinkEvent(linkEvent);
+ }
+
+ private void removeLinkReplicationEvent(LinkEvent linkEvent) {
+ if (prepareForRemoveLinkEvent(linkEvent)) {
+ removeLink(linkEvent);
+ }
+ // TODO handle invariant violation
+ // trigger instance local topology event handler
+ dispatchRemoveLinkEvent(linkEvent);
+ }
+
+ private void putDeviceReplicationEvent(DeviceEvent deviceEvent) {
+ if (prepareForAddDeviceEvent(deviceEvent)) {
+ putDevice(deviceEvent);
+ }
+ // TODO handle invariant violation
+ // trigger instance local topology event handler
+ dispatchPutDeviceEvent(deviceEvent);
+ }
+
+ private void removeDeviceReplicationEvent(DeviceEvent deviceEvent) {
+ if (prepareForRemoveDeviceEvent(deviceEvent)) {
+ removeDevice(deviceEvent);
+ }
+ // TODO handle invariant violation
+ // trigger instance local topology event handler
+ dispatchRemoveDeviceEvent(deviceEvent);
+ }
+
/* *****************
* Internal methods to maintain invariants of the network graph
* *****************/
@@ -543,90 +609,6 @@
return true;
}
- /* ******************************
- * NetworkGraphReplicationInterface methods
- * ******************************/
-
- @Override
- public void putSwitchReplicationEvent(SwitchEvent switchEvent) {
- if (prepareForAddSwitchEvent(switchEvent)) {
- putSwitch(switchEvent);
- }
- // TODO handle invariant violation
- // trigger instance local topology event handler
- dispatchPutSwitchEvent(switchEvent);
- }
-
- @Override
- public void removeSwitchReplicationEvent(SwitchEvent switchEvent) {
- if (prepareForRemoveSwitchEvent(switchEvent)) {
- removeSwitch(switchEvent);
- }
- // TODO handle invariant violation
- // trigger instance local topology event handler
- dispatchRemoveSwitchEvent(switchEvent);
- }
-
- @Override
- public void putPortReplicationEvent(PortEvent portEvent) {
- if (prepareForAddPortEvent(portEvent)) {
- putPort(portEvent);
- }
- // TODO handle invariant violation
- // trigger instance local topology event handler
- dispatchPutPortEvent(portEvent);
- }
-
- @Override
- public void removePortReplicationEvent(PortEvent portEvent) {
- if (prepareForRemovePortEvent(portEvent)) {
- removePort(portEvent);
- }
- // TODO handle invariant violation
- // trigger instance local topology event handler
- dispatchRemovePortEvent(portEvent);
- }
-
- @Override
- public void putLinkReplicationEvent(LinkEvent linkEvent) {
- if (prepareForAddLinkEvent(linkEvent)) {
- putLink(linkEvent);
- }
- // TODO handle invariant violation
- // trigger instance local topology event handler
- dispatchPutLinkEvent(linkEvent);
- }
-
- @Override
- public void removeLinkReplicationEvent(LinkEvent linkEvent) {
- if (prepareForRemoveLinkEvent(linkEvent)) {
- removeLink(linkEvent);
- }
- // TODO handle invariant violation
- // trigger instance local topology event handler
- dispatchRemoveLinkEvent(linkEvent);
- }
-
- @Override
- public void putDeviceReplicationEvent(DeviceEvent deviceEvent) {
- if (prepareForAddDeviceEvent(deviceEvent)) {
- putDevice(deviceEvent);
- }
- // TODO handle invariant violation
- // trigger instance local topology event handler
- dispatchPutDeviceEvent(deviceEvent);
- }
-
- @Override
- public void removeDeviceReplicationEvent(DeviceEvent deviceEvent) {
- if (prepareForRemoveDeviceEvent(deviceEvent)) {
- removeDevice(deviceEvent);
- }
- // TODO handle invariant violation
- // trigger instance local topology event handler
- dispatchRemoveDeviceEvent(deviceEvent);
- }
-
/* ************************************************
* Internal In-memory object mutation methods.
* ************************************************/