Class BGPSessionImpl
- java.lang.Object
-
- io.netty.channel.ChannelHandlerAdapter
-
- io.netty.channel.ChannelInboundHandlerAdapter
-
- io.netty.channel.SimpleChannelInboundHandler<org.opendaylight.yangtools.yang.binding.Notification>
-
- org.opendaylight.protocol.bgp.rib.impl.BGPSessionImpl
-
- All Implemented Interfaces:
io.netty.channel.ChannelHandler,io.netty.channel.ChannelInboundHandler,AutoCloseable,BGPSessionStateProvider,BGPSession
public class BGPSessionImpl extends io.netty.channel.SimpleChannelInboundHandler<org.opendaylight.yangtools.yang.binding.Notification> implements BGPSession, BGPSessionStateProvider, AutoCloseable
-
-
Constructor Summary
Constructors Constructor Description BGPSessionImpl(BGPSessionListener listener, io.netty.channel.Channel channel, Open remoteOpen, int localHoldTimer, BGPPeerRegistry peerRegistry)BGPSessionImpl(BGPSessionListener listener, io.netty.channel.Channel channel, Open remoteOpen, BGPSessionPreferences localPreferences, BGPPeerRegistry peerRegistry)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T extends PeerConstraint>
voidaddDecoderConstraint(Class<T> constraintClass, T constraint)Add peer constraint to session pipeline decoder.protected com.google.common.base.MoreObjects.ToStringHelperaddToStringAttributes(com.google.common.base.MoreObjects.ToStringHelper toStringHelper)voidchannelInactive(io.netty.channel.ChannelHandlerContext ctx)protected voidchannelRead0(io.netty.channel.ChannelHandlerContext ctx, org.opendaylight.yangtools.yang.binding.Notification msg)voidclose()voidcloseWithoutMessage()Close peer session without sending Notification message.voidexceptionCaught(io.netty.channel.ChannelHandlerContext ctx, Throwable cause)List<AddressFamilies>getAdvertisedAddPathTableTypes()Return a list with Add Path tables supported advertised and corresponding SendReceive mode.GracefulRestartCapabilitygetAdvertisedGracefulRestartCapability()Return advertised graceful capability containing the list of tables which the peer has advertised to support, restart time and restarting flags.LlGracefulRestartCapabilitygetAdvertisedLlGracefulRestartCapability()Return advertised long-lived graceful capability containing the list of tables with stale time which the peer has advertised to support.Set<BgpTableType>getAdvertisedTableTypes()Return the list of tables which the peer has advertised to support.org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumbergetAsNumber()Return the AS number which the peer advertises.org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4AddressgetBgpId()Return the BGP router ID advertised by the peer.BGPSessionStategetBGPSessionState()BGP Operational Session State.BGPTimersStategetBGPTimersState()BGP Operational Timers State.BGPTransportStategetBGPTransportState()BGP Operational Transport State.ChannelOutputLimitergetLimiter()StategetState()voidhandlerAdded(io.netty.channel.ChannelHandlerContext ctx)voidregisterMessagesCounter(BGPMessagesListener bgpMessagesListener)Register BGP Operational Messages State Listener.io.netty.util.concurrent.ScheduledFuture<?>schedule(Runnable command, long delay, TimeUnit unit)Schedule a task to be executed in the context of the session handling thread.voidsetChannelExtMsgCoder(Open remoteOpen)Set the extend message coder for current channel.StringtoString()-
Methods inherited from class io.netty.channel.SimpleChannelInboundHandler
acceptInboundMessage, channelRead
-
Methods inherited from class io.netty.channel.ChannelInboundHandlerAdapter
channelActive, channelReadComplete, channelRegistered, channelUnregistered, channelWritabilityChanged, userEventTriggered
-
Methods inherited from class io.netty.channel.ChannelHandlerAdapter
ensureNotSharable, handlerRemoved, isSharable
-
-
-
-
Constructor Detail
-
BGPSessionImpl
public BGPSessionImpl(BGPSessionListener listener, io.netty.channel.Channel channel, Open remoteOpen, BGPSessionPreferences localPreferences, BGPPeerRegistry peerRegistry)
-
BGPSessionImpl
public BGPSessionImpl(BGPSessionListener listener, io.netty.channel.Channel channel, Open remoteOpen, int localHoldTimer, BGPPeerRegistry peerRegistry)
-
-
Method Detail
-
setChannelExtMsgCoder
public void setChannelExtMsgCoder(Open remoteOpen)
Set the extend message coder for current channel. The reason for separating this part from constructor is, in #channel.pipeline().replace(..), the invokeChannelRead() will be invoked after the original message coder handler got removed. And there is chance that before the session instance is fully initiated (constructor returns), a KeepAlive message arrived already in the channel buffer. Thus #AbstractBGPSessionNegotiator.handleMessage(..) gets invoked again and a deadlock is caused. A BGP final state machine error will happen as BGP negotiator is still in OPEN_SENT state as the session constructor hasn't returned yet.
-
close
public void close()
- Specified by:
closein interfaceAutoCloseable
-
closeWithoutMessage
public void closeWithoutMessage()
Description copied from interface:BGPSessionClose peer session without sending Notification message.- Specified by:
closeWithoutMessagein interfaceBGPSession
-
addToStringAttributes
protected com.google.common.base.MoreObjects.ToStringHelper addToStringAttributes(com.google.common.base.MoreObjects.ToStringHelper toStringHelper)
-
getAdvertisedTableTypes
public Set<BgpTableType> getAdvertisedTableTypes()
Description copied from interface:BGPSessionReturn the list of tables which the peer has advertised to support.- Specified by:
getAdvertisedTableTypesin interfaceBGPSession- Returns:
- Set of tables which it supports.
-
getAdvertisedAddPathTableTypes
public List<AddressFamilies> getAdvertisedAddPathTableTypes()
Description copied from interface:BGPSessionReturn a list with Add Path tables supported advertised and corresponding SendReceive mode.- Specified by:
getAdvertisedAddPathTableTypesin interfaceBGPSession- Returns:
- AddPathTables supported
-
getAdvertisedGracefulRestartCapability
public GracefulRestartCapability getAdvertisedGracefulRestartCapability()
Description copied from interface:BGPSessionReturn advertised graceful capability containing the list of tables which the peer has advertised to support, restart time and restarting flags.- Specified by:
getAdvertisedGracefulRestartCapabilityin interfaceBGPSession- Returns:
- Advertised graceful restart capability.
-
getAdvertisedLlGracefulRestartCapability
public LlGracefulRestartCapability getAdvertisedLlGracefulRestartCapability()
Description copied from interface:BGPSessionReturn advertised long-lived graceful capability containing the list of tables with stale time which the peer has advertised to support.- Specified by:
getAdvertisedLlGracefulRestartCapabilityin interfaceBGPSession- Returns:
- Advertised long-lived graceful restart capability.
-
getState
public State getState()
-
getBgpId
public final org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address getBgpId()
Description copied from interface:BGPSessionReturn the BGP router ID advertised by the peer.- Specified by:
getBgpIdin interfaceBGPSession- Returns:
- Peer's BGP Router ID.
-
getAsNumber
public final org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber getAsNumber()
Description copied from interface:BGPSessionReturn the AS number which the peer advertises.- Specified by:
getAsNumberin interfaceBGPSession- Returns:
- Peer's AS Number
-
getLimiter
public ChannelOutputLimiter getLimiter()
-
channelInactive
public final void channelInactive(io.netty.channel.ChannelHandlerContext ctx) throws Exception- Specified by:
channelInactivein interfaceio.netty.channel.ChannelInboundHandler- Overrides:
channelInactivein classio.netty.channel.ChannelInboundHandlerAdapter- Throws:
Exception
-
channelRead0
protected final void channelRead0(io.netty.channel.ChannelHandlerContext ctx, org.opendaylight.yangtools.yang.binding.Notification msg)- Specified by:
channelRead0in classio.netty.channel.SimpleChannelInboundHandler<org.opendaylight.yangtools.yang.binding.Notification>
-
handlerAdded
public final void handlerAdded(io.netty.channel.ChannelHandlerContext ctx)
- Specified by:
handlerAddedin interfaceio.netty.channel.ChannelHandler- Overrides:
handlerAddedin classio.netty.channel.ChannelHandlerAdapter
-
exceptionCaught
public void exceptionCaught(io.netty.channel.ChannelHandlerContext ctx, Throwable cause)- Specified by:
exceptionCaughtin interfaceio.netty.channel.ChannelHandler- Specified by:
exceptionCaughtin interfaceio.netty.channel.ChannelInboundHandler- Overrides:
exceptionCaughtin classio.netty.channel.ChannelInboundHandlerAdapter
-
getBGPSessionState
public BGPSessionState getBGPSessionState()
Description copied from interface:BGPSessionStateProviderBGP Operational Session State.- Specified by:
getBGPSessionStatein interfaceBGPSessionStateProvider- Returns:
- BGPSessionState
-
getBGPTimersState
public BGPTimersState getBGPTimersState()
Description copied from interface:BGPSessionStateProviderBGP Operational Timers State.- Specified by:
getBGPTimersStatein interfaceBGPSessionStateProvider- Returns:
- BGPTimersState
-
getBGPTransportState
public BGPTransportState getBGPTransportState()
Description copied from interface:BGPSessionStateProviderBGP Operational Transport State.- Specified by:
getBGPTransportStatein interfaceBGPSessionStateProvider- Returns:
- BGPTransportState
-
registerMessagesCounter
public void registerMessagesCounter(BGPMessagesListener bgpMessagesListener)
Description copied from interface:BGPSessionStateProviderRegister BGP Operational Messages State Listener.- Specified by:
registerMessagesCounterin interfaceBGPSessionStateProvider- Parameters:
bgpMessagesListener- BGPMessagesListener
-
addDecoderConstraint
public <T extends PeerConstraint> void addDecoderConstraint(Class<T> constraintClass, T constraint)
Description copied from interface:BGPSessionAdd peer constraint to session pipeline decoder.- Specified by:
addDecoderConstraintin interfaceBGPSession
-
schedule
public io.netty.util.concurrent.ScheduledFuture<?> schedule(Runnable command, long delay, TimeUnit unit)
Description copied from interface:BGPSessionSchedule a task to be executed in the context of the session handling thread.- Specified by:
schedulein interfaceBGPSession- Parameters:
command- the task to executedelay- the time from now to delay executionunit- the time unit of the delay parameter- Returns:
- Future representing the scheduled task.
-
-