From b43034441d8d3a94d8b5eb4056b91b68e1a48ac4 Mon Sep 17 00:00:00 2001 From: Moiz Raja Date: Wed, 18 Dec 2013 17:14:38 -0800 Subject: [PATCH] Generate ADDED events for Node and NodeConnector Components like switch manager need to see an ADDED event come in for Node and NodeConnector before they accept changes for those elements. This commit first checks whether a Node/NodeConnector are already known to the DataBrokerService. If they are not known then it notifies the listeners of an ADDED event otherwise it notifies it of a CHANGED event Also implemented node removal. NOTE: NodeConnector removed events do not seem to be coming through. Change-Id: Idcbe7fdce37c16158614f62b56767bed624bc803 Signed-off-by: Moiz Raja --- .../InventoryAndReadAdapter.xtend | 30 ++++++++++++++++--- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/InventoryAndReadAdapter.xtend b/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/InventoryAndReadAdapter.xtend index 8ac6f1b050..609ace4695 100644 --- a/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/InventoryAndReadAdapter.xtend +++ b/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/InventoryAndReadAdapter.xtend @@ -157,17 +157,39 @@ class InventoryAndReadAdapter implements IPluginInTopologyService, IPluginInRead } override onNodeRemoved(NodeRemoved notification) { - // NOOP + val properties = Collections.emptySet(); + val org.opendaylight.yangtools.yang.binding.InstanceIdentifier identifier = notification.nodeRef.value as org.opendaylight.yangtools.yang.binding.InstanceIdentifier; + + inventoryPublisher.updateNode(notification.nodeRef.toADNode, UpdateType.REMOVED, properties); } override onNodeConnectorUpdated(NodeConnectorUpdated update) { - val properties = Collections.emptySet(); - inventoryPublisher.updateNodeConnector(update.nodeConnectorRef.toADNodeConnector, UpdateType.CHANGED, properties); + val properties = new java.util.HashSet(); + + + val org.opendaylight.yangtools.yang.binding.InstanceIdentifier identifier = update.nodeConnectorRef.value as org.opendaylight.yangtools.yang.binding.InstanceIdentifier; + var updateType = UpdateType.CHANGED; + if ( this._dataService.readOperationalData(identifier) == null ){ + updateType = UpdateType.ADDED; + } + + var nodeConnector = update.nodeConnectorRef.toADNodeConnector + + + properties.add(new org.opendaylight.controller.sal.core.Name(nodeConnector.ID.toString())); + + inventoryPublisher.updateNodeConnector(nodeConnector , updateType , properties); } override onNodeUpdated(NodeUpdated notification) { val properties = Collections.emptySet(); - inventoryPublisher.updateNode(notification.nodeRef.toADNode, UpdateType.CHANGED, properties); + val org.opendaylight.yangtools.yang.binding.InstanceIdentifier identifier = notification.nodeRef.value as org.opendaylight.yangtools.yang.binding.InstanceIdentifier; + + var updateType = UpdateType.CHANGED; + if ( this._dataService.readOperationalData(identifier) == null ){ + updateType = UpdateType.ADDED; + } + inventoryPublisher.updateNode(notification.nodeRef.toADNode, updateType, properties); } override getNodeProps() { -- 2.36.6