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 com.google.common.base.Preconditions;
13 import javax.annotation.concurrent.NotThreadSafe;
14 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
15 import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction;
16 import org.opendaylight.protocol.bgp.rib.impl.spi.RIBSupportContext;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.path.attributes.Attributes;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev130919.update.attributes.MpReachNlri;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev130919.update.attributes.MpUnreachNlri;
20 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
23 * A context for a single RIB table instance. It is always bound to a particular {@link AdjRibInWriter}.
25 * FIXME: need a better name once we local-rib and rib-out contexts
28 final class TableContext {
29 private final YangInstanceIdentifier tableId;
30 private final RIBSupportContext tableSupport;
32 TableContext(final RIBSupportContext tableSupport, final YangInstanceIdentifier tableId) {
33 this.tableSupport = requireNonNull(tableSupport);
34 this.tableId = requireNonNull(tableId);
37 YangInstanceIdentifier getTableId() {
42 void createEmptyTableStructure(final DOMDataWriteTransaction tx) {
43 this.tableSupport.createEmptyTableStructure(tx, this.tableId);
46 void removeTable(final DOMDataWriteTransaction tx) {
47 tx.delete(LogicalDatastoreType.OPERATIONAL, this.tableId);
50 void writeRoutes(final DOMDataWriteTransaction tx, final MpReachNlri nlri, final Attributes attributes) {
51 this.tableSupport.writeRoutes(tx, this.tableId, nlri, attributes);
54 void removeRoutes(final DOMDataWriteTransaction tx, final MpUnreachNlri nlri) {
55 this.tableSupport.deleteRoutes(tx, this.tableId, nlri);