+
+ @Override
+ public synchronized BgpSessionState getBgpSessionState() {
+ return this.sessionStats.getBgpSessionState(this.state);
+ }
+
+ @Override
+ public synchronized void resetSessionStats() {
+ this.sessionStats.resetStats();
+ }
+
+ public ChannelOutputLimiter getLimiter() {
+ return this.limiter;
+ }
+
+ @Override
+ public final void channelInactive(final ChannelHandlerContext ctx) {
+ LOG.debug("Channel {} inactive.", ctx.channel());
+ this.endOfInput();
+
+ try {
+ super.channelInactive(ctx);
+ } catch (final Exception e) {
+ throw new IllegalStateException("Failed to delegate channel inactive event on channel " + ctx.channel(), e);
+ }
+ }
+
+ @Override
+ protected final void channelRead0(final ChannelHandlerContext ctx, final Notification msg) {
+ LOG.debug("Message was received: {}", msg);
+ try {
+ this.handleMessage(msg);
+ } catch (final BGPDocumentedException e) {
+ this.terminate(e);
+ }
+ }
+
+ @Override
+ public final void handlerAdded(final ChannelHandlerContext ctx) {
+ this.sessionUp();
+ }
+
+ @Override
+ public void exceptionCaught(final ChannelHandlerContext ctx, final Throwable cause) {
+ LOG.warn("BGP session encountered error", cause);
+ if (cause.getCause() instanceof BGPDocumentedException) {
+ this.terminate((BGPDocumentedException) cause.getCause());
+ } else {
+ this.close();
+ }
+ }