Get rid of JSR305 annotations
[bgpcep.git] / bgp / rib-spi / src / main / java / org / opendaylight / protocol / bgp / rib / spi / BGPSession.java
1 /*
2  * Copyright (c) 2013 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 package org.opendaylight.protocol.bgp.rib.spi;
9
10 import io.netty.channel.ChannelInboundHandler;
11 import io.netty.util.concurrent.ScheduledFuture;
12 import java.util.List;
13 import java.util.Set;
14 import java.util.concurrent.TimeUnit;
15 import org.eclipse.jdt.annotation.NonNull;
16 import org.opendaylight.protocol.bgp.parser.GracefulRestartUtil;
17 import org.opendaylight.protocol.bgp.parser.spi.PeerConstraint;
18 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber;
19 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.BgpTableType;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.GracefulRestartCapability;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.LlGracefulRestartCapability;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.add.path.capability.AddressFamilies;
24
25 /**
26  * BGP Session represents the finite state machine in BGP, including timers and its purpose is to create a BGP
27  * connection between BGP speakers. Session is automatically started, when TCP connection is created,
28  * but can be stopped manually via close method of the {@link java.io.Closeable} interface.
29  * If the session is up, it has to redirect messages to/from user. Handles also malformed messages and unknown requests.
30  */
31 public interface BGPSession extends AutoCloseable, ChannelInboundHandler {
32     /**
33      * Return the list of tables which the peer has advertised to support.
34      *
35      * @return Set of tables which it supports.
36      */
37     @NonNull Set<BgpTableType> getAdvertisedTableTypes();
38
39     /**
40      * Return the BGP router ID advertised by the peer.
41      *
42      * @return Peer's BGP Router ID.
43      */
44     @NonNull Ipv4Address getBgpId();
45
46     /**
47      * Return the AS number which the peer advertises.
48      *
49      * @return Peer's AS Number
50      */
51     @NonNull AsNumber getAsNumber();
52
53     /**
54      * Return a list with Add Path tables supported advertised and corresponding SendReceive mode.
55      *
56      * @return AddPathTables supported
57      */
58     @NonNull List<AddressFamilies> getAdvertisedAddPathTableTypes();
59
60     /**
61      * Return advertised graceful capability containing the list of tables which the peer has advertised to support,
62      * restart time and restarting flags.
63      *
64      * @return Advertised graceful restart capability.
65      */
66     default @NonNull GracefulRestartCapability getAdvertisedGracefulRestartCapability() {
67         return GracefulRestartUtil.EMPTY_GR_CAPABILITY;
68     }
69
70     /**
71      * Return advertised long-lived graceful capability containing the list of tables with stale time which
72      * the peer has advertised to support.
73      *
74      * @return Advertised long-lived graceful restart capability.
75      */
76     default @NonNull LlGracefulRestartCapability getAdvertisedLlGracefulRestartCapability() {
77         return GracefulRestartUtil.EMPTY_LLGR_CAPABILITY;
78     }
79
80     /**
81      * Close peer session without sending Notification message.
82      */
83     void closeWithoutMessage();
84
85     /**
86      * Add peer constraint to session pipeline decoder.
87      */
88     <T extends PeerConstraint> void addDecoderConstraint(Class<T> constraintClass, T constraint);
89
90     /**
91      * Schedule a task to be executed in the context of the session handling thread.
92      *
93      * @param command the task to execute
94      * @param delay the time from now to delay execution
95      * @param unit the time unit of the delay parameter
96      * @return Future representing the scheduled task.
97      */
98     ScheduledFuture<?> schedule(Runnable command, long delay, TimeUnit unit);
99 }