Move releaseConnection from ReusableBGPPeer to BGPSessionListener
[bgpcep.git] / bgp / rib-spi / src / main / java / org / opendaylight / protocol / bgp / rib / spi / BGPSessionListener.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 java.util.EventListener;
11 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.rib.TablesKey;
12 import org.opendaylight.yangtools.yang.binding.Notification;
13
14 /**
15  * Listener that receives session informations from the session.
16  */
17 public interface BGPSessionListener extends EventListener {
18
19     /**
20      * Returns state of BGP session associated with this listener.
21      *
22      * @return false if session associated with this listener is null, true if its non-null
23      */
24     boolean isSessionActive();
25
26     /**
27      * Marks synchronization finished for given Table key
28      *
29      * @param tablesKey of the table where synchronization finished
30      */
31     void markUptodate(final TablesKey tablesKey);
32
33     /**
34      * Fired when the session was established successfully.
35      *
36      * @param session Peer address families which we accepted
37      */
38     void onSessionUp(BGPSession session);
39     /**
40      * Fired when the session went down because of an IO error. Implementation should take care of closing underlying
41      * session.
42      *
43      * @param session that went down
44      * @param e Exception that was thrown as the cause of session being down
45      */
46
47     void onSessionDown(BGPSession session, Exception e);
48     /**
49      * Fired when the session is terminated locally. The session has already been closed and transitioned to IDLE state.
50      * Any outstanding queued messages were not sent. The user should not attempt to make any use of the session.
51      *
52      * @param reason the cause why the session went down
53      */
54     void onSessionTerminated(BGPSession session, BGPTerminationReason reason);
55
56     /**
57      * Fired when a normal protocol message is received.
58      *
59      * @param notification Protocol message
60      */
61     void onMessage(BGPSession session, Notification notification);
62
63     void releaseConnection();
64 }