BUG-4565: queue stats error 91/29191/3
authorMichal Rehak <mirehak@cisco.com>
Tue, 3 Nov 2015 14:54:21 +0000 (15:54 +0100)
committerMichal Rehak <mirehak@cisco.com>
Wed, 4 Nov 2015 08:21:27 +0000 (09:21 +0100)
 - queues do not have any other inspect message but statistics query,
   here 1 parent was missing when writing queue stats into DS/operational
   - addapted data assembly in order to create queue node
   - added TODO: we need to clean existing queues before writing fresh ones
 - fixed test

Change-Id: Icfcb692100b2a0aa666c2e578b09cd903e59fd80
Signed-off-by: Michal Rehak <mirehak@cisco.com>
(cherry picked from commit b706170bb88018010bde3d8bd84ef1bbf4662943)

openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsGatheringUtils.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsGatheringUtilsTest.java

index b3952c61af59fc96822ab27a9ff20b19e1bc3bdb..b6ce236a5e9fff4086ddd3e47847c5c54fdc5499 100644 (file)
@@ -51,6 +51,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev13
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.flow.table.statistics.FlowTableStatistics;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.flow.table.statistics.FlowTableStatisticsBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.queues.Queue;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.queues.QueueBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.queues.QueueKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GroupDescStatsUpdated;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GroupStatisticsUpdated;
@@ -259,6 +260,7 @@ public final class StatisticsGatheringUtils {
     }
 
     private static void processQueueStatistics(final Iterable<QueueStatisticsUpdate> data, final DeviceContext deviceContext) {
+        // TODO: clean all queues of all node-connectors before writing up-to-date stats
         final InstanceIdentifier<Node> nodeIdent = deviceContext.getDeviceState().getNodeInstanceIdentifier();
         for (final QueueStatisticsUpdate queueStatisticsUpdate : data) {
             for (final QueueIdAndStatisticsMap queueStat : queueStatisticsUpdate.getQueueIdAndStatisticsMap()) {
@@ -273,8 +275,12 @@ public final class StatisticsGatheringUtils {
                             .child(NodeConnector.class, new NodeConnectorKey(queueStat.getNodeConnectorId()))
                             .augmentation(FlowCapableNodeConnector.class)
                             .child(Queue.class, qKey);
-                    final InstanceIdentifier<FlowCapableNodeConnectorQueueStatisticsData> queueStatIdent = queueIdent.augmentation(FlowCapableNodeConnectorQueueStatisticsData.class);
-                    deviceContext.writeToTransaction(LogicalDatastoreType.OPERATIONAL, queueStatIdent, statBuild.build());
+                    final QueueBuilder queueBuilder = new QueueBuilder()
+                            .setKey(qKey)
+                            .setQueueId(queueStat.getQueueId())
+                            // node-connector-id is already contained in parent node and the port-id here is of incompatible format
+                            .addAugmentation(FlowCapableNodeConnectorQueueStatisticsData.class, statBuild.build());
+                    deviceContext.writeToTransaction(LogicalDatastoreType.OPERATIONAL, queueIdent, queueBuilder.build());
                 }
             }
         }
index 86448ab68ca0767eb74391e8000d3885c64d0b9f..c0871b26a8864ba778b1cf73585e302a02a78987 100644 (file)
@@ -392,15 +392,14 @@ public class StatisticsGatheringUtilsTest {
 
         fireAndCheck(type, statsData);
 
-        InstanceIdentifier<FlowCapableNodeConnectorQueueStatisticsData> queuePath = dummyNodePath
+        KeyedInstanceIdentifier<Queue, QueueKey> queuePath = dummyNodePath
                 .child(NodeConnector.class, new NodeConnectorKey(new NodeConnectorId("openflow:" + DUMMY_NODE_ID_VALUE + ":11")))
                 .augmentation(FlowCapableNodeConnector.class)
-                .child(Queue.class, new QueueKey(new QueueId(queueIdValue)))
-                .augmentation(FlowCapableNodeConnectorQueueStatisticsData.class);
+                .child(Queue.class, new QueueKey(new QueueId(queueIdValue)));
         verify(deviceContext).writeToTransaction(
                 Matchers.eq(LogicalDatastoreType.OPERATIONAL),
                 Matchers.eq(queuePath),
-                Matchers.any(FlowCapableNodeConnectorQueueStatisticsData.class));
+                Matchers.any(Queue.class));
     }
 
     @Test