2 * Copyright (c) 2016 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.frsync.impl;
11 import java.util.Collections;
12 import java.util.concurrent.Future;
14 import org.opendaylight.openflowplugin.applications.frsync.ForwardingRulesUpdateCommitter;
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.inventory.rev130819.NodeRef;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.SalTableService;
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.UpdateTableOutput;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.table.update.OriginalTableBuilder;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.table.update.UpdatedTableBuilder;
25 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableRef;
26 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures;
27 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
28 import org.opendaylight.yangtools.yang.common.RpcResult;
29 import org.slf4j.Logger;
30 import org.slf4j.LoggerFactory;
33 * Implements {@link ForwardingRulesUpdateCommitter} methods for processing update of {@link TableFeatures}.
35 public class TableForwarder implements ForwardingRulesUpdateCommitter<TableFeatures, UpdateTableOutput> {
37 private static final Logger LOG = LoggerFactory.getLogger(TableForwarder.class);
38 private final SalTableService salTableService;
40 public TableForwarder(SalTableService salTableService) {
41 this.salTableService = salTableService;
45 public Future<RpcResult<UpdateTableOutput>> update(final InstanceIdentifier<TableFeatures> identifier,
46 final TableFeatures original, final TableFeatures update,
47 final InstanceIdentifier<FlowCapableNode> nodeIdent) {
48 LOG.debug("Forwarding Table Update request [Tbl id, node Id {} {}",
49 identifier, nodeIdent);
51 final UpdateTableInputBuilder builder = new UpdateTableInputBuilder();
53 builder.setNode(new NodeRef(nodeIdent.firstIdentifierOf(Node.class)));
55 final InstanceIdentifier<Table> iiToTable = nodeIdent.child(Table.class,
56 new TableKey(identifier.firstKeyOf(TableFeatures.class).getTableId()));
57 builder.setTableRef(new TableRef(iiToTable));
59 builder.setUpdatedTable(new UpdatedTableBuilder().setTableFeatures(
60 Collections.singletonList(update)).build());
62 builder.setOriginalTable(new OriginalTableBuilder().setTableFeatures(
63 Collections.singletonList(original)).build());
64 LOG.debug("Invoking SalTableService {} ", nodeIdent);
66 return salTableService.updateTable(builder.build());