2 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
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
8 package org.opendaylight.protocol.bgp.rib.impl;
10 import com.google.common.collect.Lists;
11 import java.util.List;
12 import org.opendaylight.protocol.bgp.rib.spi.BGPSession;
13 import org.opendaylight.protocol.bgp.rib.spi.BGPSessionListener;
14 import org.opendaylight.protocol.bgp.rib.spi.BGPTerminationReason;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.rib.TablesKey;
16 import org.opendaylight.yangtools.yang.binding.Notification;
17 import org.slf4j.Logger;
18 import org.slf4j.LoggerFactory;
21 * Listener for the client.
23 public final class SimpleSessionListener implements BGPSessionListener {
25 private static final Logger LOG = LoggerFactory.getLogger(SimpleSessionListener.class);
26 private final List<Notification> listMsg = Lists.newArrayList();
27 private BGPSession session;
29 SimpleSessionListener() {
32 List<Notification> getListMsg() {
37 public boolean isSessionActive() {
38 return ((BGPSessionImpl) this.session).isWritable();
42 public void markUptodate(final TablesKey tablesKey) {
43 LOG.debug("Table marked as up-to-date {}", tablesKey);
47 public void onSessionUp(final BGPSession session) {
48 LOG.debug("Session Up");
49 this.session = session;
53 public void onSessionDown(final BGPSession session, final Exception e) {
54 LOG.debug("Session Down", e);
58 public void onSessionTerminated(final BGPSession session, final BGPTerminationReason cause) {
59 LOG.debug("Session terminated. Cause : {}", cause.toString());
63 public void onMessage(final BGPSession session, final Notification message) {
64 this.listMsg.add(message);
65 LOG.debug("Message received: {}", message);
69 public void releaseConnection() {
70 LOG.debug("Releasing connection");
71 if (this.session != null) {
74 } catch (final Exception e) {
75 LOG.warn("Error closing session", e);
80 BGPSessionImpl.State getState() {
81 return ((BGPSessionImpl) this.session).getState();