X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fcompatibility%2Fsal-compatibility%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fsal%2Fcompatibility%2FInventoryAndReadAdapter.xtend;h=39d224ba164c937dc9ca389259f640a22b177d20;hb=9390dd5bea2420cdbb1e4f6c2029091811c4df5a;hp=56ca1b609cf2c6eeb6d5dfe669b660319d4d792d;hpb=f46e0c0ac627304099c17783696bc0b5c9f622e1;p=controller.git 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 56ca1b609c..39d224ba16 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 @@ -3,6 +3,8 @@ package org.opendaylight.controller.sal.compatibility import java.util.ArrayList import java.util.Collections import java.util.List +import java.util.Set +import java.util.concurrent.CopyOnWriteArrayList; import org.opendaylight.controller.sal.binding.api.data.DataBrokerService import org.opendaylight.controller.sal.binding.api.data.DataProviderService import org.opendaylight.controller.sal.core.Edge @@ -93,15 +95,23 @@ class InventoryAndReadAdapter implements IPluginInReadService, @Property OpendaylightFlowTableStatisticsService flowTableStatisticsService; - @Property - IPluginOutInventoryService inventoryPublisher; - @Property FlowTopologyDiscoveryService topologyDiscovery; @Property - List statisticsPublisher = new ArrayList(); - + List statisticsPublisher = new CopyOnWriteArrayList(); + + @Property + List inventoryPublisher = new CopyOnWriteArrayList(); + + def setInventoryPublisher(IPluginOutInventoryService listener){ + inventoryPublisher.add(listener); + } + + def unsetInventoryPublisher(IPluginOutInventoryService listener){ + inventoryPublisher.remove(listener); + } + def setReadPublisher(IPluginOutReadService listener) { statisticsPublisher.add(listener); } @@ -132,12 +142,12 @@ class InventoryAndReadAdapter implements IPluginInReadService, val table= it.readConfigurationData(tableRef) as Table; if(table != null){ - LOG.info("Number of flows installed in table 0 of node {} : {}",node,table.flow.size); + LOG.trace("Number of flows installed in table 0 of node {} : {}",node,table.flow.size); for(flow : table.flow){ val adsalFlow = ToSalConversionsUtils.toFlow(flow); - val statsFromDataStore = flow.getAugmentation(FlowStatisticsData) as FlowStatisticsData; + val statsFromDataStore = flow.getAugmentation(FlowStatisticsData); if(statsFromDataStore != null){ val it = new FlowOnNode(adsalFlow); @@ -207,7 +217,7 @@ class InventoryAndReadAdapter implements IPluginInReadService, for (table : dsFlowCapableNode.table){ - val tableStats = table.getAugmentation(FlowTableStatisticsData) as FlowTableStatisticsData; + val tableStats = table.getAugmentation(FlowTableStatisticsData); if(tableStats != null){ ret.add(toNodeTableStatistics(tableStats.flowTableStatistics,table.id,node)); @@ -238,11 +248,11 @@ class InventoryAndReadAdapter implements IPluginInReadService, val table= it.readConfigurationData(tableRef) as Table; if(table != null){ - LOG.info("Number of flows installed in table 0 of node {} : {}",node,table.flow.size); + LOG.trace("Number of flows installed in table 0 of node {} : {}",node,table.flow.size); for(mdsalFlow : table.flow){ if(FromSalConversionsUtils.flowEquals(mdsalFlow, MDFlowMapping.toMDSalflow(targetFlow))){ - val statsFromDataStore = mdsalFlow.getAugmentation(FlowStatisticsData) as FlowStatisticsData; + val statsFromDataStore = mdsalFlow.getAugmentation(FlowStatisticsData); if(statsFromDataStore != null){ LOG.debug("Found matching flow in the data store flow table "); @@ -308,7 +318,7 @@ class InventoryAndReadAdapter implements IPluginInReadService, val table= it.readConfigurationData(tableRef) as Table; if(table != null){ - val tableStats = table.getAugmentation(FlowTableStatisticsData) as FlowTableStatisticsData; + val tableStats = table.getAugmentation(FlowTableStatisticsData); if(tableStats != null){ nodeStats = toNodeTableStatistics(tableStats.flowTableStatistics,table.id,nodeTable.node); @@ -330,7 +340,7 @@ class InventoryAndReadAdapter implements IPluginInReadService, override onNodeRemoved(NodeRemoved notification) { val properties = Collections.emptySet(); - inventoryPublisher.updateNode(notification.nodeRef.toADNode, UpdateType.REMOVED, properties); + publishNodeUpdate(notification.nodeRef.toADNode, UpdateType.REMOVED, properties); } override onNodeConnectorUpdated(NodeConnectorUpdated update) { @@ -341,18 +351,17 @@ class InventoryAndReadAdapter implements IPluginInReadService, var nodeConnector = update.nodeConnectorRef.toADNodeConnector - inventoryPublisher.updateNodeConnector(nodeConnector , updateType , update.toADNodeConnectorProperties); + publishNodeConnectorUpdate(nodeConnector , updateType , update.toADNodeConnectorProperties); } override onNodeUpdated(NodeUpdated notification) { - val properties = Collections.emptySet(); val InstanceIdentifier identifier = notification.nodeRef.value as InstanceIdentifier; var updateType = UpdateType.CHANGED; if ( this._dataService.readOperationalData(identifier) == null ){ updateType = UpdateType.ADDED; } - inventoryPublisher.updateNode(notification.nodeRef.toADNode, updateType, notification.toADNodeProperties); + publishNodeUpdate(notification.nodeRef.toADNode, updateType, notification.toADNodeProperties); //Notify the listeners of IPluginOutReadService @@ -502,7 +511,7 @@ class InventoryAndReadAdapter implements IPluginInReadService, * OpendaylightFlowStatisticsListener interface implementation */ override onAggregateFlowStatisticsUpdate(AggregateFlowStatisticsUpdate notification) { - throw new UnsupportedOperationException("TODO: auto-generated method stub") + //Ignoring this notification as there does not seem to be a way to bubble this up to AD-SAL } override onFlowsStatisticsUpdate(FlowsStatisticsUpdate notification) { @@ -571,4 +580,21 @@ class InventoryAndReadAdapter implements IPluginInReadService, return it; } + + override getConfiguredNotConnectedNodes() { + return Collections.emptySet(); + } + + + private def publishNodeUpdate(Node node, UpdateType updateType, Set properties){ + for( publisher : inventoryPublisher){ + publisher.updateNode(node, updateType, properties); + } + } + + private def publishNodeConnectorUpdate(org.opendaylight.controller.sal.core.NodeConnector nodeConnector, UpdateType updateType, Set properties){ + for( publisher : inventoryPublisher){ + publisher.updateNodeConnector(nodeConnector, updateType, properties); + } + } }