2 * Copyright (c) 2015 Cisco Systems, Inc. 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.applications.notification.supplier.impl.item.stat;
11 import com.google.common.base.Preconditions;
12 import java.util.Collections;
13 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
14 import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.FlowTableStatisticsData;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.FlowTableStatisticsUpdate;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.FlowTableStatisticsUpdateBuilder;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.flow.table.and.statistics.map.FlowTableAndStatisticsMapBuilder;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.flow.table.and.statistics.map.FlowTableAndStatisticsMapKey;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.flow.table.statistics.FlowTableStatistics;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector;
25 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableId;
26 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
29 * Implementation define a contract between {@link FlowTableStatistics} data object
30 * and {@link FlowTableStatisticsUpdate} notification.
32 public class FlowTableStatNotificationSupplierImpl extends
33 AbstractNotificationSupplierForItemStat<FlowTableStatistics, FlowTableStatisticsUpdate> {
35 private static final InstanceIdentifier<FlowTableStatistics> FLOW_TABLE_STATISTICS_INSTANCE_IDENTIFIER
36 = getNodeWildII().augmentation(FlowCapableNode.class).child(Table.class)
37 .augmentation(FlowTableStatisticsData.class).child(FlowTableStatistics.class);
40 * Constructor register supplier as DataTreeChangeListener and create wildCarded InstanceIdentifier.
42 * @param notifProviderService - {@link NotificationProviderService}
43 * @param db - {@link DataBroker}
45 public FlowTableStatNotificationSupplierImpl(final NotificationProviderService notifProviderService,
46 final DataBroker db) {
47 super(notifProviderService, db, FlowTableStatistics.class);
51 public InstanceIdentifier<FlowTableStatistics> getWildCardPath() {
52 return FLOW_TABLE_STATISTICS_INSTANCE_IDENTIFIER;
56 public FlowTableStatisticsUpdate createNotification(final FlowTableStatistics flowTableStatistics,
57 final InstanceIdentifier<FlowTableStatistics> path) {
58 Preconditions.checkArgument(flowTableStatistics != null);
59 Preconditions.checkArgument(path != null);
61 final FlowTableAndStatisticsMapBuilder ftsmBuilder = new FlowTableAndStatisticsMapBuilder(flowTableStatistics);
62 ftsmBuilder.setKey(new FlowTableAndStatisticsMapKey(
63 new TableId(path.firstKeyOf(Table.class, TableKey.class).getId())));
65 final FlowTableStatisticsUpdateBuilder builder = new FlowTableStatisticsUpdateBuilder();
66 builder.setId(getNodeId(path));
67 builder.setMoreReplies(Boolean.FALSE);
68 // NOTE : fix if it needs, but we have to ask DataStore for the NodeConnector list
69 builder.setNodeConnector(Collections.<NodeConnector>emptyList());
70 builder.setFlowTableAndStatisticsMap(Collections.singletonList(ftsmBuilder.build()));
71 return builder.build();