X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fcompatibility%2Fsal-compatibility%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fsal%2Fcompatibility%2FInventoryAndReadAdapter.xtend;h=60e43247c2810383f49b05a24699d14c1c1f355b;hp=39d224ba164c937dc9ca389259f640a22b177d20;hb=405ea7ce68d22bd3d2501857c5253793b581b086;hpb=d67608349eca39dd2b4b77923b1500d25a664e52 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 39d224ba16..60e43247c2 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 @@ -1,3 +1,10 @@ +/* + * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ package org.opendaylight.controller.sal.compatibility import java.util.ArrayList @@ -146,7 +153,7 @@ class InventoryAndReadAdapter implements IPluginInReadService, for(flow : table.flow){ - val adsalFlow = ToSalConversionsUtils.toFlow(flow); + val adsalFlow = ToSalConversionsUtils.toFlow(flow,node); val statsFromDataStore = flow.getAugmentation(FlowStatisticsData); if(statsFromDataStore != null){ @@ -367,7 +374,10 @@ class InventoryAndReadAdapter implements IPluginInReadService, for (statsPublisher : statisticsPublisher){ val nodeRef = InstanceIdentifier.builder(Nodes).child(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node,new NodeKey(notification.id)).toInstance; - statsPublisher.descriptionStatisticsUpdated(nodeRef.toADNode,toNodeDescription(notification.nodeRef)); + val description = notification.nodeRef.toNodeDescription + if(description != null) { + statsPublisher.descriptionStatisticsUpdated(nodeRef.toADNode,description); + } } } @@ -434,9 +444,12 @@ class InventoryAndReadAdapter implements IPluginInReadService, private def FlowCapableNode readFlowCapableNode(NodeRef ref) { val dataObject = dataService.readOperationalData(ref.value as InstanceIdentifier); - val node = dataObject.checkInstanceOf( - org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node); - return node.getAugmentation(FlowCapableNode); + if(dataObject != null) { + val node = dataObject.checkInstanceOf( + org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node); + return node.getAugmentation(FlowCapableNode); + } + return null; } private def FlowCapableNodeConnector readFlowCapableNodeConnector(NodeConnectorRef ref) { @@ -492,14 +505,16 @@ class InventoryAndReadAdapter implements IPluginInReadService, private def toNodeDescription(NodeRef nodeRef){ val capableNode = readFlowCapableNode(nodeRef); - - val it = new NodeDescription() - manufacturer = capableNode.manufacturer - serialNumber = capableNode.serialNumber - software = capableNode.software - description = capableNode.description - - return it; + if(capableNode !=null) { + val it = new NodeDescription() + manufacturer = capableNode.manufacturer + serialNumber = capableNode.serialNumber + software = capableNode.software + description = capableNode.description + + return it; + } + return null; } @@ -517,14 +532,14 @@ class InventoryAndReadAdapter implements IPluginInReadService, override onFlowsStatisticsUpdate(FlowsStatisticsUpdate notification) { val adsalFlowsStatistics = new ArrayList(); + val nodeRef = InstanceIdentifier.builder(Nodes).child(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node,new NodeKey(notification.id)).toInstance; for(flowStats : notification.flowAndStatisticsMapList){ if(flowStats.tableId == 0) - adsalFlowsStatistics.add(toFlowOnNode(flowStats)); + adsalFlowsStatistics.add(toFlowOnNode(flowStats,nodeRef.toADNode)); } for (statsPublisher : statisticsPublisher){ - val nodeRef = InstanceIdentifier.builder(Nodes).child(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node,new NodeKey(notification.id)).toInstance; statsPublisher.nodeFlowStatisticsUpdated(nodeRef.toADNode,adsalFlowsStatistics); } @@ -569,9 +584,9 @@ class InventoryAndReadAdapter implements IPluginInReadService, } - private static def toFlowOnNode (FlowAndStatisticsMapList flowAndStatsMap){ + private static def toFlowOnNode (FlowAndStatisticsMapList flowAndStatsMap,Node node){ - val it = new FlowOnNode(ToSalConversionsUtils.toFlow(flowAndStatsMap)); + val it = new FlowOnNode(ToSalConversionsUtils.toFlow(flowAndStatsMap,node)); byteCount = flowAndStatsMap.byteCount.value.longValue; packetCount = flowAndStatsMap.packetCount.value.longValue;