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.group.statistics.rev131111.NodeGroupStatistics;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.NodeGroupStatisticsBuilder;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupDescStatsReply;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.GroupBuilder;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.GroupKey;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
21 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
23 public class GroupDescMultipartWriter extends AbstractMultipartWriter<GroupDescStatsReply> {
25 private final DeviceRegistry registry;
27 public GroupDescMultipartWriter(final TxFacade txFacade,
28 final InstanceIdentifier<Node> instanceIdentifier,
29 final DeviceRegistry registry) {
30 super(txFacade, instanceIdentifier);
31 this.registry = registry;
35 protected Class<GroupDescStatsReply> getType() {
36 return GroupDescStatsReply.class;
40 public void storeStatistics(final GroupDescStatsReply statistics, final boolean withParents) {
41 statistics.getGroupDescStats()
44 getInstanceIdentifier()
45 .augmentation(FlowCapableNode.class)
46 .child(Group.class, new GroupKey(stat.getGroupId())),
47 new GroupBuilder(stat)
48 .setKey(new GroupKey(stat.getGroupId()))
49 .addAugmentation(NodeGroupStatistics.class, new NodeGroupStatisticsBuilder().build())
53 registry.getDeviceGroupRegistry().store(stat.getGroupId());