BUG-6747: Race condition on peer connection
[bgpcep.git] / bgp / rib-spi / src / main / java / org / opendaylight / protocol / bgp / rib / spi / ExportPolicyPeerTracker.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.rib.spi;
10
11 import java.util.Optional;
12 import javax.annotation.Nonnull;
13 import javax.annotation.Nullable;
14 import org.opendaylight.protocol.concepts.AbstractRegistration;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev130919.SendReceive;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.PeerId;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.PeerRole;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.SimpleRoutingPolicy;
19 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
20 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateNode;
21
22 /**
23  * Tracks peers for adj-rib-out writeout.
24  */
25 public interface ExportPolicyPeerTracker {
26     /**
27      * Update set with supported tables per peer
28      * @param peerId which receveid the change
29      * @param node data change
30      */
31     @Deprecated
32     default void onTablesChanged(PeerId peerId, DataTreeCandidateNode node) {}
33
34     /**
35      * Register Peer
36      * @param peerId Peer Id
37      * @param sendReceive send receive add ath configuration of the peer
38      * @param peerPath Yii of the peer
39      * @param peerRole Role of the peer
40      * @param simpleRoutingPolicy
41      */
42     AbstractRegistration registerPeer(@Nonnull PeerId peerId, @Nullable SendReceive sendReceive, @Nonnull YangInstanceIdentifier peerPath, @Nonnull PeerRole peerRole,
43         @Nonnull Optional<SimpleRoutingPolicy> simpleRoutingPolicy);
44
45     /**
46      * returns PeerExportGroup per role
47      * @param role of desired PeerExportGroup
48      * @return PeerExportGroup
49      */
50     PeerExportGroup getPeerGroup(@Nonnull PeerRole role);
51
52     /**
53      * check whether the peer supports the table
54      * @param peerId of peer
55      * @return true if peer supports table
56      */
57     boolean isTableSupported(@Nonnull PeerId peerId);
58
59     /**
60      * @param peerId of peer
61      * @return Role of peer
62      */
63     PeerRole getRole(@Nonnull YangInstanceIdentifier peerId);
64
65     /**
66      * Check whether Peer supports Add Path
67      * @param peerId
68      * @return true if add-path is supported
69      */
70     boolean isAddPathSupportedByPeer(@Nonnull PeerId peerId);
71
72     /**
73      * Invoked whenever a peer role changes.
74      *
75      * @param peerPath Peer's path
76      * @param role Peer's new role, null indicates the peer has disappeared.
77      */
78     @Deprecated
79     default void peerRoleChanged(@Nonnull YangInstanceIdentifier peerPath,  @Nullable PeerRole role) {
80     }
81 }