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 com.google.common.util.concurrent.ListenableFuture;
12 import java.util.Collections;
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> {
32 private static final Logger LOG = LoggerFactory.getLogger(TableForwarder.class);
34 public TableForwarder(final ForwardingRulesManager manager, final DataBroker db,
35 final ListenerRegistrationHelper registrationHelper) {
36 super(manager, db, registrationHelper);
40 protected InstanceIdentifier<TableFeatures> getWildCardPath() {
41 return InstanceIdentifier.create(Nodes.class).child(Node.class).augmentation(FlowCapableNode.class)
42 .child(TableFeatures.class);
46 public void remove(final InstanceIdentifier<TableFeatures> identifier, final TableFeatures removeDataObj,
47 final InstanceIdentifier<FlowCapableNode> nodeIdent) {
52 public void update(final InstanceIdentifier<TableFeatures> identifier, final TableFeatures original,
53 final TableFeatures update, final InstanceIdentifier<FlowCapableNode> nodeIdent) {
54 LOG.debug("Received the Table Update request [Tbl id, node Id, original, upd {} {} {} {}", identifier,
55 nodeIdent, original, update);
57 final TableFeatures originalTableFeatures = original;
58 TableFeatures updatedTableFeatures;
60 updatedTableFeatures = original;
62 updatedTableFeatures = update;
64 final UpdateTableInputBuilder builder = new UpdateTableInputBuilder();
66 builder.setNode(new NodeRef(nodeIdent.firstIdentifierOf(Node.class)));
68 // TODO: reconsider model - this particular field is not used in service
70 builder.setTableRef(new TableRef(identifier));
72 builder.setTransactionUri(new Uri(provider.getNewTransactionId()));
74 builder.setUpdatedTable(new UpdatedTableBuilder()
75 .setTableFeatures(Collections.singletonMap(updatedTableFeatures.key(), updatedTableFeatures))
78 builder.setOriginalTable(new OriginalTableBuilder()
79 .setTableFeatures(Collections.singletonMap(originalTableFeatures.key(), originalTableFeatures))
81 LOG.debug("Invoking SalTableService ");
83 if (provider.getSalTableService() != null) {
84 LOG.debug(" Handle to SalTableServices {}", provider.getSalTableService());
87 LoggingFutures.addErrorLogging(provider.getSalTableService().updateTable(builder.build()), LOG,
92 public ListenableFuture<RpcResult<?>> add(final InstanceIdentifier<TableFeatures> identifier,
93 final TableFeatures addDataObj, final InstanceIdentifier<FlowCapableNode> nodeIdent) {
94 return Futures.immediateFuture(null);
98 public void createStaleMarkEntity(final InstanceIdentifier<TableFeatures> identifier, final TableFeatures del,
99 final InstanceIdentifier<FlowCapableNode> nodeIdent) {
104 public ListenableFuture<RpcResult<?>> removeWithResult(final InstanceIdentifier<TableFeatures> identifier,
105 final TableFeatures del, final InstanceIdentifier<FlowCapableNode> nodeIdent) {
106 return Futures.immediateFuture(null);