BUG-58: refactor to take advantage of netty
[bgpcep.git] / bgp / rib-impl / src / main / java / org / opendaylight / protocol / bgp / rib / impl / BGPPeer.java
index be062425a9f8cbcd974c4701b120b19cd57e508a..a56a2c05cf7a96d9c1e0393a8eba3ddfe7696dc5 100644 (file)
@@ -10,10 +10,10 @@ package org.opendaylight.protocol.bgp.rib.impl;
 import java.util.Set;
 
 import org.opendaylight.protocol.bgp.concepts.BGPTableType;
-import org.opendaylight.protocol.bgp.parser.BGPError;
 import org.opendaylight.protocol.bgp.parser.BGPMessage;
 import org.opendaylight.protocol.bgp.parser.BGPSession;
 import org.opendaylight.protocol.bgp.parser.BGPSessionListener;
+import org.opendaylight.protocol.bgp.parser.BGPTerminationReason;
 import org.opendaylight.protocol.bgp.parser.BGPUpdateMessage;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -26,7 +26,7 @@ import com.google.common.base.Preconditions;
  * Class representing a peer. We have a single instance for each peer, which provides translation from BGP events into
  * RIB actions.
  */
-public final class BGPPeer extends BGPSessionListener {
+public final class BGPPeer implements BGPSessionListener {
        private static final Logger logger = LoggerFactory.getLogger(BGPPeer.class);
        private Set<BGPTableType> tables;
        private final String name;
@@ -38,29 +38,31 @@ public final class BGPPeer extends BGPSessionListener {
        }
 
        @Override
-       public void onMessage(final BGPMessage message) {
+       public void onMessage(final BGPSession session, final BGPMessage message) {
                if (message instanceof BGPUpdateMessage) {
                        final BGPUpdateMessage m = (BGPUpdateMessage) message;
                        this.rib.updateTables(this, m.getAddedObjects(), m.getRemovedObjects());
-               } else
+               } else {
                        logger.info("Ignoring unhandled message class " + message.getClass());
+               }
        }
 
        @Override
-       public void onSessionUp(final Set<BGPTableType> remoteParams) {
-               logger.info("Session with peer {} went up with tables: {}", this.name, remoteParams);
+       public void onSessionUp(final BGPSession session) {
+               logger.info("Session with peer {} went up with tables: {}", this.name, session.getAdvertisedTableTypes());
        }
 
        @Override
        public void onSessionDown(final BGPSession session, final Exception e) {
                // FIXME: support graceful restart
-               for (final BGPTableType t : this.tables)
+               for (final BGPTableType t : this.tables) {
                        this.rib.clearTable(this, t);
+               }
        }
 
        @Override
-       public void onSessionTerminated(final BGPError cause) {
-               logger.info("Session with peer {} terminated", this.name);
+       public void onSessionTerminated(final BGPSession session, final BGPTerminationReason cause) {
+               logger.info("Session with peer {} terminated: {}", this.name, cause);
        }
 
        @Override