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 class SimpleSessionListener implements BGPSessionListener {
25 private final List<Notification> listMsg = Lists.newArrayList();
27 public boolean up = false;
29 private static final Logger LOG = LoggerFactory.getLogger(SimpleSessionListener.class);
31 public boolean down = false;
33 private BGPSession session;
35 public SimpleSessionListener() {
38 public List<Notification> getListMsg() {
43 public void onMessage(final BGPSession session, final Notification message) {
44 this.listMsg.add(message);
45 LOG.debug("Message received: {}", message);
49 public void onSessionUp(final BGPSession session) {
50 LOG.debug("Session Up");
51 this.session = session;
56 public void onSessionDown(final BGPSession session, final Exception e) {
57 LOG.debug("Session Down", e);
62 public void onSessionTerminated(final BGPSession session, final BGPTerminationReason cause) {
63 LOG.debug("Session terminated. Cause : {}", cause.toString());
67 public void releaseConnection() {
68 LOG.debug("Releasing connection");
69 if (this.session != null) {
72 } catch (final Exception e) {
73 LOG.warn("Error closing session", e);
80 public boolean isSessionActive() {
85 public void markUptodate(final TablesKey tablesKey) {
86 LOG.debug("Table marked as up-to-date {}", tablesKey);