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
8 package org.opendaylight.openflowplugin.applications.notification.supplier.impl.item.stat;
10 import com.google.common.base.Preconditions;
11 import java.util.Collections;
12 import org.opendaylight.mdsal.binding.api.DataBroker;
13 import org.opendaylight.mdsal.binding.api.NotificationPublishService;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.FlowTableStatisticsData;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.FlowTableStatisticsUpdate;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.FlowTableStatisticsUpdateBuilder;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.flow.table.and.statistics.map.FlowTableAndStatisticsMapBuilder;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.flow.table.and.statistics.map.FlowTableAndStatisticsMapKey;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.flow.table.statistics.FlowTableStatistics;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableId;
24 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
27 * Implementation define a contract between {@link FlowTableStatistics} data object
28 * and {@link FlowTableStatisticsUpdate} notification.
30 public class FlowTableStatNotificationSupplierImpl extends
31 AbstractNotificationSupplierForItemStat<FlowTableStatistics, FlowTableStatisticsUpdate> {
33 private static final InstanceIdentifier<FlowTableStatistics> FLOW_TABLE_STATISTICS_INSTANCE_IDENTIFIER
34 = getNodeWildII().augmentation(FlowCapableNode.class).child(Table.class)
35 .augmentation(FlowTableStatisticsData.class).child(FlowTableStatistics.class);
38 * Constructor register supplier as DataTreeChangeListener and create wildCarded InstanceIdentifier.
40 * @param notifProviderService - {@link NotificationPublishService}
41 * @param db - {@link DataBroker}
43 public FlowTableStatNotificationSupplierImpl(final NotificationPublishService notifProviderService,
44 final DataBroker db) {
45 super(notifProviderService, db, FlowTableStatistics.class);
49 public InstanceIdentifier<FlowTableStatistics> getWildCardPath() {
50 return FLOW_TABLE_STATISTICS_INSTANCE_IDENTIFIER;
54 public FlowTableStatisticsUpdate createNotification(final FlowTableStatistics flowTableStatistics,
55 final InstanceIdentifier<FlowTableStatistics> path) {
56 Preconditions.checkArgument(flowTableStatistics != null);
57 Preconditions.checkArgument(path != null);
59 final FlowTableAndStatisticsMapBuilder ftsmBuilder = new FlowTableAndStatisticsMapBuilder(flowTableStatistics);
60 ftsmBuilder.withKey(new FlowTableAndStatisticsMapKey(
61 new TableId(path.firstKeyOf(Table.class).getId())));
63 final FlowTableStatisticsUpdateBuilder builder = new FlowTableStatisticsUpdateBuilder();
64 builder.setId(getNodeId(path));
65 builder.setMoreReplies(Boolean.FALSE);
66 // NOTE : fix if it needs, but we have to ask DataStore for the NodeConnector list
67 builder.setNodeConnector(Collections.<NodeConnector>emptyList());
68 builder.setFlowTableAndStatisticsMap(Collections.singletonList(ftsmBuilder.build()));
69 return builder.build();