BGPCEP-754: Fix NPE and rework
[bgpcep.git] / bgp / rib-spi / src / main / java / org / opendaylight / protocol / bgp / rib / spi / BGPPeerTracker.java
1 /*
2  * Copyright (c) 2018 AT&T Intellectual Property. 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.List;
12 import java.util.Map;
13 import javax.annotation.Nonnull;
14 import javax.annotation.Nullable;
15 import org.opendaylight.protocol.concepts.AbstractRegistration;
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.PeerRole;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.rib.TablesKey;
19
20 /**
21  * Tracks Peers under RIB.
22  */
23 public interface BGPPeerTracker {
24     /**
25      * Register Peer.
26      *
27      * @param peer Peer
28      * @return registration tickets
29      */
30     AbstractRegistration registerPeer(@Nonnull Peer peer);
31
32     /**
33      * Returns Peer
34      *
35      * @param peerId peer ID
36      * @return Peer
37      */
38     @Nullable
39     Peer getPeer(@Nonnull PeerId peerId);
40
41     /**
42      * Returns map of PeerId per PeerRole.
43      * Role with none peerId will be filtered.
44      *
45      * @return Returns map of Peer group by PeerRole
46      */
47     @Nonnull
48     List<Peer> getPeers();
49 }