7535b7407a5d40dc81296dcf634b4cc055ee9ed3
[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.ExportPolicyPeerTracker;
14 import org.opendaylight.protocol.bgp.rib.spi.PeerExportGroup;
15 import org.opendaylight.protocol.bgp.rib.spi.RIBSupport;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.PeerId;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.rib.TablesKey;
18 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
19 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
20 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
21 import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
22 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
23
24 /**
25  * A single route entry inside a route table. Maintains the attributes of
26  * from all contributing peers. The information is stored in arrays with a
27  * shared map of offsets for peers to allow lookups. This is needed to
28  * maintain low memory overhead in face of large number of routes and peers,
29  * where individual object overhead becomes the dominating factor.
30  */
31 public interface RouteEntry {
32     /**
33      * Remove route.
34      *
35      * @param routerId     router ID in unsigned integer format from an Ipv4Address
36      * @param remotePathId remote path Id received
37      * @return return true if it was the last route on entry
38      */
39     boolean removeRoute(UnsignedInteger routerId, Long remotePathId);
40
41     /**
42      * Create value.
43      *
44      * @param routeId router ID pathArgument
45      * @param path    BestPath
46      * @return MapEntryNode
47      */
48     @Deprecated
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      * Add Route.
61      *
62      * @param routerId     router ID in unsigned integer format from an Ipv4Address
63      * @param remotePathId remote path Id received
64      * @param attrII       route Attributes Identifier
65      * @param data         route Data change
66      * @return returns the offset
67      */
68     int addRoute(UnsignedInteger routerId, Long remotePathId, NodeIdentifier attrII, NormalizedNode<?, ?> data);
69
70     /**
71      * Update LocRibOut and AdjRibsOut by removing stale best path and writing new best.
72      *
73      * @param localTK      local Table Key
74      * @param peerPT       peer export policy
75      * @param locRibTarget YII local rib
76      * @param ribSupport   rib support
77      * @param tx           DOM transaction
78      * @param routeIdPA    router ID pathArgument
79      */
80     void updateRoute(TablesKey localTK, ExportPolicyPeerTracker peerPT, YangInstanceIdentifier locRibTarget,
81             RIBSupport ribSupport, DOMDataWriteTransaction tx, PathArgument routeIdPA);
82
83     /**
84      * Write Route on LocRibOut and AdjRibsOut.
85      *
86      * @param peerId     destination peerId
87      * @param routeId    router ID path Argument
88      * @param rootPath   YII root path
89      * @param peerGroup  PeerExportGroup
90      * @param localTK    local Table Key
91      * @param ribSupport rib support
92      * @param tx         DOM transaction
93      */
94     void writeRoute(PeerId peerId, PathArgument routeId, YangInstanceIdentifier rootPath, PeerExportGroup peerGroup,
95             TablesKey localTK, ExportPolicyPeerTracker peerPT, RIBSupport ribSupport, DOMDataWriteTransaction tx);
96 }