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
9 package org.opendaylight.openflowplugin.impl.datastore.multipart;
11 import org.opendaylight.openflowplugin.api.openflow.device.DeviceRegistry;
12 import org.opendaylight.openflowplugin.api.openflow.device.TxFacade;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.MeterBuilder;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.MeterKey;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.NodeMeterStatistics;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.NodeMeterStatisticsBuilder;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterConfigStatsReply;
21 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
23 public class MeterConfigMultipartWriter extends AbstractMultipartWriter<MeterConfigStatsReply> {
25 private final DeviceRegistry registry;
27 public MeterConfigMultipartWriter(final TxFacade txFacade,
28 final InstanceIdentifier<Node> instanceIdentifier,
29 final DeviceRegistry registry) {
30 super(txFacade, instanceIdentifier);
31 this.registry = registry;
35 protected Class<MeterConfigStatsReply> getType() {
36 return MeterConfigStatsReply.class;
40 public void storeStatistics(final MeterConfigStatsReply statistics, final boolean withParents) {
41 statistics.getMeterConfigStats()
44 getInstanceIdentifier()
45 .augmentation(FlowCapableNode.class)
46 .child(Meter.class, new MeterKey(stat.getMeterId())),
47 new MeterBuilder(stat)
48 .withKey(new MeterKey(stat.getMeterId()))
49 .addAugmentation(NodeMeterStatistics.class, new NodeMeterStatisticsBuilder().build())
53 registry.getDeviceMeterRegistry().store(stat.getMeterId());