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.table.statistics.rev131215.FlowTableStatisticsData;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.FlowTableStatisticsUpdate;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.FlowTableStatisticsUpdateBuilder;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.flow.table.and.statistics.map.FlowTableAndStatisticsMapBuilder;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.flow.table.and.statistics.map.FlowTableAndStatisticsMapKey;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.flow.table.statistics.FlowTableStatistics;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableId;
25 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
28 * Implementation define a contract between {@link FlowTableStatistics} data object
29 * and {@link FlowTableStatisticsUpdate} notification.
31 public class FlowTableStatNotificationSupplierImpl extends
32 AbstractNotificationSupplierForItemStat<FlowTableStatistics, FlowTableStatisticsUpdate> {
34 private static final InstanceIdentifier<FlowTableStatistics> FLOW_TABLE_STATISTICS_INSTANCE_IDENTIFIER
35 = getNodeWildII().augmentation(FlowCapableNode.class).child(Table.class)
36 .augmentation(FlowTableStatisticsData.class).child(FlowTableStatistics.class);
39 * Constructor register supplier as DataTreeChangeListener and create wildCarded InstanceIdentifier.
41 * @param notifProviderService - {@link NotificationProviderService}
42 * @param db - {@link DataBroker}
44 public FlowTableStatNotificationSupplierImpl(final NotificationProviderService notifProviderService,
45 final DataBroker db) {
46 super(notifProviderService, db, FlowTableStatistics.class);
50 public InstanceIdentifier<FlowTableStatistics> getWildCardPath() {
51 return FLOW_TABLE_STATISTICS_INSTANCE_IDENTIFIER;
55 public FlowTableStatisticsUpdate createNotification(final FlowTableStatistics flowTableStatistics,
56 final InstanceIdentifier<FlowTableStatistics> path) {
57 Preconditions.checkArgument(flowTableStatistics != null);
58 Preconditions.checkArgument(path != null);
60 final FlowTableAndStatisticsMapBuilder ftsmBuilder = new FlowTableAndStatisticsMapBuilder(flowTableStatistics);
61 ftsmBuilder.withKey(new FlowTableAndStatisticsMapKey(
62 new TableId(path.firstKeyOf(Table.class).getId())));
64 final FlowTableStatisticsUpdateBuilder builder = new FlowTableStatisticsUpdateBuilder();
65 builder.setId(getNodeId(path));
66 builder.setMoreReplies(Boolean.FALSE);
67 // NOTE : fix if it needs, but we have to ask DataStore for the NodeConnector list
68 builder.setNodeConnector(Collections.<NodeConnector>emptyList());
69 builder.setFlowTableAndStatisticsMap(Collections.singletonList(ftsmBuilder.build()));
70 return builder.build();