Provide Add Path support for all AFI/SAFI
[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 javax.annotation.Nonnull;
13 import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
14 import org.opendaylight.protocol.bgp.rib.spi.entry.RouteEntryDependenciesContainer;
15 import org.opendaylight.protocol.bgp.rib.spi.entry.RouteEntryInfo;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.Route;
17
18 /**
19  * A single route entry inside a route table. Maintains the attributes of
20  * from all contributing peers. The information is stored in arrays with a
21  * shared map of offsets for peers to allow lookups. This is needed to
22  * maintain low memory overhead in face of large number of routes and peers,
23  * where individual object overhead becomes the dominating factor.
24  */
25 public interface RouteEntry {
26     /**
27      * Remove route.
28      *
29      * @param routerId     router ID in unsigned integer format from an Ipv4Address
30      * @param remotePathId remote path Id received
31      * @return return true if it was the last route on entry
32      */
33     boolean removeRoute(@Nonnull UnsignedInteger routerId, long remotePathId);
34
35     /**
36      * Indicates whether best has changed.
37      *
38      * @param localAs The local autonomous system number
39      * @return return true if it has changed
40      */
41     boolean selectBest(long localAs);
42
43     /**
44      * Add Route.
45      *
46      * @param routerId     router ID in unsigned integer format from an Ipv4Address
47      * @param remotePathId remote path Id received
48      * @param route        route Data change
49      * @return returns the offset
50      */
51     int addRoute(@Nonnull UnsignedInteger routerId, long remotePathId, @Nonnull Route route);
52
53     /**
54      * Update LocRibOut and AdjRibsOut by removing stale best path and writing new best.
55      *
56      * @param entryDependencies entry Dependencies container
57      * @param routeKey          route key
58      * @param tx                DOM transaction
59      */
60     void updateBestPaths(
61             @Nonnull RouteEntryDependenciesContainer entryDependencies,
62             @Nonnull String routeKey,
63             @Nonnull WriteTransaction tx);
64
65     /**
66      * Initialize LocRibOut and AdjRibsOut for new peers with already present best paths.
67      *
68      * @param entryDependencies Route Entry Dependencies wrapper
69      * @param entryInfo         Route Entry Info wrapper
70      * @param tx                transaction
71      */
72     void initializeBestPaths(
73             @Nonnull RouteEntryDependenciesContainer entryDependencies,
74             @Nonnull RouteEntryInfo entryInfo,
75             @Nonnull WriteTransaction tx);
76 }