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.strategy;
11 import java.util.Collections;
12 import java.util.concurrent.Future;
13 import org.opendaylight.openflowplugin.applications.frsync.ForwardingRulesUpdateCommitter;
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.inventory.rev130819.tables.TableKey;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.SalTableService;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.UpdateTableInputBuilder;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.UpdateTableOutput;
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;
32 * Implements {@link ForwardingRulesUpdateCommitter} methods for processing update of {@link TableFeatures}.
34 public class TableForwarder implements ForwardingRulesUpdateCommitter<TableFeatures, UpdateTableOutput> {
36 private static final Logger LOG = LoggerFactory.getLogger(TableForwarder.class);
37 private final SalTableService salTableService;
39 public TableForwarder(SalTableService salTableService) {
40 this.salTableService = salTableService;
44 public Future<RpcResult<UpdateTableOutput>> update(final InstanceIdentifier<TableFeatures> identifier,
45 final TableFeatures original, final TableFeatures update,
46 final InstanceIdentifier<FlowCapableNode> nodeIdent) {
47 LOG.debug("Forwarding Table Update request [Tbl id, node Id {} {}",
48 identifier, nodeIdent);
50 final UpdateTableInputBuilder builder = new UpdateTableInputBuilder();
52 builder.setNode(new NodeRef(nodeIdent.firstIdentifierOf(Node.class)));
54 final InstanceIdentifier<Table> iiToTable = nodeIdent.child(Table.class,
55 new TableKey(identifier.firstKeyOf(TableFeatures.class).getTableId()));
56 builder.setTableRef(new TableRef(iiToTable));
58 builder.setUpdatedTable(new UpdatedTableBuilder().setTableFeatures(
59 Collections.singletonList(update)).build());
61 builder.setOriginalTable(new OriginalTableBuilder().setTableFeatures(
62 Collections.singletonList(original)).build());
63 LOG.debug("Invoking SalTableService {} ", nodeIdent);
65 return salTableService.updateTable(builder.build());