- public void onDataChanged(AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> change) {
-
- /*
- * TerminationPoint notifications with OVSDB augmentations
- * vSwitch ports. Iterate through the list of new ports.
- */
- for (Entry<InstanceIdentifier<?>, DataObject> entry : change.getCreatedData().entrySet()) {
- if (entry.getValue() instanceof OvsdbTerminationPointAugmentation) {
- OvsdbTerminationPointAugmentation ovsdbTp = (OvsdbTerminationPointAugmentation) entry.getValue();
- @SuppressWarnings("unchecked")
- InstanceIdentifier<OvsdbTerminationPointAugmentation> ovsdbTpIid = (InstanceIdentifier<OvsdbTerminationPointAugmentation>) entry.getKey();
- OvsdbBridgeAugmentation ovsdbBridge = getOvsdbBridgeFromTerminationPoint(ovsdbTpIid, dataBroker);
- nodeIdByTerminPoint.put(ovsdbTpIid,
- new NodeId(getInventoryNodeIdString(ovsdbBridge, ovsdbTpIid, dataBroker)));
- processOvsdbBridge(ovsdbBridge, ovsdbTp, ovsdbTpIid);
- }
- }
-
- /*
- * Updates
- */
- for (Entry<InstanceIdentifier<?>, DataObject> entry : change.getUpdatedData().entrySet()) {
- if (entry.getValue() instanceof OvsdbTerminationPointAugmentation) {
- OvsdbTerminationPointAugmentation ovsdbTp = (OvsdbTerminationPointAugmentation) entry.getValue();
- @SuppressWarnings("unchecked")
- InstanceIdentifier<OvsdbTerminationPointAugmentation> ovsdbTpIid = (InstanceIdentifier<OvsdbTerminationPointAugmentation>) entry.getKey();
- OvsdbBridgeAugmentation ovsdbBridge = getOvsdbBridgeFromTerminationPoint(ovsdbTpIid, dataBroker);
- processOvsdbBridge(ovsdbBridge, ovsdbTp, ovsdbTpIid);
- }
- }
-
- /*
- * Deletions
- */
- for (InstanceIdentifier<?> iid : change.getRemovedPaths()) {
- DataObject old = change.getOriginalData().get(iid);
- if (old instanceof OvsdbTerminationPointAugmentation) {
- OvsdbTerminationPointAugmentation ovsdbTp = (OvsdbTerminationPointAugmentation) old;
- @SuppressWarnings("unchecked")
- InstanceIdentifier<OvsdbTerminationPointAugmentation> ovsdbTpIid = (InstanceIdentifier<OvsdbTerminationPointAugmentation>) iid;
- processRemovedTp(nodeIdByTerminPoint.get(ovsdbTpIid) , ovsdbTp, ovsdbTpIid);
+ public void onDataTreeChanged(Collection<DataTreeModification<OvsdbTerminationPointAugmentation>> changes) {
+ for (DataTreeModification<OvsdbTerminationPointAugmentation> change: changes) {
+ DataObjectModification<OvsdbTerminationPointAugmentation> rootNode = change.getRootNode();
+ InstanceIdentifier<OvsdbTerminationPointAugmentation> ovsdbTpIid = change.getRootPath().getRootIdentifier();
+ OvsdbTerminationPointAugmentation origOvsdbTp = rootNode.getDataBefore();
+ switch (rootNode.getModificationType()) {
+ case SUBTREE_MODIFIED:
+ case WRITE:
+ OvsdbTerminationPointAugmentation updatedOvsdbTp = rootNode.getDataAfter();
+ OvsdbBridgeAugmentation ovsdbBridge = getOvsdbBridgeFromTerminationPoint(ovsdbTpIid, dataBroker);
+ if (origOvsdbTp == null) {
+ NODE_ID_BY_TERMIN_POINT.put(ovsdbTpIid,
+ new NodeId(getInventoryNodeIdString(ovsdbBridge, ovsdbTpIid, dataBroker)));
+ }
+
+ processOvsdbBridge(ovsdbBridge, updatedOvsdbTp, ovsdbTpIid);
+ break;
+ case DELETE:
+ processRemovedTp(NODE_ID_BY_TERMIN_POINT.get(ovsdbTpIid), origOvsdbTp, ovsdbTpIid);
+ break;
+ default:
+ break;