BUG-4827: Replace extractPathId method from RibSupport
[bgpcep.git] / bgp / path-selection-mode / src / main / java / org / opendaylight / protocol / bgp / mode / api / RouteEntry.java
1 /*
2  * Copyright (c) 2016 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
9 package org.opendaylight.protocol.bgp.mode.api;
10
11 import com.google.common.primitives.UnsignedInteger;
12 import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction;
13 import org.opendaylight.protocol.bgp.rib.spi.CacheDisconnectedPeers;
14 import org.opendaylight.protocol.bgp.rib.spi.ExportPolicyPeerTracker;
15 import org.opendaylight.protocol.bgp.rib.spi.PeerExportGroup;
16 import org.opendaylight.protocol.bgp.rib.spi.RIBSupport;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.PeerId;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.rib.TablesKey;
19 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
20 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
21 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
22 import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
23 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
24
25 /**
26  * A single route entry inside a route table. Maintains the attributes of
27  * from all contributing peers. The information is stored in arrays with a
28  * shared map of offsets for peers to allow lookups. This is needed to
29  * maintain low memory overhead in face of large number of routes and peers,
30  * where individual object overhead becomes the dominating factor.
31  */
32 public interface RouteEntry {
33     /**
34      * Remove route
35      *
36      * @param routerId router ID in unsigned integer format from an Ipv4Address
37      * @param remotePathId remote path Id received
38      * @return return true if it was the last route on entry
39      */
40     boolean removeRoute(UnsignedInteger routerId, Long remotePathId);
41
42     /**
43      * Create value
44      *
45      * @param routeId router ID pathArgument
46      * @param path BestPath
47      * @return MapEntryNode
48      */
49     MapEntryNode createValue(PathArgument routeId, BestPath path);
50
51     /**
52      * Indicates whether best has changed
53      *
54      * @param localAs The local autonomous system number
55      * @return return true if it has changed
56      */
57     boolean selectBest(long localAs);
58
59     /**
60      * @param routerId router ID in unsigned integer format from an Ipv4Address
61      * @param remotePathId remote path Id received
62      * @param attrII route Attributes Identifier
63      * @param data route Data change
64      * @return returns the offset
65      */
66     int addRoute(UnsignedInteger routerId, Long remotePathId, NodeIdentifier attrII, NormalizedNode<?, ?> data);
67
68     /**
69      * Update LocRibOut and AdjRibsOut by removing stale best path and writing new best
70      *
71      * @param localTK local Table Key
72      * @param peerPT peer export policy
73      * @param locRibTarget YII local rib
74      * @param ribSupport rib support
75      * @param discPeers list of disconnected peers
76      * @param tx DOM transaction
77      * @param routeIdPA router ID pathArgument
78      */
79     void updateRoute(TablesKey localTK, ExportPolicyPeerTracker peerPT, YangInstanceIdentifier locRibTarget, RIBSupport ribSupport,
80         CacheDisconnectedPeers discPeers, DOMDataWriteTransaction tx, PathArgument routeIdPA);
81
82     /**
83      * Write Route on LocRibOut and AdjRibsOut
84      *  @param peerId destination peerId
85      * @param routeId router ID path Argument
86      * @param rootPath YII root path
87      * @param peerGroup PeerExportGroup
88      * @param localTK local Table Key
89      * @param ribSupport rib support
90      * @param tx DOM transaction
91      */
92     void writeRoute(PeerId peerId, PathArgument routeId, YangInstanceIdentifier rootPath, PeerExportGroup peerGroup, TablesKey localTK,
93         ExportPolicyPeerTracker peerPT, RIBSupport ribSupport, CacheDisconnectedPeers discPeers, DOMDataWriteTransaction tx);
94 }