00c9152aa6ddc6f583ee4019fa9348e6ad952c56
[bgpcep.git] / bgp / rib-impl / src / main / java / org / opendaylight / protocol / bgp / rib / impl / spi / RIBSupportContext.java
1 /*
2  * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.protocol.bgp.rib.impl.spi;
9
10 import java.util.Collection;
11 import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction;
12 import org.opendaylight.protocol.bgp.rib.spi.RIBSupport;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.Attributes;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.update.attributes.MpReachNlri;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.update.attributes.MpUnreachNlri;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.Route;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.Tables;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.tables.Routes;
19 import org.opendaylight.yangtools.yang.binding.ChildOf;
20 import org.opendaylight.yangtools.yang.binding.ChoiceIn;
21 import org.opendaylight.yangtools.yang.binding.DataObject;
22 import org.opendaylight.yangtools.yang.binding.Identifiable;
23 import org.opendaylight.yangtools.yang.binding.Identifier;
24 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
25 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
26
27 /**
28  *
29  * {@link RIBSupport} wrapper which provides additional functionality
30  * such as logic to update / remove routes using Binding DTOs
31  * for BGP messages.
32  *
33  */
34 public abstract class RIBSupportContext {
35
36     /**
37      *
38      * Create specified Rib table structure using supplied transaction.
39      *
40      * @param tx Transaction to to be used
41      * @param tableId Instance Identifier of table to be cleared.
42      */
43     public abstract void createEmptyTableStructure(DOMDataWriteTransaction tx, YangInstanceIdentifier tableId);
44
45     /**
46      * Removes supplied routes from RIB table using supplied transaction.
47      *
48      * @param tx Transaction to be used
49      * @param tableId Instance Identifier of table to be updated
50      * @param nlri UnreachNlri which contains routes to be removed.
51      */
52     public abstract void deleteRoutes(DOMDataWriteTransaction tx, YangInstanceIdentifier tableId, MpUnreachNlri nlri);
53
54     /**
55      *
56      * Writes supplied routes and attributes to RIB table using supplied transaction.
57      *
58      *
59      * @param tx Transaction to be used
60      * @param tableId Instance Identifier of table to be updated
61      * @param nlri ReachNlri which contains routes to be written.
62      * @param attributes Attributes which should be written.
63      * @return Set of processed route key identifiers
64      */
65     public abstract Collection<NodeIdentifierWithPredicates> writeRoutes(DOMDataWriteTransaction tx,
66                                                                          YangInstanceIdentifier tableId,
67                                                                          MpReachNlri nlri,
68                                                                          Attributes attributes);
69
70     /**
71      * Returns backing RIB support.
72      *
73      * @return RIBSupport
74      */
75     public abstract <C extends Routes & DataObject & ChoiceIn<Tables>, S extends ChildOf<? super C>,
76         R extends Route & ChildOf<? super S> & Identifiable<I>, I extends Identifier<R>>
77             RIBSupport<C, S, R, I> getRibSupport();
78 }