+/*
+ * 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
for(flow : table.flow){
- val adsalFlow = ToSalConversionsUtils.toFlow(flow);
+ val adsalFlow = ToSalConversionsUtils.toFlow(flow,node);
val statsFromDataStore = flow.getAugmentation(FlowStatisticsData);
if(statsFromDataStore != null){
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);
+ }
}
}
private def FlowCapableNode readFlowCapableNode(NodeRef ref) {
val dataObject = dataService.readOperationalData(ref.value as InstanceIdentifier<? extends DataObject>);
- 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) {
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;
}
override onFlowsStatisticsUpdate(FlowsStatisticsUpdate notification) {
val adsalFlowsStatistics = new ArrayList<FlowOnNode>();
+ 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);
}
}
- 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;