BUG-2383 : RIBSupport exposes Route classes rather than QNAME
[bgpcep.git] / bgp / rib-spi / src / main / java / org / opendaylight / protocol / bgp / rib / spi / RIBSupport.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.spi;
9
10 import com.google.common.collect.ImmutableCollection;
11 import java.util.Collection;
12 import javax.annotation.Nonnull;
13 import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.Route;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.rib.tables.Routes;
16 import org.opendaylight.yangtools.yang.binding.DataObject;
17 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
18 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
19 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
20 import org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode;
21 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
22 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateNode;
23
24 /**
25  * Interface implemented for AFI/SAFI-specific RIB extensions. The extensions need
26  * to register an implementation of this class and the RIB core then calls into it
27  * to inquire about details specific to that particular model.
28  */
29 public interface RIBSupport {
30     /**
31      * Return the table-type-specific empty routes container, as augmented into the
32      * bgp-rib model under /rib/tables/routes choice node. This needs to include all
33      * the skeleton nodes under which the individual routes will be stored.
34      *
35      * @return Protocol-specific case in the routes choice, may not be null.
36      */
37     @Nonnull ChoiceNode emptyRoutes();
38
39     /**
40      * Return the localized identifier of the attributes route member, as expanded
41      * from the route grouping in the specific augmentation of the base routes choice.
42      *
43      * @return The attributes identifier, may not be null.
44      */
45     @Nonnull NodeIdentifier routeAttributesIdentifier();
46
47     /**
48      * Return class object of the Routes Case statement.
49      *
50      * @return Class
51      */
52     @Nonnull Class<? extends Routes> routesCaseClass();
53
54     /**
55      * Return class object of the Routes Container statement.
56      *
57      * @return Class
58      */
59     @Nonnull Class<? extends DataObject> routesContainerClass();
60
61     /**
62      * Return class object of the Routes List statement.
63      *
64      * @return Class
65      */
66     @Nonnull Class<? extends Route> routesListClass();
67
68     @Nonnull ImmutableCollection<Class<? extends DataObject>> cacheableAttributeObjects();
69     @Nonnull ImmutableCollection<Class<? extends DataObject>> cacheableNlriObjects();
70
71     /**
72      * Given the NLRI as ContainerNode, this method should extract withdrawn routes
73      * from the DOM model and delete them from RIBs.
74      *
75      * @param tx DOMDataWriteTransaction
76      * @param tablePath YangInstanceIdentifier
77      * @param nlri ContainerNode DOM representation of NLRI in Update message
78      */
79     void deleteRoutes(@Nonnull DOMDataWriteTransaction tx, @Nonnull YangInstanceIdentifier tablePath, @Nonnull ContainerNode nlri);
80
81     /**
82      * Given the NLRI as ContainerNode, this method should extract advertised routes
83      * from the DOM model and put them into RIBs.
84      *
85      * @param tx DOMDataWriteTransaction
86      * @param tablePath YangInstanceIdentifier
87      * @param nlri ContainerNode DOM representation of NLRI in Update message
88      * @param attributes ContainerNode
89      */
90     void putRoutes(@Nonnull DOMDataWriteTransaction tx, @Nonnull YangInstanceIdentifier tablePath, @Nonnull ContainerNode nlri, @Nonnull ContainerNode attributes);
91
92     /**
93      * Returns routes that were modified within this RIB support instance.
94      *
95      * @param routes DataTreeCandidateNode
96      * @return collection of modified nodes or empty collection if no node was modified
97      */
98     @Nonnull Collection<DataTreeCandidateNode> changedRoutes(@Nonnull DataTreeCandidateNode routes);
99
100     /**
101      * Constructs an instance identifier path to routeId.
102      *
103      * @param routesPath YangInstanceIdentifier base path
104      * @param routeId PathArgument leaf path
105      * @return YangInstanceIdentifier with routesPath + specific RIB support routes path + routeId
106      */
107     @Nonnull YangInstanceIdentifier routePath(@Nonnull YangInstanceIdentifier routesPath, @Nonnull PathArgument routeId);
108 }