Class StrictBGPPeerRegistry
java.lang.Object
org.opendaylight.protocol.bgp.rib.impl.StrictBGPPeerRegistry
- All Implemented Interfaces:
AutoCloseable
,BGPPeerRegistry
@Singleton
@MetaInfServices
public final class StrictBGPPeerRegistry
extends Object
implements BGPPeerRegistry, AutoCloseable
BGP peer registry that allows only 1 session per BGP peer. If a second session with peer is established, one of
the sessions will be dropped. The session with lower source BGP id will be dropped. This class is thread-safe.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addPeer
(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddressNoZone oldIp, BGPSessionListener peer, BGPSessionPreferences preferences) Add configured peer, its IP address and preferences.void
close()
static org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddressNoZone
getIpAddress
(SocketAddress socketAddress) Creates IpAddress from SocketAddress.getPeer
(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddressNoZone ip, org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4AddressNoZone sourceId, org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4AddressNoZone remoteId, Open openObj) Get configured peer after BGP session was successfully established.getPeerPreferences
(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddressNoZone ip) Get preferences for a remote peer.boolean
isPeerConfigured
(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddressNoZone oldIp) Check whether peer on provided IP address is present in this registry.org.opendaylight.yangtools.concepts.Registration
Register PeerRegistryListener, which listens to the changes in peer registry (add peer, remove peer).org.opendaylight.yangtools.concepts.Registration
Register PeerRegistrySessionListener, which listens to the changes in sessions of peers in peer registry (create session, remove session).void
removePeer
(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddressNoZone oldIp) Remove configured peer from registry.void
removePeerSession
(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddressNoZone oldIp) Remove peer session from registry.toString()
void
updatePeerPreferences
(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddressNoZone address, BGPSessionPreferences preferences) Set new preferences.
-
Constructor Details
-
StrictBGPPeerRegistry
@Inject public StrictBGPPeerRegistry()
-
-
Method Details
-
addPeer
public void addPeer(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddressNoZone oldIp, BGPSessionListener peer, BGPSessionPreferences preferences) Description copied from interface:BGPPeerRegistry
Add configured peer, its IP address and preferences. To be used when a BGP session is established.- Specified by:
addPeer
in interfaceBGPPeerRegistry
- Parameters:
oldIp
- address of remote peerpeer
- configured peer as BGPSessionListenerpreferences
- session preferences for configured peer
-
removePeer
public void removePeer(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddressNoZone oldIp) Description copied from interface:BGPPeerRegistry
Remove configured peer from registry.- Specified by:
removePeer
in interfaceBGPPeerRegistry
- Parameters:
oldIp
- address of remote peer
-
removePeerSession
public void removePeerSession(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddressNoZone oldIp) Description copied from interface:BGPPeerRegistry
Remove peer session from registry.- Specified by:
removePeerSession
in interfaceBGPPeerRegistry
- Parameters:
oldIp
- address of remote peer
-
isPeerConfigured
public boolean isPeerConfigured(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddressNoZone oldIp) Description copied from interface:BGPPeerRegistry
Check whether peer on provided IP address is present in this registry.- Specified by:
isPeerConfigured
in interfaceBGPPeerRegistry
- Parameters:
oldIp
- address of remote peer- Returns:
- true if peer is present false otherwise
-
getPeer
public BGPSessionListener getPeer(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddressNoZone ip, org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4AddressNoZone sourceId, org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4AddressNoZone remoteId, Open openObj) throws BGPDocumentedException Description copied from interface:BGPPeerRegistry
Get configured peer after BGP session was successfully established. Called by negotiators.- Specified by:
getPeer
in interfaceBGPPeerRegistry
- Parameters:
ip
- address of remote peersourceId
- BGP ID of peer that initiated the session (current device or remote peer)remoteId
- BGP ID of peer that accepted the session (current device or remote peer)openObj
- remote Open message- Returns:
- BGPSessionListener configured Peer as BGP listener
- Throws:
BGPDocumentedException
- if session establishment cannot be finished successfully
-
getPeerPreferences
public BGPSessionPreferences getPeerPreferences(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddressNoZone ip) Description copied from interface:BGPPeerRegistry
Get preferences for a remote peer.- Specified by:
getPeerPreferences
in interfaceBGPPeerRegistry
- Parameters:
ip
- address of remote peer- Returns:
- BGP session preferences for configured peer
-
getIpAddress
public static org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddressNoZone getIpAddress(SocketAddress socketAddress) Creates IpAddress from SocketAddress. Only InetSocketAddress is accepted with inner address: Inet4Address and Inet6Address.- Parameters:
socketAddress
- socket address to transform- Returns:
- IpAddress equivalent to given socket address
- Throws:
IllegalArgumentException
- if submitted socket address is not InetSocketAddress[ipv4 | ipv6]
-
close
@PreDestroy public void close()- Specified by:
close
in interfaceAutoCloseable
-
toString
-
registerPeerRegisterListener
public org.opendaylight.yangtools.concepts.Registration registerPeerRegisterListener(PeerRegistryListener listener) Description copied from interface:BGPPeerRegistry
Register PeerRegistryListener, which listens to the changes in peer registry (add peer, remove peer). After registration, an initial drop is provided by calling onPeerAdded().- Specified by:
registerPeerRegisterListener
in interfaceBGPPeerRegistry
- Parameters:
listener
- The PeerRegistryListener to be registered.- Returns:
- Registration ticked, used for closing of registration.
-
registerPeerSessionListener
public org.opendaylight.yangtools.concepts.Registration registerPeerSessionListener(PeerRegistrySessionListener listener) Description copied from interface:BGPPeerRegistry
Register PeerRegistrySessionListener, which listens to the changes in sessions of peers in peer registry (create session, remove session). After registration, an initial drop is provided by calling onSessionCreated().- Specified by:
registerPeerSessionListener
in interfaceBGPPeerRegistry
- Parameters:
listener
- The PeerRegistrySessionListener to be registered.- Returns:
- Registration ticked, used for closing of registration.
-
updatePeerPreferences
public void updatePeerPreferences(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddressNoZone address, BGPSessionPreferences preferences) Description copied from interface:BGPPeerRegistry
Set new preferences. In case of graceful restart execution we need to send updated GracefulRestartCapability when sesison re-establish, information which tables where preserved during restart will change. Note that this method only updates preferences of already registered peer. To add new peer to registry use addPeer().- Specified by:
updatePeerPreferences
in interfaceBGPPeerRegistry
- Parameters:
address
- of neighborpreferences
- to send in OPEN message
-