From: Dana Kutenicsova Date: Sat, 28 Sep 2013 07:34:11 +0000 (+0200) Subject: Switched BGPMessage concept to yangtools.binding.Notification. X-Git-Tag: jenkins-bgpcep-bulk-release-prepare-only-1~237^2~241 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=commitdiff_plain;h=ab025f573547e9cd0cf8be24a2b2e8cefc26c6f6;p=bgpcep.git Switched BGPMessage concept to yangtools.binding.Notification. Change-Id: Iad4b2e15f8093cd8d4ff926be619a6ea9b7d65e6 Signed-off-by: Dana Kutenicsova --- 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 index 78999dd39d..0000000000 --- a/bgp/parser-api/src/main/java/org/opendaylight/protocol/bgp/parser/BGPMessage.java +++ /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 { - -} diff --git a/bgp/parser-api/src/main/java/org/opendaylight/protocol/bgp/parser/BGPMessageFactory.java b/bgp/parser-api/src/main/java/org/opendaylight/protocol/bgp/parser/BGPMessageFactory.java index fe40691c96..1c25f27768 100644 --- a/bgp/parser-api/src/main/java/org/opendaylight/protocol/bgp/parser/BGPMessageFactory.java +++ b/bgp/parser-api/src/main/java/org/opendaylight/protocol/bgp/parser/BGPMessageFactory.java @@ -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 { +public interface BGPMessageFactory extends ProtocolMessageFactory { } diff --git a/bgp/parser-api/src/main/java/org/opendaylight/protocol/bgp/parser/BGPSession.java b/bgp/parser-api/src/main/java/org/opendaylight/protocol/bgp/parser/BGPSession.java index af173644ce..fcfd73c808 100644 --- a/bgp/parser-api/src/main/java/org/opendaylight/protocol/bgp/parser/BGPSession.java +++ b/bgp/parser-api/src/main/java/org/opendaylight/protocol/bgp/parser/BGPSession.java @@ -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 { +public interface BGPSession extends ProtocolSession { public Set getAdvertisedTableTypes(); } diff --git a/bgp/parser-api/src/main/java/org/opendaylight/protocol/bgp/parser/BGPSessionListener.java b/bgp/parser-api/src/main/java/org/opendaylight/protocol/bgp/parser/BGPSessionListener.java index cc38f72dd8..8a4510f315 100644 --- a/bgp/parser-api/src/main/java/org/opendaylight/protocol/bgp/parser/BGPSessionListener.java +++ b/bgp/parser-api/src/main/java/org/opendaylight/protocol/bgp/parser/BGPSessionListener.java @@ -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 { +public interface BGPSessionListener extends SessionListener { } diff --git a/bgp/parser-api/src/main/java/org/opendaylight/protocol/bgp/parser/BGPUpdateEvent.java b/bgp/parser-api/src/main/java/org/opendaylight/protocol/bgp/parser/BGPUpdateEvent.java index 2d37917a6f..e381366372 100644 --- a/bgp/parser-api/src/main/java/org/opendaylight/protocol/bgp/parser/BGPUpdateEvent.java +++ b/bgp/parser-api/src/main/java/org/opendaylight/protocol/bgp/parser/BGPUpdateEvent.java @@ -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 { } diff --git a/bgp/parser-api/src/main/java/org/opendaylight/protocol/bgp/parser/BGPUpdateMessage.java b/bgp/parser-api/src/main/java/org/opendaylight/protocol/bgp/parser/BGPUpdateMessage.java index ef015cd58d..7bb7004e19 100644 --- a/bgp/parser-api/src/main/java/org/opendaylight/protocol/bgp/parser/BGPUpdateMessage.java +++ b/bgp/parser-api/src/main/java/org/opendaylight/protocol/bgp/parser/BGPUpdateMessage.java @@ -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. * diff --git a/bgp/parser-api/src/main/java/org/opendaylight/protocol/bgp/parser/message/BGPKeepAliveMessage.java b/bgp/parser-api/src/main/java/org/opendaylight/protocol/bgp/parser/message/BGPKeepAliveMessage.java index af199a5469..bf0370ef38 100644 --- a/bgp/parser-api/src/main/java/org/opendaylight/protocol/bgp/parser/message/BGPKeepAliveMessage.java +++ b/bgp/parser-api/src/main/java/org/opendaylight/protocol/bgp/parser/message/BGPKeepAliveMessage.java @@ -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 BGP KeepAlive message */ -public final class BGPKeepAliveMessage implements BGPMessage { - - private static final long serialVersionUID = 5469664138660829255L; +public final class BGPKeepAliveMessage implements Notification { /** * Creates a BGP KeepAlive message. diff --git a/bgp/parser-api/src/main/java/org/opendaylight/protocol/bgp/parser/message/BGPNotificationMessage.java b/bgp/parser-api/src/main/java/org/opendaylight/protocol/bgp/parser/message/BGPNotificationMessage.java index 7943aa38bf..a4eb7aedaa 100644 --- a/bgp/parser-api/src/main/java/org/opendaylight/protocol/bgp/parser/message/BGPNotificationMessage.java +++ b/bgp/parser-api/src/main/java/org/opendaylight/protocol/bgp/parser/message/BGPNotificationMessage.java @@ -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 BGP Notification Message */ -public final class BGPNotificationMessage implements BGPMessage { - - private static final long serialVersionUID = -5860147919167775673L; +public final class BGPNotificationMessage implements Notification { private final BGPError error; diff --git a/bgp/parser-api/src/main/java/org/opendaylight/protocol/bgp/parser/message/BGPOpenMessage.java b/bgp/parser-api/src/main/java/org/opendaylight/protocol/bgp/parser/message/BGPOpenMessage.java index dab318e215..03e535b256 100644 --- a/bgp/parser-api/src/main/java/org/opendaylight/protocol/bgp/parser/message/BGPOpenMessage.java +++ b/bgp/parser-api/src/main/java/org/opendaylight/protocol/bgp/parser/message/BGPOpenMessage.java @@ -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 BGP Open Message */ -public final class BGPOpenMessage implements BGPMessage { - - private static final long serialVersionUID = -3507481736478860117L; +public final class BGPOpenMessage implements Notification { /** * Current BGP version. diff --git a/bgp/parser-api/src/test/java/org/opendaylight/protocol/bgp/parser/APITest.java b/bgp/parser-api/src/test/java/org/opendaylight/protocol/bgp/parser/APITest.java index 95a01781b3..43d583f8d6 100644 --- a/bgp/parser-api/src/test/java/org/opendaylight/protocol/bgp/parser/APITest.java +++ b/bgp/parser-api/src/test/java/org/opendaylight/protocol/bgp/parser/APITest.java @@ -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()); } } diff --git a/bgp/parser-impl/src/main/java/org/opendaylight/protocol/bgp/parser/impl/BGPMessageFactoryImpl.java b/bgp/parser-impl/src/main/java/org/opendaylight/protocol/bgp/parser/impl/BGPMessageFactoryImpl.java index 21dc7c8a97..2a1bbbdefe 100644 --- a/bgp/parser-impl/src/main/java/org/opendaylight/protocol/bgp/parser/impl/BGPMessageFactoryImpl.java +++ b/bgp/parser-impl/src/main/java/org/opendaylight/protocol/bgp/parser/impl/BGPMessageFactoryImpl.java @@ -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 parse(final byte[] bytes) throws DeserializerException, DocumentedException { + public List 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."); } diff --git a/bgp/parser-mock/src/main/java/org/opendaylight/protocol/bgp/parser/mock/BGPMessageParserMock.java b/bgp/parser-mock/src/main/java/org/opendaylight/protocol/bgp/parser/mock/BGPMessageParserMock.java index abe4ea6df4..868d4c1b7a 100644 --- a/bgp/parser-mock/src/main/java/org/opendaylight/protocol/bgp/parser/mock/BGPMessageParserMock.java +++ b/bgp/parser-mock/src/main/java/org/opendaylight/protocol/bgp/parser/mock/BGPMessageParserMock.java @@ -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 { - private final Map> messages; +public class BGPMessageParserMock implements ProtocolMessageFactory { + private final Map> messages; /** * @param updateMessages Map */ - public BGPMessageParserMock(final Map> messages) { + public BGPMessageParserMock(final Map> messages) { this.messages = messages; } @Override - public List parse(final byte[] bytes) throws DeserializerException, DocumentedException { - final List ret = this.messages.get(bytes); + public List parse(final byte[] bytes) throws DeserializerException, DocumentedException { + final List ret = this.messages.get(bytes); if (ret == null) { throw new IllegalArgumentException("Undefined message encountered"); } @@ -40,7 +40,7 @@ public class BGPMessageParserMock implements ProtocolMessageFactory } @Override - public byte[] put(final BGPMessage msg) { + public byte[] put(final Notification msg) { // nothing return null; } diff --git a/bgp/parser-mock/src/test/java/org/opendaylight/protocol/bgp/parser/mock/BGPMessageParserMockTest.java b/bgp/parser-mock/src/test/java/org/opendaylight/protocol/bgp/parser/mock/BGPMessageParserMockTest.java index 7d7ce3d22f..148d62290b 100644 --- a/bgp/parser-mock/src/test/java/org/opendaylight/protocol/bgp/parser/mock/BGPMessageParserMockTest.java +++ b/bgp/parser-mock/src/test/java/org/opendaylight/protocol/bgp/parser/mock/BGPMessageParserMockTest.java @@ -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> updateMap = Maps.newHashMap(); + final Map> 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> updateMap = Maps.newHashMap(); + final Map> 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> openMap = Maps.newHashMap(); + final Map> openMap = Maps.newHashMap(); final Set 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); diff --git a/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/BGPHandlerFactory.java b/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/BGPHandlerFactory.java index 0e2b9ceed8..8ffbd94525 100644 --- a/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/BGPHandlerFactory.java +++ b/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/BGPHandlerFactory.java @@ -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 { - private final ProtocolMessageEncoder encoder; +public class BGPHandlerFactory extends ProtocolHandlerFactory { + private final ProtocolMessageEncoder encoder; public BGPHandlerFactory(final BGPMessageFactory msgFactory) { super(msgFactory); - this.encoder = new ProtocolMessageEncoder(this.msgFactory); + this.encoder = new ProtocolMessageEncoder(this.msgFactory); } @Override @@ -33,6 +33,6 @@ public class BGPHandlerFactory extends ProtocolHandlerFactory { @Override public ChannelHandler[] getDecoders() { - return new ChannelHandler[] { new BGPMessageHeaderDecoder(), new ProtocolMessageDecoder(this.msgFactory) }; + return new ChannelHandler[] { new BGPMessageHeaderDecoder(), new ProtocolMessageDecoder(this.msgFactory) }; } } diff --git a/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/BGPPeer.java b/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/BGPPeer.java index a56a2c05cf..16e4e71f2c 100644 --- a/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/BGPPeer.java +++ b/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/BGPPeer.java @@ -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()); diff --git a/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/BGPSessionImpl.java b/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/BGPSessionImpl.java index 65bb948121..9a9139db5d 100644 --- a/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/BGPSessionImpl.java +++ b/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/BGPSessionImpl.java @@ -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 implements BGPSession { +public class BGPSessionImpl extends AbstractProtocolSession implements BGPSession { private static final Logger logger = LoggerFactory.getLogger(BGPSessionImpl.class); @@ -54,11 +54,9 @@ public class BGPSessionImpl extends AbstractProtocolSession 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 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 implemen } } - void sendMessage(final BGPMessage msg) { + void sendMessage(final Notification msg) { try { this.channel.writeAndFlush(msg); this.lastMessageSentAt = System.nanoTime(); diff --git a/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/BGPSessionNegotiator.java b/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/BGPSessionNegotiator.java index a1b9aa529e..3ee9ef04c5 100644 --- a/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/BGPSessionNegotiator.java +++ b/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/BGPSessionNegotiator.java @@ -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 { +public final class BGPSessionNegotiator extends AbstractSessionNegotiator { // 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 { +public final class BGPSessionNegotiatorFactory implements SessionNegotiatorFactory { private final BGPSessionPreferences initialPrefs; private final Timer timer; @@ -25,6 +25,6 @@ public final class BGPSessionNegotiatorFactory implements SessionNegotiatorFacto @Override public SessionNegotiator getSessionNegotiator(final SessionListenerFactory factory, final Channel channel, final Promise promise) { - return new BGPSessionNegotiator(timer, promise, channel, initialPrefs, factory.getSessionListener()); + return new BGPSessionNegotiator(this.timer, promise, channel, this.initialPrefs, factory.getSessionListener()); } } diff --git a/bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/FSMTest.java b/bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/FSMTest.java index 421bc8a5b1..0755248413 100644 --- a/bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/FSMTest.java +++ b/bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/FSMTest.java @@ -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 receivedMsgs = Lists.newArrayList(); + private final List 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()); } diff --git a/bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/ParserTest.java b/bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/ParserTest.java index 3916101fb1..cfd4c3c9e3 100644 --- a/bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/ParserTest.java +++ b/bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/ParserTest.java @@ -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 factory = new BGPMessageFactoryImpl(); + final ProtocolMessageFactory 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()); diff --git a/bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/SimpleSessionListener.java b/bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/SimpleSessionListener.java index aea49383b6..d6b6b7d288 100644 --- a/bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/SimpleSessionListener.java +++ b/bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/SimpleSessionListener.java @@ -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 listMsg = Lists.newArrayList(); + private final List listMsg = Lists.newArrayList(); public boolean up = false; @@ -31,12 +31,12 @@ public class SimpleSessionListener implements BGPSessionListener { public boolean down = false; - public List getListMsg() { + public List 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); } diff --git a/bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/SpeakerSessionListener.java b/bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/SpeakerSessionListener.java index 5574a238b1..92f3d6138e 100644 --- a/bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/SpeakerSessionListener.java +++ b/bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/SpeakerSessionListener.java @@ -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 messages = Lists.newArrayList(); + public List 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); } diff --git a/bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/SpeakerSessionMock.java b/bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/SpeakerSessionMock.java index 7589938c07..fa87011081 100644 --- a/bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/SpeakerSessionMock.java +++ b/bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/SpeakerSessionMock.java @@ -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); } diff --git a/bgp/rib-mock/src/main/java/org/opendaylight/protocol/bgp/rib/mock/BGPMock.java b/bgp/rib-mock/src/main/java/org/opendaylight/protocol/bgp/rib/mock/BGPMock.java index d1122d5245..afe7ad008f 100644 --- a/bgp/rib-mock/src/main/java/org/opendaylight/protocol/bgp/rib/mock/BGPMock.java +++ b/bgp/rib-mock/src/main/java/org/opendaylight/protocol/bgp/rib/mock/BGPMock.java @@ -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 allPreviousByteMessages; - private final List allPreviousBGPMessages; + private final List allPreviousBGPMessages; private final EventBus eventBus; @GuardedBy("this") private final List openRegistrations = Lists.newLinkedList(); @@ -53,9 +53,9 @@ public final class BGPMock implements BGP, Closeable { this.allPreviousBGPMessages = this.parsePrevious(this.allPreviousByteMessages); } - private List parsePrevious(final List msgs) { - final List messages = Lists.newArrayList(); - final ProtocolMessageFactory parser = new BGPMessageFactoryImpl(); + private List parsePrevious(final List msgs) { + final List messages = Lists.newArrayList(); + final ProtocolMessageFactory 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 registerUpdateListener(final BGPSessionListener listener, final ReconnectStrategy strategy) { + public synchronized ListenerRegistration 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 messages) { - for (final BGPMessage message : messages) { + public synchronized void insertMessages(final List 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); } diff --git a/bgp/rib-mock/src/main/java/org/opendaylight/protocol/bgp/rib/mock/EventBusRegistration.java b/bgp/rib-mock/src/main/java/org/opendaylight/protocol/bgp/rib/mock/EventBusRegistration.java index 7013d3def0..c3a642b5a8 100644 --- a/bgp/rib-mock/src/main/java/org/opendaylight/protocol/bgp/rib/mock/EventBusRegistration.java +++ b/bgp/rib-mock/src/main/java/org/opendaylight/protocol/bgp/rib/mock/EventBusRegistration.java @@ -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 { private boolean closed = false; public static EventBusRegistration createAndRegister(final EventBus eventBus, final BGPSessionListener listener, - final List allPreviousMessages) { + final List allPreviousMessages) { final EventBusRegistration instance = new EventBusRegistration(eventBus, listener, allPreviousMessages); eventBus.register(instance); return instance; } - private EventBusRegistration(final EventBus eventBus, final BGPSessionListener listener, final List allPreviousMessages) { + private EventBusRegistration(final EventBus eventBus, final BGPSessionListener listener, final List 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 { 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) { diff --git a/bgp/rib-mock/src/test/java/org/opendaylight/protocol/bgp/rib/mock/BGPListenerMock.java b/bgp/rib-mock/src/test/java/org/opendaylight/protocol/bgp/rib/mock/BGPListenerMock.java index 3cae9787a5..e46a9a6369 100644 --- a/bgp/rib-mock/src/test/java/org/opendaylight/protocol/bgp/rib/mock/BGPListenerMock.java +++ b/bgp/rib-mock/src/test/java/org/opendaylight/protocol/bgp/rib/mock/BGPListenerMock.java @@ -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 buffer = Collections.synchronizedList(new ArrayList()); + private final List buffer = Collections.synchronizedList(new ArrayList()); private boolean connected = false; - protected List getBuffer() { + protected List 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); } diff --git a/bgp/testtool/src/main/java/org/opendaylight/protocol/bgp/testtool/TestingListener.java b/bgp/testtool/src/main/java/org/opendaylight/protocol/bgp/testtool/TestingListener.java index 37cb37bd1d..617797df0b 100644 --- a/bgp/testtool/src/main/java/org/opendaylight/protocol/bgp/testtool/TestingListener.java +++ b/bgp/testtool/src/main/java/org/opendaylight/protocol/bgp/testtool/TestingListener.java @@ -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()); } diff --git a/bgp/testtool/src/test/java/org/opendaylight/protocol/bgp/testtool/BGPSpeakerMock.java b/bgp/testtool/src/test/java/org/opendaylight/protocol/bgp/testtool/BGPSpeakerMock.java index e5d11fd765..b4a529205f 100644 --- a/bgp/testtool/src/test/java/org/opendaylight/protocol/bgp/testtool/BGPSpeakerMock.java +++ b/bgp/testtool/src/test/java/org/opendaylight/protocol/bgp/testtool/BGPSpeakerMock.java @@ -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, L extends SessionListener> extends -AbstractDispatcher { +public class BGPSpeakerMock, L extends SessionListener> extends AbstractDispatcher { private final SessionNegotiatorFactory negotiatorFactory; private final ProtocolHandlerFactory factory; @@ -52,9 +51,10 @@ AbstractDispatcher { @Override public void initializeChannel(final SocketChannel ch, final Promise 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 { final BGPSessionPreferences prefs = new BGPSessionProposalImpl((short) 90, new AsNumber((long) 25), IPv4.FAMILY.addressForString("127.0.0.2")).getProposal(); - final SessionNegotiatorFactory snf = new BGPSessionNegotiatorFactory(new HashedWheelTimer(), prefs); + final SessionNegotiatorFactory snf = new BGPSessionNegotiatorFactory(new HashedWheelTimer(), prefs); - final BGPSpeakerMock mock = new BGPSpeakerMock(snf, new BGPHandlerFactory(new BGPMessageFactoryImpl()), new DefaultPromise(GlobalEventExecutor.INSTANCE)); + final BGPSpeakerMock mock = new BGPSpeakerMock(snf, new BGPHandlerFactory(new BGPMessageFactoryImpl()), new DefaultPromise(GlobalEventExecutor.INSTANCE)); mock.createServer(new InetSocketAddress("127.0.0.2", 12345), f); } diff --git a/bgp/testtool/src/test/java/org/opendaylight/protocol/bgp/testtool/SpeakerSessionListener.java b/bgp/testtool/src/test/java/org/opendaylight/protocol/bgp/testtool/SpeakerSessionListener.java index 22852c049d..edc271ca98 100644 --- a/bgp/testtool/src/test/java/org/opendaylight/protocol/bgp/testtool/SpeakerSessionListener.java +++ b/bgp/testtool/src/test/java/org/opendaylight/protocol/bgp/testtool/SpeakerSessionListener.java @@ -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(); }