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.protocol.bgp.rib.impl;
10 import static java.util.Objects.requireNonNull;
12 import java.util.Collection;
13 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
14 import org.opendaylight.mdsal.dom.api.DOMDataTreeWriteTransaction;
15 import org.opendaylight.protocol.bgp.rib.impl.spi.RIBSupportContext;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.Attributes;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.update.attributes.MpReachNlri;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.update.attributes.MpUnreachNlri;
19 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
20 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
21 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
24 * A context for a single RIB table instance. It is always bound to a particular {@link AdjRibInWriter}.
27 * This class is NOT thread-safe.
29 // FIXME: need a better name once we local-rib and rib-out contexts
30 final class TableContext {
31 private final YangInstanceIdentifier tableId;
32 private final RIBSupportContext tableSupport;
34 TableContext(final RIBSupportContext tableSupport, final YangInstanceIdentifier tableId) {
35 this.tableSupport = requireNonNull(tableSupport);
36 this.tableId = requireNonNull(tableId);
39 YangInstanceIdentifier getTableId() {
44 void createEmptyTableStructure(final DOMDataTreeWriteTransaction tx) {
45 this.tableSupport.createEmptyTableStructure(tx, this.tableId);
48 void removeTable(final DOMDataTreeWriteTransaction tx) {
49 tx.delete(LogicalDatastoreType.OPERATIONAL, this.tableId);
52 Collection<NodeIdentifierWithPredicates> writeRoutes(final DOMDataTreeWriteTransaction tx, final MpReachNlri nlri,
53 final Attributes attributes) {
54 return this.tableSupport.writeRoutes(tx, this.tableId, nlri, attributes);
57 void removeRoutes(final DOMDataTreeWriteTransaction tx, final MpUnreachNlri nlri) {
58 this.tableSupport.deleteRoutes(tx, this.tableId, nlri);
61 YangInstanceIdentifier routesPath() {
62 return tableSupport.getRibSupport().routesPath(this.tableId);
65 YangInstanceIdentifier routePath(final PathArgument routeId) {
66 return tableSupport.getRibSupport().routePath(this.tableId, routeId);