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