import org.opendaylight.protocol.bgp.rib.impl.StrictBGPPeerRegistry;
import org.opendaylight.protocol.bgp.rib.impl.spi.BGPPeerRegistry;
import org.opendaylight.protocol.bgp.rib.impl.spi.BGPSessionPreferences;
-import org.opendaylight.protocol.bgp.rib.impl.spi.ReusableBGPPeer;
import org.opendaylight.protocol.bgp.rib.spi.BGPSessionListener;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;
}
@Override
- public void addPeer(final IpAddress ip, final ReusableBGPPeer peer, final BGPSessionPreferences preferences) {
+ public void addPeer(final IpAddress ip, final BGPSessionListener peer, final BGPSessionPreferences preferences) {
this.global.addPeer(ip, peer, preferences);
}
import org.opendaylight.protocol.bgp.rib.impl.spi.BGPSessionStatistics;
import org.opendaylight.protocol.bgp.rib.impl.spi.RIB;
import org.opendaylight.protocol.bgp.rib.impl.spi.RIBSupportContext;
-import org.opendaylight.protocol.bgp.rib.impl.spi.ReusableBGPPeer;
import org.opendaylight.protocol.bgp.rib.spi.BGPSession;
+import org.opendaylight.protocol.bgp.rib.spi.BGPSessionListener;
import org.opendaylight.protocol.bgp.rib.spi.BGPTerminationReason;
import org.opendaylight.protocol.bgp.rib.spi.Peer;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Prefix;
* Class representing a peer. We have a single instance for each peer, which provides translation from BGP events into
* RIB actions.
*/
-public class BGPPeer implements ReusableBGPPeer, Peer, AutoCloseable, BGPPeerRuntimeMXBean, TransactionChainListener {
+public class BGPPeer implements BGPSessionListener, Peer, AutoCloseable, BGPPeerRuntimeMXBean, TransactionChainListener {
private static final Logger LOG = LoggerFactory.getLogger(BGPPeer.class);
import org.opendaylight.protocol.bgp.parser.impl.message.open.As4CapabilityHandler;
import org.opendaylight.protocol.bgp.rib.impl.spi.BGPPeerRegistry;
import org.opendaylight.protocol.bgp.rib.impl.spi.BGPSessionPreferences;
-import org.opendaylight.protocol.bgp.rib.impl.spi.ReusableBGPPeer;
import org.opendaylight.protocol.bgp.rib.spi.BGPSessionListener;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.AsNumber;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
public static final StrictBGPPeerRegistry GLOBAL = new StrictBGPPeerRegistry();
@GuardedBy("this")
- private final Map<IpAddress, ReusableBGPPeer> peers = Maps.newHashMap();
+ private final Map<IpAddress, BGPSessionListener> peers = Maps.newHashMap();
@GuardedBy("this")
private final Map<IpAddress, BGPSessionId> sessionIds = Maps.newHashMap();
@GuardedBy("this")
private final Map<IpAddress, BGPSessionPreferences> peerPreferences = Maps.newHashMap();
@Override
- public synchronized void addPeer(final IpAddress ip, final ReusableBGPPeer peer, final BGPSessionPreferences preferences) {
+ public synchronized void addPeer(final IpAddress ip, final BGPSessionListener peer, final BGPSessionPreferences preferences) {
Preconditions.checkNotNull(ip);
Preconditions.checkArgument(!this.peers.containsKey(ip), "Peer for %s already present", ip);
this.peers.put(ip, Preconditions.checkNotNull(peer));
* Add configured peer, its IP address and preferences. To be used when a BGP session is established.
*
* @param ip address of remote peer
- * @param peer configured peer as ReusableBGPPeer
+ * @param peer configured peer as BGPSessionListener
* @param prefs session preferences for configured peer
*/
- void addPeer(IpAddress ip, ReusableBGPPeer peer, BGPSessionPreferences prefs);
+ void addPeer(IpAddress ip, BGPSessionListener peer, BGPSessionPreferences prefs);
/**
* Remove configured peer from registry.
+++ /dev/null
-/*
- * Copyright (c) 2014 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.rib.impl.spi;
-
-import org.opendaylight.protocol.bgp.rib.spi.BGPSessionListener;
-
-public interface ReusableBGPPeer extends BGPSessionListener {
-
- // TODO merge with BGPSessionListener ?
-
- void releaseConnection();
-
-}
import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableLeafSetNodeBuilder;
import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableUnkeyedListNodeBuilder;
-/**
- * Created by cgasparini on 10.6.2015.
- */
public class FromExternalImportPolicyTest {
private static final QName DATA_QNAME = QName.cachedReference(QName.create("urn:opendaylight:params:xml:ns:yang:bgp-inet", "2013-09-19", "attributes"));
import com.google.common.collect.Lists;
import java.util.List;
-import org.opendaylight.protocol.bgp.rib.impl.spi.ReusableBGPPeer;
import org.opendaylight.protocol.bgp.rib.spi.BGPSession;
+import org.opendaylight.protocol.bgp.rib.spi.BGPSessionListener;
import org.opendaylight.protocol.bgp.rib.spi.BGPTerminationReason;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.rib.TablesKey;
import org.opendaylight.yangtools.yang.binding.Notification;
/**
* Listener for the client.
*/
-public class SimpleSessionListener implements ReusableBGPPeer {
+public class SimpleSessionListener implements BGPSessionListener {
private final List<Notification> listMsg = Lists.newArrayList();
+++ /dev/null
-/*
- * 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.rib.impl;
-
-import com.google.common.collect.Lists;
-import java.util.List;
-import java.util.Set;
-import org.opendaylight.protocol.bgp.rib.spi.BGPSession;
-import org.opendaylight.protocol.bgp.rib.spi.BGPSessionListener;
-import org.opendaylight.protocol.bgp.rib.spi.BGPTerminationReason;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev130919.BgpTableType;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.rib.TablesKey;
-import org.opendaylight.yangtools.yang.binding.Notification;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Listener for the BGP Speaker.
- */
-public class SpeakerSessionListener implements BGPSessionListener {
-
- public List<Notification> messages = Lists.newArrayList();
-
- public boolean up = false;
-
- public Set<BgpTableType> types;
-
- private static final Logger LOG = LoggerFactory.getLogger(SpeakerSessionListener.class);
-
- public SpeakerSessionListener() {
- }
-
- @Override
- public void onMessage(final BGPSession session, final Notification message) {
- LOG.debug("Received message: {} {}", message.getClass(), message);
- this.messages.add(message);
- }
-
- @Override
- public synchronized void onSessionUp(final BGPSession session) {
- LOG.debug("Session up.");
- this.up = true;
- this.types = session.getAdvertisedTableTypes();
- this.notifyAll();
- }
-
- @Override
- public void onSessionDown(final BGPSession session, final Exception e) {
- LOG.debug("Session down.");
- this.up = false;
- }
-
- @Override
- public void onSessionTerminated(final BGPSession session, final BGPTerminationReason cause) {
- LOG.debug("Session terminated. Cause : {}", cause.toString());
- this.up = false;
- }
-
- @Override
- public boolean isSessionActive() {
- return true;
- }
-
- @Override
- public void markUptodate(final TablesKey tablesKey) {
- LOG.debug("Table marked as up-to-date {}", tablesKey);
- }
-}
+++ /dev/null
-/*
- * 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.rib.impl;
-
-import static org.mockito.Mockito.mock;
-
-import io.netty.channel.Channel;
-import org.opendaylight.protocol.bgp.rib.spi.BGPSessionListener;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.OpenBuilder;
-import org.opendaylight.yangtools.yang.binding.Notification;
-
-/**
- * Mock of the BGP speakers session.
- */
-public class SpeakerSessionMock extends BGPSessionImpl {
-
- private final BGPSessionListener client;
-
- SpeakerSessionMock(final BGPSessionListener listener, final BGPSessionListener client) {
- super(listener, mock(Channel.class), new OpenBuilder().setHoldTimer(5).build(), 10, null);
- this.client = client;
- }
-
- @Override
- public void writeAndFlush(final Notification msg) {
- this.setLastMessageSentAt(System.nanoTime());
- this.client.onMessage(this, msg);
- }
-}
import org.opendaylight.protocol.bgp.parser.BGPDocumentedException;
import org.opendaylight.protocol.bgp.parser.BGPError;
import org.opendaylight.protocol.bgp.rib.impl.spi.BGPSessionPreferences;
-import org.opendaylight.protocol.bgp.rib.impl.spi.ReusableBGPPeer;
import org.opendaylight.protocol.bgp.rib.spi.BGPSessionListener;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.AsNumber;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
private static final IpAddress REMOTE_IP = new IpAddress(FROM);
private static final Ipv4Address TO = new Ipv4Address("255.255.255.255");
- private final ReusableBGPPeer peer1 = getMockSession();
+ private final BGPSessionListener peer1 = getMockSession();
private final Open classicOpen = createOpen(TO, LOCAL_AS);
private StrictBGPPeerRegistry peerRegistry;
private BGPSessionPreferences mockPreferences;
this.mockPreferences = new BGPSessionPreferences(LOCAL_AS, 1, new Ipv4Address("0.0.0.1"), LOCAL_AS, Collections.<BgpParameters> emptyList());
}
- private static ReusableBGPPeer getMockSession() {
- final ReusableBGPPeer mock = Mockito.mock(ReusableBGPPeer.class);
+ private static BGPSessionListener getMockSession() {
+ final BGPSessionListener mock = Mockito.mock(BGPSessionListener.class);
Mockito.doNothing().when(mock).releaseConnection();
return mock;
}
final IpAddress remoteIp2 = new IpAddress(to2);
this.peerRegistry.addPeer(REMOTE_IP, this.peer1, this.mockPreferences);
- final ReusableBGPPeer session2 = getMockSession();
+ final BGPSessionListener session2 = getMockSession();
this.peerRegistry.addPeer(remoteIp2, session2, this.mockPreferences);
final BGPSessionListener returnedSession1 = this.peerRegistry.getPeer(REMOTE_IP, FROM, TO, this.classicOpen);
+++ /dev/null
-/*
- * 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.rib.mock;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import org.opendaylight.protocol.bgp.rib.spi.BGPSession;
-import org.opendaylight.protocol.bgp.rib.spi.BGPSessionListener;
-import org.opendaylight.protocol.bgp.rib.spi.BGPTerminationReason;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.rib.TablesKey;
-import org.opendaylight.yangtools.yang.binding.Notification;
-
-/**
- * Mock implementation of {@link BGPSessionListener} for testing purposes.
- */
-public final class BGPListenerMock implements BGPSessionListener {
- private final List<Notification> buffer = Collections.synchronizedList(new ArrayList<Notification>());
- private boolean connected = false;
-
- protected List<Notification> getBuffer() {
- return this.buffer;
- }
-
- protected boolean isConnected() {
- return this.connected;
- }
-
- @Override
- public void onMessage(final BGPSession session, final Notification message) {
- this.buffer.add(message);
- }
-
- @Override
- public void onSessionUp(final BGPSession session) {
- this.connected = true;
- }
-
- @Override
- public void onSessionDown(final BGPSession session, final Exception e) {
- this.connected = false;
-
- }
-
- @Override
- public void onSessionTerminated(final BGPSession session, final BGPTerminationReason reason) {
- this.connected = false;
- }
-
- @Override
- public boolean isSessionActive() {
- return true;
- }
-
- @Override
- public void markUptodate(final TablesKey tablesKey) {
- }
-}
* @param notification Protocol message
*/
void onMessage(BGPSession session, Notification notification);
+
+ void releaseConnection();
}
import org.opendaylight.protocol.bgp.rib.impl.BGPSessionProposalImpl;
import org.opendaylight.protocol.bgp.rib.impl.StrictBGPPeerRegistry;
import org.opendaylight.protocol.bgp.rib.impl.spi.BGPSessionPreferences;
-import org.opendaylight.protocol.bgp.rib.impl.spi.ReusableBGPPeer;
+import org.opendaylight.protocol.bgp.rib.spi.BGPSessionListener;
import org.opendaylight.protocol.framework.NeverReconnectStrategy;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.AsNumber;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;
final Main m = new Main();
- final ReusableBGPPeer sessionListener = new TestingListener();
+ final BGPSessionListener sessionListener = new TestingListener();
final Map<Class<? extends AddressFamily>, Class<? extends SubsequentAddressFamily>> tables = new HashMap<>();
tables.put(Ipv4AddressFamily.class, UnicastSubsequentAddressFamily.class);
*/
package org.opendaylight.protocol.bgp.testtool;
-import org.opendaylight.protocol.bgp.rib.impl.spi.ReusableBGPPeer;
import org.opendaylight.protocol.bgp.rib.spi.BGPSession;
+import org.opendaylight.protocol.bgp.rib.spi.BGPSessionListener;
import org.opendaylight.protocol.bgp.rib.spi.BGPTerminationReason;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.rib.TablesKey;
import org.opendaylight.yangtools.yang.binding.Notification;
/**
* Testing BGP Listener.
*/
-public class TestingListener implements ReusableBGPPeer {
+public class TestingListener implements BGPSessionListener {
private static final Logger LOG = LoggerFactory.getLogger(TestingListener.class);
@Override
import org.opendaylight.protocol.bgp.rib.impl.BGPSessionProposalImpl;
import org.opendaylight.protocol.bgp.rib.impl.spi.BGPPeerRegistry;
import org.opendaylight.protocol.bgp.rib.impl.spi.BGPSessionPreferences;
-import org.opendaylight.protocol.bgp.rib.impl.spi.ReusableBGPPeer;
import org.opendaylight.protocol.bgp.rib.spi.BGPSessionListener;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.AsNumber;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
this.peerRegistry = new BGPPeerRegistry() {
@Override
- public void addPeer(final IpAddress ip, final ReusableBGPPeer peer, final BGPSessionPreferences prefs) {
+ public void addPeer(final IpAddress ip, final BGPSessionListener peer, final BGPSessionPreferences prefs) {
}
@Override
// this.d.stop();
}
+ @Override
+ public void releaseConnection() {
+
+ }
+
@Override
public boolean isSessionActive() {
return true;