BUG-2109 : clear BGP session after it was already initialized
[bgpcep.git] / bgp / testtool / src / test / java / org / opendaylight / protocol / bgp / testtool / SpeakerSessionListener.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.testtool;
9
10 import org.opendaylight.protocol.bgp.rib.spi.BGPSession;
11 import org.opendaylight.protocol.bgp.rib.spi.BGPSessionListener;
12 import org.opendaylight.protocol.bgp.rib.spi.BGPTerminationReason;
13 import org.opendaylight.yangtools.yang.binding.Notification;
14 import org.slf4j.Logger;
15 import org.slf4j.LoggerFactory;
16
17 public class SpeakerSessionListener implements BGPSessionListener {
18     private static final Logger LOG = LoggerFactory.getLogger(SpeakerSessionListener.class);
19
20     @Override
21     public void onSessionUp(final BGPSession session) {
22         LOG.info("Server: Session is up.");
23     }
24
25     @Override
26     public void onSessionTerminated(final BGPSession session, final BGPTerminationReason cause) {
27         LOG.info("Server: Session terminated: {}", cause);
28     }
29
30     @Override
31     public void onSessionDown(final BGPSession session, final Exception e) {
32         LOG.info("Server: Session down.");
33         session.close();
34         // this.d.stop();
35     }
36
37     @Override
38     public void onMessage(final BGPSession session, final Notification message) {
39         LOG.info("Server: Message received: {}", message);
40         // this.d.stop();
41     }
42
43     @Override
44     public boolean isSessionActive() {
45         return true;
46     }
47 }