2 * Copyright (c) 2015, 2017 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.frm.impl;
10 import com.google.common.util.concurrent.Futures;
11 import java.util.Collections;
12 import java.util.concurrent.Future;
13 import org.opendaylight.infrautils.utils.concurrent.LoggingFutures;
14 import org.opendaylight.mdsal.binding.api.DataBroker;
15 import org.opendaylight.openflowplugin.applications.frm.ForwardingRulesManager;
16 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.UpdateTableInputBuilder;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.table.update.OriginalTableBuilder;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.table.update.UpdatedTableBuilder;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableRef;
25 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures;
26 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
27 import org.opendaylight.yangtools.yang.common.RpcResult;
28 import org.slf4j.Logger;
29 import org.slf4j.LoggerFactory;
31 public class TableForwarder extends AbstractListeningCommiter<TableFeatures> {
33 private static final Logger LOG = LoggerFactory.getLogger(TableForwarder.class);
35 public TableForwarder(final ForwardingRulesManager manager, final DataBroker db,
36 final ListenerRegistrationHelper registrationHelper) {
37 super(manager, db, registrationHelper);
41 public void deregisterListener() {
47 if (listenerRegistration != null) {
48 listenerRegistration.close();
49 listenerRegistration = null;
54 protected InstanceIdentifier<TableFeatures> getWildCardPath() {
55 return InstanceIdentifier.create(Nodes.class).child(Node.class).augmentation(FlowCapableNode.class)
56 .child(TableFeatures.class);
60 public void remove(final InstanceIdentifier<TableFeatures> identifier, final TableFeatures removeDataObj,
61 final InstanceIdentifier<FlowCapableNode> nodeIdent) {
66 public void update(final InstanceIdentifier<TableFeatures> identifier, final TableFeatures original,
67 final TableFeatures update, final InstanceIdentifier<FlowCapableNode> nodeIdent) {
68 LOG.debug("Received the Table Update request [Tbl id, node Id, original, upd {} {} {} {}", identifier,
69 nodeIdent, original, update);
71 final TableFeatures originalTableFeatures = original;
72 TableFeatures updatedTableFeatures;
74 updatedTableFeatures = original;
76 updatedTableFeatures = update;
78 final UpdateTableInputBuilder builder = new UpdateTableInputBuilder();
80 builder.setNode(new NodeRef(nodeIdent.firstIdentifierOf(Node.class)));
82 // TODO: reconsider model - this particular field is not used in service
84 builder.setTableRef(new TableRef(identifier));
86 builder.setTransactionUri(new Uri(provider.getNewTransactionId()));
88 builder.setUpdatedTable(new UpdatedTableBuilder()
89 .setTableFeatures(Collections.singletonMap(updatedTableFeatures.key(), updatedTableFeatures))
92 builder.setOriginalTable(new OriginalTableBuilder()
93 .setTableFeatures(Collections.singletonMap(originalTableFeatures.key(), originalTableFeatures))
95 LOG.debug("Invoking SalTableService ");
97 if (this.provider.getSalTableService() != null) {
98 LOG.debug(" Handle to SalTableServices {}", this.provider.getSalTableService());
101 LoggingFutures.addErrorLogging(this.provider.getSalTableService().updateTable(builder.build()), LOG,
106 public Future<? extends RpcResult<?>> add(final InstanceIdentifier<TableFeatures> identifier,
107 final TableFeatures addDataObj, final InstanceIdentifier<FlowCapableNode> nodeIdent) {
108 return Futures.immediateFuture(null);
112 public void createStaleMarkEntity(InstanceIdentifier<TableFeatures> identifier, TableFeatures del,
113 InstanceIdentifier<FlowCapableNode> nodeIdent) {
118 public Future<? extends RpcResult<?>> removeWithResult(InstanceIdentifier<TableFeatures> identifier,
119 TableFeatures del, InstanceIdentifier<FlowCapableNode> nodeIdent) {