2 * Copyright (c) 2017 Pantheon Technologies s.r.o. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.openflowplugin.impl.datastore.multipart;
10 import org.opendaylight.openflowplugin.api.openflow.device.TxFacade;
11 import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;
12 import org.opendaylight.openflowplugin.openflow.md.util.InventoryDataServiceUtil;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.queues.Queue;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.queues.QueueBuilder;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.queues.QueueKey;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FeaturesReply;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.FlowCapableNodeConnectorQueueStatisticsData;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.FlowCapableNodeConnectorQueueStatisticsDataBuilder;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.QueueIdAndStatisticsMap;
25 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.flow.capable.node.connector.queue.statistics.FlowCapableNodeConnectorQueueStatisticsBuilder;
26 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
27 import org.opendaylight.yangtools.yang.common.Uint32;
29 public class QueueStatsMultipartWriter extends AbstractMultipartWriter<QueueIdAndStatisticsMap> {
31 private final FeaturesReply features;
34 public QueueStatsMultipartWriter(final TxFacade txFacade,
35 final InstanceIdentifier<Node> instanceIdentifier,
36 final FeaturesReply features) {
37 super(txFacade, instanceIdentifier);
38 this.features = features;
42 protected Class<QueueIdAndStatisticsMap> getType() {
43 return QueueIdAndStatisticsMap.class;
47 public void storeStatistics(final QueueIdAndStatisticsMap statistics, final boolean withParents) {
48 final OpenflowVersion openflowVersion = OpenflowVersion.get(features.getVersion());
50 statistics.getQueueIdAndStatisticsMap()
52 final Uint32 port = InventoryDataServiceUtil
53 .portNumberfromNodeConnectorId(openflowVersion, stat.getNodeConnectorId());
54 final NodeConnectorId id = InventoryDataServiceUtil
55 .nodeConnectorIdfromDatapathPortNo(
56 features.getDatapathId(),
58 OpenflowVersion.get(features.getVersion()));
61 getInstanceIdentifier()
62 .child(NodeConnector.class, new NodeConnectorKey(id))
63 .augmentation(FlowCapableNodeConnector.class)
64 .child(Queue.class, new QueueKey(stat.getQueueId())),
66 .withKey(new QueueKey(stat.getQueueId()))
67 .setQueueId(stat.getQueueId())
69 FlowCapableNodeConnectorQueueStatisticsData.class,
70 new FlowCapableNodeConnectorQueueStatisticsDataBuilder()
71 .setFlowCapableNodeConnectorQueueStatistics(
72 new FlowCapableNodeConnectorQueueStatisticsBuilder(stat)