Switched BGPMessage concept to yangtools.binding.Notification. 76/1476/1
authorDana Kutenicsova <dkutenic@cisco.com>
Sat, 28 Sep 2013 07:34:11 +0000 (09:34 +0200)
committerDana Kutenicsova <dkutenic@cisco.com>
Sat, 28 Sep 2013 07:34:11 +0000 (09:34 +0200)
Change-Id: Iad4b2e15f8093cd8d4ff926be619a6ea9b7d65e6
Signed-off-by: Dana Kutenicsova <dkutenic@cisco.com>
29 files changed:
bgp/parser-api/src/main/java/org/opendaylight/protocol/bgp/parser/BGPMessage.java [deleted file]
bgp/parser-api/src/main/java/org/opendaylight/protocol/bgp/parser/BGPMessageFactory.java
bgp/parser-api/src/main/java/org/opendaylight/protocol/bgp/parser/BGPSession.java
bgp/parser-api/src/main/java/org/opendaylight/protocol/bgp/parser/BGPSessionListener.java
bgp/parser-api/src/main/java/org/opendaylight/protocol/bgp/parser/BGPUpdateEvent.java
bgp/parser-api/src/main/java/org/opendaylight/protocol/bgp/parser/BGPUpdateMessage.java
bgp/parser-api/src/main/java/org/opendaylight/protocol/bgp/parser/message/BGPKeepAliveMessage.java
bgp/parser-api/src/main/java/org/opendaylight/protocol/bgp/parser/message/BGPNotificationMessage.java
bgp/parser-api/src/main/java/org/opendaylight/protocol/bgp/parser/message/BGPOpenMessage.java
bgp/parser-api/src/test/java/org/opendaylight/protocol/bgp/parser/APITest.java
bgp/parser-impl/src/main/java/org/opendaylight/protocol/bgp/parser/impl/BGPMessageFactoryImpl.java
bgp/parser-mock/src/main/java/org/opendaylight/protocol/bgp/parser/mock/BGPMessageParserMock.java
bgp/parser-mock/src/test/java/org/opendaylight/protocol/bgp/parser/mock/BGPMessageParserMockTest.java
bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/BGPHandlerFactory.java
bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/BGPPeer.java
bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/BGPSessionImpl.java
bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/BGPSessionNegotiator.java
bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/BGPSessionNegotiatorFactory.java
bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/FSMTest.java
bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/ParserTest.java
bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/SimpleSessionListener.java
bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/SpeakerSessionListener.java
bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/SpeakerSessionMock.java
bgp/rib-mock/src/main/java/org/opendaylight/protocol/bgp/rib/mock/BGPMock.java
bgp/rib-mock/src/main/java/org/opendaylight/protocol/bgp/rib/mock/EventBusRegistration.java
bgp/rib-mock/src/test/java/org/opendaylight/protocol/bgp/rib/mock/BGPListenerMock.java
bgp/testtool/src/main/java/org/opendaylight/protocol/bgp/testtool/TestingListener.java
bgp/testtool/src/test/java/org/opendaylight/protocol/bgp/testtool/BGPSpeakerMock.java
bgp/testtool/src/test/java/org/opendaylight/protocol/bgp/testtool/SpeakerSessionListener.java

diff --git a/bgp/parser-api/src/main/java/org/opendaylight/protocol/bgp/parser/BGPMessage.java b/bgp/parser-api/src/main/java/org/opendaylight/protocol/bgp/parser/BGPMessage.java
deleted file mode 100644 (file)
index 78999dd..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.protocol.bgp.parser;
-
-
-/**
- * Basic structure for BGP Message. There is not other common feature than the serialization.
- */
-@Deprecated
-public interface BGPMessage {
-
-}
index fe40691c96354e8c736f9be735b2148c8be8d621..1c25f27768cfcb9927949500fa001a39a71f2f48 100644 (file)
@@ -8,10 +8,11 @@
 package org.opendaylight.protocol.bgp.parser;
 
 import org.opendaylight.protocol.framework.ProtocolMessageFactory;
+import org.opendaylight.yangtools.yang.binding.Notification;
 
 /**
  * Interface to expose BGP specific MessageFactory.
  */
-public interface BGPMessageFactory extends ProtocolMessageFactory<BGPMessage> {
+public interface BGPMessageFactory extends ProtocolMessageFactory<Notification> {
 
 }
index af173644ced2bb595ad9b7103e06d30afb843910..fcfd73c80893d2c41db9cea8917f00d4744b5de4 100644 (file)
@@ -11,6 +11,7 @@ import java.util.Set;
 
 import org.opendaylight.protocol.bgp.concepts.BGPTableType;
 import org.opendaylight.protocol.framework.ProtocolSession;
+import org.opendaylight.yangtools.yang.binding.Notification;
 
 /**
  * BGP Session represents the finite state machine in BGP, including timers and its purpose is to create a BGP
@@ -19,7 +20,7 @@ import org.opendaylight.protocol.framework.ProtocolSession;
  * 
  * If the session is up, it has to redirect messages to/from user. Handles also malformed messages and unknown requests.
  */
-public interface BGPSession extends ProtocolSession<BGPMessage> {
+public interface BGPSession extends ProtocolSession<Notification> {
 
        public Set<BGPTableType> getAdvertisedTableTypes();
 }
index cc38f72dd81112ada6cc84f3cfba2bebf163cfee..8a4510f315d1116f3f9776f2691fa7a4062602f7 100644 (file)
@@ -8,10 +8,11 @@
 package org.opendaylight.protocol.bgp.parser;
 
 import org.opendaylight.protocol.framework.SessionListener;
+import org.opendaylight.yangtools.yang.binding.Notification;
 
 /**
  * Listener that receives session informations from the session.
  */
-public interface BGPSessionListener extends SessionListener<BGPMessage, BGPSession, BGPTerminationReason> {
+public interface BGPSessionListener extends SessionListener<Notification, BGPSession, BGPTerminationReason> {
 
 }
index 2d37917a6fecebb275f8ec9faf97df6c0ea9ef6a..e3813663726823c8b3936cd8906411163656bcb1 100644 (file)
@@ -7,12 +7,14 @@
  */
 package org.opendaylight.protocol.bgp.parser;
 
+import org.opendaylight.yangtools.yang.binding.Notification;
+
 /**
  * Marker interface for events resulting from parsing of an BGP UPDATE message. An unfortunate twist in BGP spec makes
  * use of a specially-crafted message to indicate that a per-AFI RIB has been completely synchronized.
  * 
  * Extends ProtocolMessage to allow parsing of BGP Update Messages in BGP listener.
  */
-public interface BGPUpdateEvent extends BGPMessage {
+public interface BGPUpdateEvent extends Notification {
 
 }
index ef015cd58d8040f1991401a528ee36501f7b7fb9..7bb7004e19496d89129543bfcba22955d1aa667f 100644 (file)
@@ -10,7 +10,7 @@ package org.opendaylight.protocol.bgp.parser;
 import java.util.Set;
 
 import org.opendaylight.protocol.bgp.concepts.BGPObject;
-
+import org.opendaylight.yangtools.yang.binding.Notification;
 
 /**
  * 
@@ -19,7 +19,7 @@ import org.opendaylight.protocol.bgp.concepts.BGPObject;
  * kind of situation. Therefore, first step is to remove objects, then add the other set.
  * 
  */
-public interface BGPUpdateMessage extends BGPUpdateEvent, BGPMessage {
+public interface BGPUpdateMessage extends BGPUpdateEvent, Notification {
        /**
         * Objects that are identified with Identifiers in this set, need to be removed from topology.
         * 
index af199a54691acd00495520604f1eba2f63379128..bf0370ef384cd7199225b24c53e70b5a6f4e44e5 100644 (file)
@@ -7,16 +7,14 @@
  */
 package org.opendaylight.protocol.bgp.parser.message;
 
-import org.opendaylight.protocol.bgp.parser.BGPMessage;
+import org.opendaylight.yangtools.yang.binding.Notification;
 
 /**
  * BGP KeepAlive message. Always empty.
  * 
  * @see <a href="http://tools.ietf.org/html/rfc4271#section-4.4">BGP KeepAlive message</a>
  */
-public final class BGPKeepAliveMessage implements BGPMessage {
-
-       private static final long serialVersionUID = 5469664138660829255L;
+public final class BGPKeepAliveMessage implements Notification {
 
        /**
         * Creates a BGP KeepAlive message.
index 7943aa38bf7c789a97935d1f589ea05b32f222ea..a4eb7aedaaa6ef1059b6ca8ccd36aa2eceaa4f3c 100644 (file)
@@ -10,17 +10,14 @@ package org.opendaylight.protocol.bgp.parser.message;
 import java.util.Arrays;
 
 import org.opendaylight.protocol.bgp.parser.BGPError;
-import org.opendaylight.protocol.bgp.parser.BGPMessage;
-
+import org.opendaylight.yangtools.yang.binding.Notification;
 
 /**
  * Representation of BGPNotification message.
  * 
  * @see <a link="http://tools.ietf.org/html/rfc4271#section-4.5">BGP Notification Message</a>
  */
-public final class BGPNotificationMessage implements BGPMessage {
-
-       private static final long serialVersionUID = -5860147919167775673L;
+public final class BGPNotificationMessage implements Notification {
 
        private final BGPError error;
 
index dab318e215ba49dd14c421b7e04870dc8686487a..03e535b256f9030fd887c585fcdd6cfaf9928641 100644 (file)
@@ -9,19 +9,17 @@ package org.opendaylight.protocol.bgp.parser.message;
 
 import java.util.List;
 
-import org.opendaylight.protocol.bgp.parser.BGPMessage;
 import org.opendaylight.protocol.bgp.parser.BGPParameter;
 import org.opendaylight.protocol.concepts.IPv4Address;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.AsNumber;
+import org.opendaylight.yangtools.yang.binding.Notification;
 
 /**
  * Representation of BGPOpen message.
  * 
  * @see <a href="http://tools.ietf.org/html/rfc4271#section-4.2">BGP Open Message</a>
  */
-public final class BGPOpenMessage implements BGPMessage {
-
-       private static final long serialVersionUID = -3507481736478860117L;
+public final class BGPOpenMessage implements Notification {
 
        /**
         * Current BGP version.
index 95a01781b378ea7ad65cbf6a5c6d95e3924427ea..43d583f8d66f435f5762faea83c73e697925ee35 100644 (file)
@@ -52,6 +52,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.type
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.extended.community.ExtendedCommunity;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.next.hop.c.next.hop.CIpv4NextHopBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.next.hop.c.next.hop.c.ipv4.next.hop.Ipv4NextHopBuilder;
+import org.opendaylight.yangtools.yang.binding.Notification;
 
 import com.google.common.collect.Maps;
 import com.google.common.collect.Sets;
@@ -163,13 +164,13 @@ public class APITest {
 
        @Test
        public void testBGPKeepAliveMessage() {
-               final BGPMessage msg = new BGPKeepAliveMessage();
+               final Notification msg = new BGPKeepAliveMessage();
                assertTrue(msg instanceof BGPKeepAliveMessage);
        }
 
        @Test
        public void testBGPNotificationMessage() {
-               final BGPMessage msg = new BGPNotificationMessage(BGPError.AS_PATH_MALFORMED);
+               final Notification msg = new BGPNotificationMessage(BGPError.AS_PATH_MALFORMED);
                assertTrue(msg instanceof BGPNotificationMessage);
                assertEquals(BGPError.AS_PATH_MALFORMED, ((BGPNotificationMessage) msg).getError());
                assertNull(((BGPNotificationMessage) msg).getData());
@@ -177,14 +178,14 @@ public class APITest {
 
        @Test
        public void testBGPOpenMessage() {
-               final BGPMessage msg = new BGPOpenMessage(new AsNumber((long) 58), (short) 5, null, null);
+               final Notification msg = new BGPOpenMessage(new AsNumber((long) 58), (short) 5, null, null);
                assertNull(((BGPOpenMessage) msg).getOptParams());
        }
 
        @Test
        public void testToString() {
-               final BGPMessage o = new BGPOpenMessage(new AsNumber((long) 58), (short) 5, null, null);
-               final BGPMessage n = new BGPNotificationMessage(BGPError.ATTR_FLAGS_MISSING);
+               final Notification o = new BGPOpenMessage(new AsNumber((long) 58), (short) 5, null, null);
+               final Notification n = new BGPNotificationMessage(BGPError.ATTR_FLAGS_MISSING);
                assertNotSame(o.toString(), n.toString());
        }
 }
index 21dc7c8a978e664fe1fdadcad0a714dda932207f..2a1bbbdefef3c37197f5ebd46bf33446d9ada8a0 100644 (file)
@@ -12,7 +12,6 @@ import java.util.List;
 
 import org.opendaylight.protocol.bgp.parser.BGPDocumentedException;
 import org.opendaylight.protocol.bgp.parser.BGPError;
-import org.opendaylight.protocol.bgp.parser.BGPMessage;
 import org.opendaylight.protocol.bgp.parser.BGPMessageFactory;
 import org.opendaylight.protocol.bgp.parser.impl.message.BGPNotificationMessageParser;
 import org.opendaylight.protocol.bgp.parser.impl.message.BGPOpenMessageParser;
@@ -23,6 +22,7 @@ import org.opendaylight.protocol.bgp.parser.message.BGPOpenMessage;
 import org.opendaylight.protocol.framework.DeserializerException;
 import org.opendaylight.protocol.framework.DocumentedException;
 import org.opendaylight.protocol.util.ByteArray;
+import org.opendaylight.yangtools.yang.binding.Notification;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -49,7 +49,7 @@ public final class BGPMessageFactoryImpl implements BGPMessageFactory {
         * @see org.opendaylight.protocol.bgp.parser.BGPMessageParser#parse(byte[])
         */
        @Override
-       public List<BGPMessage> parse(final byte[] bytes) throws DeserializerException, DocumentedException {
+       public List<Notification> parse(final byte[] bytes) throws DeserializerException, DocumentedException {
                if (bytes == null) {
                        throw new IllegalArgumentException("Array of bytes is mandatory.");
                }
@@ -81,7 +81,7 @@ public final class BGPMessageFactoryImpl implements BGPMessageFactory {
 
                logger.debug("Attempt to parse message from bytes: {}", ByteArray.bytesToHexString(msgBody));
 
-               final BGPMessage msg;
+               final Notification msg;
 
                switch (messageType) {
                case 1:
@@ -111,7 +111,7 @@ public final class BGPMessageFactoryImpl implements BGPMessageFactory {
        }
 
        @Override
-       public byte[] put(final BGPMessage msg) {
+       public byte[] put(final Notification msg) {
                if (msg == null) {
                        throw new IllegalArgumentException("BGPMessage is mandatory.");
                }
index abe4ea6df46483ee68612dc17f70ac0c1f35f05b..868d4c1b7aaae72b71b46c1d5cf05a4cdb6db4e3 100644 (file)
@@ -10,29 +10,29 @@ package org.opendaylight.protocol.bgp.parser.mock;
 import java.util.List;
 import java.util.Map;
 
-import org.opendaylight.protocol.bgp.parser.BGPMessage;
 import org.opendaylight.protocol.framework.DeserializerException;
 import org.opendaylight.protocol.framework.DocumentedException;
 import org.opendaylight.protocol.framework.ProtocolMessageFactory;
+import org.opendaylight.yangtools.yang.binding.Notification;
 
 /**
  * Mock implementation of {@link BGPMessageParser}. It implements the required interface by having two internal maps,
  * each used in one of the methods. It looks up the key provided to the method and returns whatever value is stored in
  * the map.
  */
-public class BGPMessageParserMock implements ProtocolMessageFactory<BGPMessage> {
-       private final Map<byte[], List<BGPMessage>> messages;
+public class BGPMessageParserMock implements ProtocolMessageFactory<Notification> {
+       private final Map<byte[], List<Notification>> messages;
 
        /**
         * @param updateMessages Map<byte[], BGPUpdateEvent>
         */
-       public BGPMessageParserMock(final Map<byte[], List<BGPMessage>> messages) {
+       public BGPMessageParserMock(final Map<byte[], List<Notification>> messages) {
                this.messages = messages;
        }
 
        @Override
-       public List<BGPMessage> parse(final byte[] bytes) throws DeserializerException, DocumentedException {
-               final List<BGPMessage> ret = this.messages.get(bytes);
+       public List<Notification> parse(final byte[] bytes) throws DeserializerException, DocumentedException {
+               final List<Notification> ret = this.messages.get(bytes);
                if (ret == null) {
                        throw new IllegalArgumentException("Undefined message encountered");
                }
@@ -40,7 +40,7 @@ public class BGPMessageParserMock implements ProtocolMessageFactory<BGPMessage>
        }
 
        @Override
-       public byte[] put(final BGPMessage msg) {
+       public byte[] put(final Notification msg) {
                // nothing
                return null;
        }
index 7d7ce3d22f50177745a3c0f4dd3ce1839e3e784f..148d62290bad260a0f4e28cc327edcaacb000b8e 100644 (file)
@@ -30,7 +30,6 @@ import org.opendaylight.protocol.bgp.concepts.BGPTableType;
 import org.opendaylight.protocol.bgp.concepts.BaseBGPObjectState;
 import org.opendaylight.protocol.bgp.linkstate.NetworkObjectState;
 import org.opendaylight.protocol.bgp.linkstate.NetworkRouteState;
-import org.opendaylight.protocol.bgp.parser.BGPMessage;
 import org.opendaylight.protocol.bgp.parser.BGPParameter;
 import org.opendaylight.protocol.bgp.parser.BGPRoute;
 import org.opendaylight.protocol.bgp.parser.BGPUpdateMessage;
@@ -59,6 +58,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.type
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.next.hop.CNextHop;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.next.hop.c.next.hop.CIpv6NextHopBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.next.hop.c.next.hop.c.ipv6.next.hop.Ipv6NextHopBuilder;
+import org.opendaylight.yangtools.yang.binding.Notification;
 
 import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
@@ -87,9 +87,9 @@ public class BGPMessageParserMockTest {
         */
        @Test
        public void testGetUpdateMessage() throws DeserializerException, DocumentedException, IOException {
-               final Map<byte[], List<BGPMessage>> updateMap = Maps.newHashMap();
+               final Map<byte[], List<Notification>> updateMap = Maps.newHashMap();
                for (int i = 0; i < this.inputBytes.length; i++) {
-                       updateMap.put(this.inputBytes[i], Lists.newArrayList((BGPMessage) this.messages.get(i)));
+                       updateMap.put(this.inputBytes[i], Lists.newArrayList((Notification) this.messages.get(i)));
                }
 
                final BGPMessageParserMock mockParser = new BGPMessageParserMock(updateMap);
@@ -109,9 +109,9 @@ public class BGPMessageParserMockTest {
         */
        @Test(expected = IllegalArgumentException.class)
        public void testGetUpdateMessageException() throws DeserializerException, DocumentedException, IOException {
-               final Map<byte[], List<BGPMessage>> updateMap = Maps.newHashMap();
+               final Map<byte[], List<Notification>> updateMap = Maps.newHashMap();
                for (int i = 0; i < this.inputBytes.length; i++) {
-                       updateMap.put(this.inputBytes[i], Lists.newArrayList((BGPMessage) this.messages.get(i)));
+                       updateMap.put(this.inputBytes[i], Lists.newArrayList((Notification) this.messages.get(i)));
                }
 
                final BGPMessageParserMock mockParser = new BGPMessageParserMock(updateMap);
@@ -171,7 +171,7 @@ public class BGPMessageParserMockTest {
 
        @Test
        public void testGetOpenMessage() throws DeserializerException, DocumentedException, IOException {
-               final Map<byte[], List<BGPMessage>> openMap = Maps.newHashMap();
+               final Map<byte[], List<Notification>> openMap = Maps.newHashMap();
 
                final Set<BGPTableType> type = Sets.newHashSet();
                type.add(new BGPTableType(Ipv4AddressFamily.class, MplsLabeledVpnSubsequentAddressFamily.class));
@@ -181,7 +181,7 @@ public class BGPMessageParserMockTest {
 
                final byte[] input = new byte[] { 5, 8, 13, 21 };
 
-               openMap.put(input, Lists.newArrayList((BGPMessage) new BGPOpenMessage(new AsNumber((long) 30), (short) 30, null, params)));
+               openMap.put(input, Lists.newArrayList((Notification) new BGPOpenMessage(new AsNumber((long) 30), (short) 30, null, params)));
 
                final BGPMessageParserMock mockParser = new BGPMessageParserMock(openMap);
 
index 0e2b9ceed8f389057c19379aee1b8fb42e4f70d8..8ffbd94525c290598304913ca92cb7fda69d8e1d 100644 (file)
@@ -9,21 +9,21 @@ package org.opendaylight.protocol.bgp.rib.impl;
 
 import io.netty.channel.ChannelHandler;
 
-import org.opendaylight.protocol.bgp.parser.BGPMessage;
 import org.opendaylight.protocol.bgp.parser.BGPMessageFactory;
 import org.opendaylight.protocol.framework.ProtocolHandlerFactory;
 import org.opendaylight.protocol.framework.ProtocolMessageDecoder;
 import org.opendaylight.protocol.framework.ProtocolMessageEncoder;
+import org.opendaylight.yangtools.yang.binding.Notification;
 
 /**
  * BGP specific factory for protocol inbound/outbound handlers.
  */
-public class BGPHandlerFactory extends ProtocolHandlerFactory<BGPMessage> {
-       private final ProtocolMessageEncoder<BGPMessage> encoder;
+public class BGPHandlerFactory extends ProtocolHandlerFactory<Notification> {
+       private final ProtocolMessageEncoder<Notification> encoder;
 
        public BGPHandlerFactory(final BGPMessageFactory msgFactory) {
                super(msgFactory);
-               this.encoder = new ProtocolMessageEncoder<BGPMessage>(this.msgFactory);
+               this.encoder = new ProtocolMessageEncoder<Notification>(this.msgFactory);
        }
 
        @Override
@@ -33,6 +33,6 @@ public class BGPHandlerFactory extends ProtocolHandlerFactory<BGPMessage> {
 
        @Override
        public ChannelHandler[] getDecoders() {
-               return new ChannelHandler[] { new BGPMessageHeaderDecoder(), new ProtocolMessageDecoder<BGPMessage>(this.msgFactory) };
+               return new ChannelHandler[] { new BGPMessageHeaderDecoder(), new ProtocolMessageDecoder<Notification>(this.msgFactory) };
        }
 }
index a56a2c05cf7a96d9c1e0393a8eba3ddfe7696dc5..16e4e71f2cca57b26ca904dea41c11f5f224566e 100644 (file)
@@ -10,11 +10,11 @@ package org.opendaylight.protocol.bgp.rib.impl;
 import java.util.Set;
 
 import org.opendaylight.protocol.bgp.concepts.BGPTableType;
-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.opendaylight.yangtools.yang.binding.Notification;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -38,7 +38,7 @@ public final class BGPPeer implements BGPSessionListener {
        }
 
        @Override
-       public void onMessage(final BGPSession session, final BGPMessage message) {
+       public void onMessage(final BGPSession session, final Notification message) {
                if (message instanceof BGPUpdateMessage) {
                        final BGPUpdateMessage m = (BGPUpdateMessage) message;
                        this.rib.updateTables(this, m.getAddedObjects(), m.getRemovedObjects());
index 65bb948121bb48332b68a3c77b2c3e475b50d235..9a9139db5d1563ad3974a870b42b4578bcf07772 100644 (file)
@@ -21,7 +21,6 @@ import javax.annotation.concurrent.GuardedBy;
 
 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.BGPParameter;
 import org.opendaylight.protocol.bgp.parser.BGPSession;
 import org.opendaylight.protocol.bgp.parser.BGPSessionListener;
@@ -31,6 +30,7 @@ import org.opendaylight.protocol.bgp.parser.message.BGPNotificationMessage;
 import org.opendaylight.protocol.bgp.parser.message.BGPOpenMessage;
 import org.opendaylight.protocol.bgp.parser.parameter.MultiprotocolCapability;
 import org.opendaylight.protocol.framework.AbstractProtocolSession;
+import org.opendaylight.yangtools.yang.binding.Notification;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -41,7 +41,7 @@ import com.google.common.base.Preconditions;
 import com.google.common.collect.Sets;
 
 @VisibleForTesting
-public class BGPSessionImpl extends AbstractProtocolSession<BGPMessage> implements BGPSession {
+public class BGPSessionImpl extends AbstractProtocolSession<Notification> implements BGPSession {
 
        private static final Logger logger = LoggerFactory.getLogger(BGPSessionImpl.class);
 
@@ -54,11 +54,9 @@ public class BGPSessionImpl extends AbstractProtocolSession<BGPMessage> implemen
         */
        public enum State {
                /**
-                * The session object is created by the negotiator in OpenConfirm state.
-                * While in this state, the session object is half-alive, e.g. the timers
-                * are running, but the session is not completely up, e.g. it has not been
-                * announced to the listener. If the session is torn down in this state,
-                * we do not inform the listener.
+                * The session object is created by the negotiator in OpenConfirm state. While in this state, the session object
+                * is half-alive, e.g. the timers are running, but the session is not completely up, e.g. it has not been
+                * announced to the listener. If the session is torn down in this state, we do not inform the listener.
                 */
                OpenConfirm,
                /**
@@ -153,7 +151,7 @@ public class BGPSessionImpl extends AbstractProtocolSession<BGPMessage> implemen
         * @param msg incoming message
         */
        @Override
-       public void handleMessage(final BGPMessage msg) {
+       public void handleMessage(final Notification msg) {
                // Update last reception time
                this.lastMessageReceivedAt = System.nanoTime();
 
@@ -185,7 +183,7 @@ public class BGPSessionImpl extends AbstractProtocolSession<BGPMessage> implemen
                }
        }
 
-       void sendMessage(final BGPMessage msg) {
+       void sendMessage(final Notification msg) {
                try {
                        this.channel.writeAndFlush(msg);
                        this.lastMessageSentAt = System.nanoTime();
index a1b9aa529e677a33a63cd5f71412e3189b63ecb4..3ee9ef04c5e200560392ab186e72e0a2ea4549f4 100644 (file)
@@ -20,7 +20,6 @@ import javax.annotation.concurrent.GuardedBy;
 
 import org.opendaylight.protocol.bgp.parser.BGPDocumentedException;
 import org.opendaylight.protocol.bgp.parser.BGPError;
-import org.opendaylight.protocol.bgp.parser.BGPMessage;
 import org.opendaylight.protocol.bgp.parser.BGPParameter;
 import org.opendaylight.protocol.bgp.parser.BGPSessionListener;
 import org.opendaylight.protocol.bgp.parser.message.BGPKeepAliveMessage;
@@ -32,13 +31,14 @@ import org.opendaylight.protocol.bgp.rib.impl.spi.BGPSessionPreferences;
 import org.opendaylight.protocol.framework.AbstractSessionNegotiator;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev130918.LinkstateAddressFamily;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev130918.LinkstateSubsequentAddressFamily;
+import org.opendaylight.yangtools.yang.binding.Notification;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import com.google.common.annotations.VisibleForTesting;
 import com.google.common.base.Preconditions;
 
-public final class BGPSessionNegotiator extends AbstractSessionNegotiator<BGPMessage, BGPSessionImpl> {
+public final class BGPSessionNegotiator extends AbstractSessionNegotiator<Notification, BGPSessionImpl> {
        // 4 minutes recommended in http://tools.ietf.org/html/rfc4271#section-8.2.2
        // FIXME to actual value
        protected static final int INITIAL_HOLDTIMER = 1;
@@ -108,7 +108,7 @@ public final class BGPSessionNegotiator extends AbstractSessionNegotiator<BGPMes
        }
 
        @Override
-       protected synchronized void handleMessage(final BGPMessage msg) {
+       protected synchronized void handleMessage(final Notification msg) {
                logger.debug("Channel {} handling message in state {}", this.channel, this.state);
 
                switch (this.state) {
index 668c1e8a7ac3971b885196c0b3f3bc4d258ec92c..dbbe5d1f801f5d72d0b5b302bb079308e39066a0 100644 (file)
@@ -4,16 +4,16 @@ import io.netty.channel.Channel;
 import io.netty.util.Timer;
 import io.netty.util.concurrent.Promise;
 
-import org.opendaylight.protocol.bgp.parser.BGPMessage;
 import org.opendaylight.protocol.bgp.parser.BGPSessionListener;
 import org.opendaylight.protocol.bgp.rib.impl.spi.BGPSessionPreferences;
 import org.opendaylight.protocol.framework.SessionListenerFactory;
 import org.opendaylight.protocol.framework.SessionNegotiator;
 import org.opendaylight.protocol.framework.SessionNegotiatorFactory;
+import org.opendaylight.yangtools.yang.binding.Notification;
 
 import com.google.common.base.Preconditions;
 
-public final class BGPSessionNegotiatorFactory implements SessionNegotiatorFactory<BGPMessage, BGPSessionImpl, BGPSessionListener> {
+public final class BGPSessionNegotiatorFactory implements SessionNegotiatorFactory<Notification, BGPSessionImpl, BGPSessionListener> {
        private final BGPSessionPreferences initialPrefs;
        private final Timer timer;
 
@@ -25,6 +25,6 @@ public final class BGPSessionNegotiatorFactory implements SessionNegotiatorFacto
        @Override
        public SessionNegotiator<BGPSessionImpl> getSessionNegotiator(final SessionListenerFactory<BGPSessionListener> factory,
                        final Channel channel, final Promise<BGPSessionImpl> promise) {
-               return new BGPSessionNegotiator(timer, promise, channel, initialPrefs, factory.getSessionListener());
+               return new BGPSessionNegotiator(this.timer, promise, channel, this.initialPrefs, factory.getSessionListener());
        }
 }
index 421bc8a5b16ef968952f7b5abd1b24ac160d8cab..07552484132ee9860ba8e79e0d1566002a26d122 100644 (file)
@@ -34,7 +34,6 @@ import org.mockito.invocation.InvocationOnMock;
 import org.mockito.stubbing.Answer;
 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.BGPParameter;
 import org.opendaylight.protocol.bgp.parser.message.BGPKeepAliveMessage;
 import org.opendaylight.protocol.bgp.parser.message.BGPNotificationMessage;
@@ -46,6 +45,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.link
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev130918.LinkstateSubsequentAddressFamily;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.Ipv4AddressFamily;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.UnicastSubsequentAddressFamily;
+import org.opendaylight.yangtools.yang.binding.Notification;
 
 import com.google.common.collect.Lists;
 
@@ -63,7 +63,7 @@ public class FSMTest {
 
        private final BGPTableType linkstatett = new BGPTableType(LinkstateAddressFamily.class, LinkstateSubsequentAddressFamily.class);
 
-       private final List<BGPMessage> receivedMsgs = Lists.newArrayList();
+       private final List<Notification> receivedMsgs = Lists.newArrayList();
 
        private BGPOpenMessage classicOpen;
 
@@ -79,10 +79,10 @@ public class FSMTest {
                        @Override
                        public Object answer(final InvocationOnMock invocation) {
                                final Object[] args = invocation.getArguments();
-                               FSMTest.this.receivedMsgs.add((BGPMessage) args[0]);
+                               FSMTest.this.receivedMsgs.add((Notification) args[0]);
                                return null;
                        }
-               }).when(this.speakerListener).writeAndFlush(any(BGPMessage.class));
+               }).when(this.speakerListener).writeAndFlush(any(Notification.class));
                doReturn("TestingChannel").when(this.speakerListener).toString();
                doReturn(this.pipeline).when(this.speakerListener).pipeline();
                doReturn(this.pipeline).when(this.pipeline).replace(any(ChannelHandler.class), any(String.class), any(ChannelHandler.class));
@@ -119,7 +119,7 @@ public class FSMTest {
                this.clientSession.handleMessage(new BGPOpenMessage(new AsNumber((long) 30), (short) 1, null, null));
                assertEquals(2, this.receivedMsgs.size());
                assertTrue(this.receivedMsgs.get(1) instanceof BGPNotificationMessage);
-               final BGPMessage m = this.receivedMsgs.get(this.receivedMsgs.size() - 1);
+               final Notification m = this.receivedMsgs.get(this.receivedMsgs.size() - 1);
                assertEquals(BGPError.UNSPECIFIC_OPEN_ERROR, ((BGPNotificationMessage) m).getError());
        }
 
@@ -132,7 +132,7 @@ public class FSMTest {
                assertTrue(this.receivedMsgs.get(0) instanceof BGPOpenMessage);
                Thread.sleep(BGPSessionNegotiator.INITIAL_HOLDTIMER * 1000 * 60);
                Thread.sleep(100);
-               final BGPMessage m = this.receivedMsgs.get(this.receivedMsgs.size() - 1);
+               final Notification m = this.receivedMsgs.get(this.receivedMsgs.size() - 1);
                assertEquals(BGPError.HOLD_TIMER_EXPIRED, ((BGPNotificationMessage) m).getError());
        }
 
index 3916101fb1ae82bcd8eff4b8113004036bfb2340..cfd4c3c9e3f90953e3814b5903309d2e9db3ca8b 100644 (file)
@@ -24,7 +24,6 @@ import org.junit.Test;
 import org.opendaylight.protocol.bgp.concepts.BGPTableType;
 import org.opendaylight.protocol.bgp.parser.BGPDocumentedException;
 import org.opendaylight.protocol.bgp.parser.BGPError;
-import org.opendaylight.protocol.bgp.parser.BGPMessage;
 import org.opendaylight.protocol.bgp.parser.BGPParameter;
 import org.opendaylight.protocol.bgp.parser.impl.BGPMessageFactoryImpl;
 import org.opendaylight.protocol.bgp.parser.message.BGPKeepAliveMessage;
@@ -41,6 +40,7 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev130918.LinkstateAddressFamily;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.Ipv4AddressFamily;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.UnicastSubsequentAddressFamily;
+import org.opendaylight.yangtools.yang.binding.Notification;
 
 import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
@@ -48,19 +48,19 @@ import com.google.common.collect.Maps;
 public class ParserTest {
 
        public static final byte[] openBMsg = new byte[] { (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
-               (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
-               (byte) 0xff, (byte) 0x00, (byte) 0x1d, (byte) 0x01, (byte) 0x04, (byte) 0x00, (byte) 0x64, (byte) 0x00, (byte) 0xb4,
-               (byte) 0x14, (byte) 0x14, (byte) 0x14, (byte) 0x14, (byte) 0x00 };
+                       (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
+                       (byte) 0xff, (byte) 0x00, (byte) 0x1d, (byte) 0x01, (byte) 0x04, (byte) 0x00, (byte) 0x64, (byte) 0x00, (byte) 0xb4,
+                       (byte) 0x14, (byte) 0x14, (byte) 0x14, (byte) 0x14, (byte) 0x00 };
 
        public static final byte[] keepAliveBMsg = new byte[] { (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
-               (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
-               (byte) 0xff, (byte) 0x00, (byte) 0x13, (byte) 0x04 };
+                       (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
+                       (byte) 0xff, (byte) 0x00, (byte) 0x13, (byte) 0x04 };
 
        public static final byte[] notificationBMsg = new byte[] { (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
-               (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
-               (byte) 0xff, (byte) 0xff, (byte) 0x00, (byte) 0x17, (byte) 0x03, (byte) 0x02, (byte) 0x04, (byte) 0x04, (byte) 0x09 };
+                       (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
+                       (byte) 0xff, (byte) 0xff, (byte) 0x00, (byte) 0x17, (byte) 0x03, (byte) 0x02, (byte) 0x04, (byte) 0x04, (byte) 0x09 };
 
-       final ProtocolMessageFactory<BGPMessage> factory = new BGPMessageFactoryImpl();
+       final ProtocolMessageFactory<Notification> factory = new BGPMessageFactoryImpl();
 
        @Test
        public void testHeaderErrors() throws DeserializerException, DocumentedException {
@@ -95,11 +95,11 @@ public class ParserTest {
 
        @Test
        public void testKeepAliveMsg() throws DeserializerException, DocumentedException {
-               final BGPMessage keepAlive = new BGPKeepAliveMessage();
+               final Notification keepAlive = new BGPKeepAliveMessage();
                final byte[] bytes = this.factory.put(keepAlive);
                assertArrayEquals(keepAliveBMsg, bytes);
 
-               final BGPMessage m = this.factory.parse(bytes).get(0);
+               final Notification m = this.factory.parse(bytes).get(0);
 
                assertTrue(m instanceof BGPKeepAliveMessage);
        }
@@ -123,11 +123,11 @@ public class ParserTest {
 
        @Test
        public void testOpenMessage() throws UnknownHostException, DeserializerException, DocumentedException {
-               final BGPMessage open = new BGPOpenMessage(new AsNumber((long) 100), (short) 180, new IPv4Address(InetAddress.getByName("20.20.20.20")), null);
+               final Notification open = new BGPOpenMessage(new AsNumber((long) 100), (short) 180, new IPv4Address(InetAddress.getByName("20.20.20.20")), null);
                final byte[] bytes = this.factory.put(open);
                assertArrayEquals(openBMsg, bytes);
 
-               final BGPMessage m = this.factory.parse(bytes).get(0);
+               final Notification m = this.factory.parse(bytes).get(0);
 
                assertTrue(m instanceof BGPOpenMessage);
                assertEquals(new AsNumber((long) 100), ((BGPOpenMessage) m).getMyAS());
@@ -190,11 +190,11 @@ public class ParserTest {
 
        @Test
        public void testNotificationMsg() throws DeserializerException, DocumentedException {
-               BGPMessage notMsg = new BGPNotificationMessage(BGPError.OPT_PARAM_NOT_SUPPORTED, new byte[] { 4, 9 });
+               Notification notMsg = new BGPNotificationMessage(BGPError.OPT_PARAM_NOT_SUPPORTED, new byte[] { 4, 9 });
                byte[] bytes = this.factory.put(notMsg);
                assertArrayEquals(notificationBMsg, bytes);
 
-               BGPMessage m = this.factory.parse(bytes).get(0);
+               Notification m = this.factory.parse(bytes).get(0);
 
                assertTrue(m instanceof BGPNotificationMessage);
                assertEquals(BGPError.OPT_PARAM_NOT_SUPPORTED, ((BGPNotificationMessage) m).getError());
index aea49383b699f46fef1db3e40b15781239fac082..d6b6b7d2887798d5acc925e0a2865e640e630b06 100644 (file)
@@ -9,10 +9,10 @@ package org.opendaylight.protocol.bgp.rib.impl;
 
 import java.util.List;
 
-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.yangtools.yang.binding.Notification;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -23,7 +23,7 @@ import com.google.common.collect.Lists;
  */
 public class SimpleSessionListener implements BGPSessionListener {
 
-       private final List<BGPMessage> listMsg = Lists.newArrayList();
+       private final List<Notification> listMsg = Lists.newArrayList();
 
        public boolean up = false;
 
@@ -31,12 +31,12 @@ public class SimpleSessionListener implements BGPSessionListener {
 
        public boolean down = false;
 
-       public List<BGPMessage> getListMsg() {
+       public List<Notification> getListMsg() {
                return this.listMsg;
        }
 
        @Override
-       public void onMessage(final BGPSession session, final BGPMessage message) {
+       public void onMessage(final BGPSession session, final Notification message) {
                this.listMsg.add(message);
                logger.debug("Message received:" + message);
        }
index 5574a238b1dca689e16526c57bca640296b3b42f..92f3d6138ee4f155460a1b45c0c37932e10fad06 100644 (file)
@@ -11,10 +11,10 @@ import java.util.List;
 import java.util.Set;
 
 import org.opendaylight.protocol.bgp.concepts.BGPTableType;
-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.yangtools.yang.binding.Notification;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -25,7 +25,7 @@ import com.google.common.collect.Lists;
  */
 public class SpeakerSessionListener implements BGPSessionListener {
 
-       public List<BGPMessage> messages = Lists.newArrayList();
+       public List<Notification> messages = Lists.newArrayList();
 
        public boolean up = false;
 
@@ -37,7 +37,7 @@ public class SpeakerSessionListener implements BGPSessionListener {
        }
 
        @Override
-       public void onMessage(final BGPSession session, final BGPMessage message) {
+       public void onMessage(final BGPSession session, final Notification message) {
                logger.debug("Received message: " + message.getClass() + " " + message);
                this.messages.add(message);
        }
index 7589938c07963e212f8bed093a9ce0fa904f54f5..fa87011081463f0c61c0ec3b32ae221527be4d8f 100644 (file)
@@ -11,9 +11,9 @@ import static org.mockito.Mockito.mock;
 import io.netty.channel.Channel;
 import io.netty.util.HashedWheelTimer;
 
-import org.opendaylight.protocol.bgp.parser.BGPMessage;
 import org.opendaylight.protocol.bgp.parser.BGPSessionListener;
 import org.opendaylight.protocol.bgp.parser.message.BGPOpenMessage;
+import org.opendaylight.yangtools.yang.binding.Notification;
 
 /**
  * Mock of the BGP speakers session.
@@ -28,7 +28,7 @@ public class SpeakerSessionMock extends BGPSessionImpl {
        }
 
        @Override
-       public void sendMessage(final BGPMessage msg) {
+       public void sendMessage(final Notification msg) {
                this.lastMessageSentAt = System.nanoTime();
                this.client.onMessage(this, msg);
        }
index d1122d524508848aa0c44b90b01124d5bc6e7643..afe7ad008f48cf7e5be8a40be733c7a661a0acc4 100644 (file)
@@ -16,7 +16,6 @@ import javax.annotation.concurrent.GuardedBy;
 import javax.annotation.concurrent.ThreadSafe;
 
 import org.opendaylight.protocol.bgp.parser.BGPError;
-import org.opendaylight.protocol.bgp.parser.BGPMessage;
 import org.opendaylight.protocol.bgp.parser.BGPSessionListener;
 import org.opendaylight.protocol.bgp.parser.impl.BGPMessageFactoryImpl;
 import org.opendaylight.protocol.bgp.parser.message.BGPNotificationMessage;
@@ -27,6 +26,7 @@ import org.opendaylight.protocol.framework.DocumentedException;
 import org.opendaylight.protocol.framework.ProtocolMessageFactory;
 import org.opendaylight.protocol.framework.ReconnectStrategy;
 import org.opendaylight.protocol.util.ByteArray;
+import org.opendaylight.yangtools.yang.binding.Notification;
 
 import com.google.common.collect.Lists;
 import com.google.common.eventbus.EventBus;
@@ -38,11 +38,11 @@ import com.google.common.eventbus.EventBus;
  */
 @ThreadSafe
 public final class BGPMock implements BGP, Closeable {
-       static final BGPMessage connectionLostMagicMessage = new BGPNotificationMessage(BGPError.CEASE);
+       static final Notification connectionLostMagicMessage = new BGPNotificationMessage(BGPError.CEASE);
 
        @GuardedBy("this")
        private final List<byte[]> allPreviousByteMessages;
-       private final List<BGPMessage> allPreviousBGPMessages;
+       private final List<Notification> allPreviousBGPMessages;
        private final EventBus eventBus;
        @GuardedBy("this")
        private final List<EventBusRegistration> openRegistrations = Lists.newLinkedList();
@@ -53,9 +53,9 @@ public final class BGPMock implements BGP, Closeable {
                this.allPreviousBGPMessages = this.parsePrevious(this.allPreviousByteMessages);
        }
 
-       private List<BGPMessage> parsePrevious(final List<byte[]> msgs) {
-               final List<BGPMessage> messages = Lists.newArrayList();
-               final ProtocolMessageFactory<BGPMessage> parser = new BGPMessageFactoryImpl();
+       private List<Notification> parsePrevious(final List<byte[]> msgs) {
+               final List<Notification> messages = Lists.newArrayList();
+               final ProtocolMessageFactory<Notification> parser = new BGPMessageFactoryImpl();
                try {
                        for (final byte[] b : msgs) {
 
@@ -76,7 +76,8 @@ public final class BGPMock implements BGP, Closeable {
         * @return ListenerRegistration
         */
        @Override
-       public synchronized ListenerRegistration<BGPSessionListener> registerUpdateListener(final BGPSessionListener listener, final ReconnectStrategy strategy) {
+       public synchronized ListenerRegistration<BGPSessionListener> registerUpdateListener(final BGPSessionListener listener,
+                       final ReconnectStrategy strategy) {
                return EventBusRegistration.createAndRegister(this.eventBus, listener, this.allPreviousBGPMessages);
        }
 
@@ -84,13 +85,13 @@ public final class BGPMock implements BGP, Closeable {
                this.insertMessage(connectionLostMagicMessage);
        }
 
-       public synchronized void insertMessages(final List<BGPMessage> messages) {
-               for (final BGPMessage message : messages) {
+       public synchronized void insertMessages(final List<Notification> messages) {
+               for (final Notification message : messages) {
                        this.insertMessage(message);
                }
        }
 
-       private synchronized void insertMessage(final BGPMessage message) {
+       private synchronized void insertMessage(final Notification message) {
                this.allPreviousBGPMessages.add(message);
                this.eventBus.post(message);
        }
index 7013d3def060a4078c617cdec22fdecc7bee76b3..c3a642b5a848f67f2e8681fd4f71c4995c8d0b5a 100644 (file)
@@ -13,7 +13,6 @@ import java.util.Set;
 import javax.annotation.concurrent.GuardedBy;
 
 import org.opendaylight.protocol.bgp.concepts.BGPTableType;
-import org.opendaylight.protocol.bgp.parser.BGPMessage;
 import org.opendaylight.protocol.bgp.parser.BGPParameter;
 import org.opendaylight.protocol.bgp.parser.BGPSession;
 import org.opendaylight.protocol.bgp.parser.BGPSessionListener;
@@ -21,6 +20,7 @@ import org.opendaylight.protocol.bgp.parser.message.BGPKeepAliveMessage;
 import org.opendaylight.protocol.bgp.parser.message.BGPOpenMessage;
 import org.opendaylight.protocol.bgp.parser.parameter.MultiprotocolCapability;
 import org.opendaylight.protocol.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.yang.binding.Notification;
 
 import com.google.common.collect.Sets;
 import com.google.common.eventbus.EventBus;
@@ -37,22 +37,22 @@ class EventBusRegistration implements ListenerRegistration<BGPSessionListener> {
        private boolean closed = false;
 
        public static EventBusRegistration createAndRegister(final EventBus eventBus, final BGPSessionListener listener,
-                       final List<BGPMessage> allPreviousMessages) {
+                       final List<Notification> allPreviousMessages) {
                final EventBusRegistration instance = new EventBusRegistration(eventBus, listener, allPreviousMessages);
                eventBus.register(instance);
                return instance;
        }
 
-       private EventBusRegistration(final EventBus eventBus, final BGPSessionListener listener, final List<BGPMessage> allPreviousMessages) {
+       private EventBusRegistration(final EventBus eventBus, final BGPSessionListener listener, final List<Notification> allPreviousMessages) {
                this.eventBus = eventBus;
                this.listener = listener;
-               for (final BGPMessage message : allPreviousMessages) {
+               for (final Notification message : allPreviousMessages) {
                        sendMessage(listener, message);
                }
        }
 
        @Subscribe
-       public void onMessage(final BGPMessage message) {
+       public void onMessage(final Notification message) {
                sendMessage(this.listener, message);
        }
 
@@ -65,7 +65,7 @@ class EventBusRegistration implements ListenerRegistration<BGPSessionListener> {
                this.closed = true;
        }
 
-       private static void sendMessage(final BGPSessionListener listener, final BGPMessage message) {
+       private static void sendMessage(final BGPSessionListener listener, final Notification message) {
                if (BGPMock.connectionLostMagicMessage.equals(message)) {
                        listener.onSessionTerminated(null, null);
                } else if (message instanceof BGPOpenMessage) {
index 3cae9787a530ece29feb9245afdecb8e2eee5993..e46a9a636915eff4825a24b572a0ac31e4d3f939 100644 (file)
@@ -11,20 +11,19 @@ import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
 
-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.yangtools.yang.binding.Notification;
 
 /**
  * Mock implementation of {@link BGPListener} for testing purposes.
  */
 final class BGPListenerMock implements BGPSessionListener {
-       private final List<BGPMessage> buffer = Collections.synchronizedList(new ArrayList<BGPMessage>());
+       private final List<Notification> buffer = Collections.synchronizedList(new ArrayList<Notification>());
        private boolean connected = false;
 
-       protected List<BGPMessage> getBuffer() {
+       protected List<Notification> getBuffer() {
                return this.buffer;
        }
 
@@ -33,7 +32,7 @@ final class BGPListenerMock implements BGPSessionListener {
        }
 
        @Override
-       public void onMessage(final BGPSession session, final BGPMessage message) {
+       public void onMessage(final BGPSession session, final Notification message) {
                this.buffer.add(message);
        }
 
index 37cb37bd1df30e08331ddbd777a977a366579a17..617797df0bcdaf22bec4ec9eda42335d3cca591b 100644 (file)
@@ -7,10 +7,10 @@
  */
 package org.opendaylight.protocol.bgp.testtool;
 
-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.yangtools.yang.binding.Notification;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -21,7 +21,7 @@ public class TestingListener implements BGPSessionListener {
        private static final Logger logger = LoggerFactory.getLogger(TestingListener.class);
 
        @Override
-       public void onMessage(final BGPSession session, final BGPMessage message) {
+       public void onMessage(final BGPSession session, final Notification message) {
                logger.info("Client Listener: message received: {}", message.toString());
        }
 
index e5d11fd7659a8437d1403daf1a4cecaf8a656636..b4a529205f1542de2f5705100fff2e80f245950b 100644 (file)
@@ -16,7 +16,6 @@ import io.netty.util.concurrent.Promise;
 import java.io.IOException;
 import java.net.InetSocketAddress;
 
-import org.opendaylight.protocol.bgp.parser.BGPMessage;
 import org.opendaylight.protocol.bgp.parser.BGPSessionListener;
 import org.opendaylight.protocol.bgp.parser.impl.BGPMessageFactoryImpl;
 import org.opendaylight.protocol.bgp.rib.impl.BGPHandlerFactory;
@@ -32,11 +31,11 @@ import org.opendaylight.protocol.framework.SessionListener;
 import org.opendaylight.protocol.framework.SessionListenerFactory;
 import org.opendaylight.protocol.framework.SessionNegotiatorFactory;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.AsNumber;
+import org.opendaylight.yangtools.yang.binding.Notification;
 
 import com.google.common.base.Preconditions;
 
-public class BGPSpeakerMock<M, S extends ProtocolSession<M>, L extends SessionListener<M, ?, ?>> extends
-AbstractDispatcher<S, L> {
+public class BGPSpeakerMock<M, S extends ProtocolSession<M>, L extends SessionListener<M, ?, ?>> extends AbstractDispatcher<S, L> {
 
        private final SessionNegotiatorFactory<M, S, L> negotiatorFactory;
        private final ProtocolHandlerFactory<?> factory;
@@ -52,9 +51,10 @@ AbstractDispatcher<S, L> {
 
                        @Override
                        public void initializeChannel(final SocketChannel ch, final Promise<S> promise) {
-                               ch.pipeline().addLast(factory.getDecoders());
-                               ch.pipeline().addLast("negotiator", negotiatorFactory.getSessionNegotiator(listenerFactory, ch, promise));
-                               ch.pipeline().addLast(factory.getEncoders());
+                               ch.pipeline().addLast(BGPSpeakerMock.this.factory.getDecoders());
+                               ch.pipeline().addLast("negotiator",
+                                               BGPSpeakerMock.this.negotiatorFactory.getSessionNegotiator(listenerFactory, ch, promise));
+                               ch.pipeline().addLast(BGPSpeakerMock.this.factory.getEncoders());
                        }
                });
        }
@@ -70,9 +70,9 @@ AbstractDispatcher<S, L> {
 
                final BGPSessionPreferences prefs = new BGPSessionProposalImpl((short) 90, new AsNumber((long) 25), IPv4.FAMILY.addressForString("127.0.0.2")).getProposal();
 
-               final SessionNegotiatorFactory<BGPMessage, BGPSessionImpl, BGPSessionListener> snf = new BGPSessionNegotiatorFactory(new HashedWheelTimer(), prefs);
+               final SessionNegotiatorFactory<Notification, BGPSessionImpl, BGPSessionListener> snf = new BGPSessionNegotiatorFactory(new HashedWheelTimer(), prefs);
 
-               final BGPSpeakerMock<BGPMessage, BGPSessionImpl, BGPSessionListener> mock = new BGPSpeakerMock<BGPMessage, BGPSessionImpl, BGPSessionListener>(snf, new BGPHandlerFactory(new BGPMessageFactoryImpl()), new DefaultPromise<BGPSessionImpl>(GlobalEventExecutor.INSTANCE));
+               final BGPSpeakerMock<Notification, BGPSessionImpl, BGPSessionListener> mock = new BGPSpeakerMock<Notification, BGPSessionImpl, BGPSessionListener>(snf, new BGPHandlerFactory(new BGPMessageFactoryImpl()), new DefaultPromise<BGPSessionImpl>(GlobalEventExecutor.INSTANCE));
 
                mock.createServer(new InetSocketAddress("127.0.0.2", 12345), f);
        }
index 22852c049d67191a04236c15f80589ace7dc8563..edc271ca9878149d115c1a6fc721b0bf9c5d3dec 100644 (file)
@@ -7,10 +7,10 @@
  */
 package org.opendaylight.protocol.bgp.testtool;
 
-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.yangtools.yang.binding.Notification;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -35,7 +35,7 @@ public class SpeakerSessionListener implements BGPSessionListener {
        }
 
        @Override
-       public void onMessage(final BGPSession session, final BGPMessage message) {
+       public void onMessage(final BGPSession session, final Notification message) {
                logger.info("Server: Message received: {}", message);
                // this.d.stop();
        }