2 * Copyright 2015 Open Networking Laboratory
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package org.onosproject.bgp.controller.impl;
19 import org.jboss.netty.channel.ChannelPipeline;
20 import org.jboss.netty.channel.ChannelPipelineFactory;
21 import org.jboss.netty.channel.Channels;
22 import org.jboss.netty.handler.timeout.ReadTimeoutHandler;
23 import org.jboss.netty.util.ExternalResourceReleasable;
24 import org.jboss.netty.util.HashedWheelTimer;
25 import org.jboss.netty.util.Timer;
28 * Creates a ChannelPipeline for a server-side bgp channel.
30 public class BGPPipelineFactory
31 implements ChannelPipelineFactory, ExternalResourceReleasable {
33 static final Timer TIMER = new HashedWheelTimer();
34 protected ReadTimeoutHandler readTimeoutHandler;
35 BGPControllerImpl bgpCtrlImpl;
38 * Constructor to initialize the values.
40 * @param ctrlImpl parent ctrlImpl
41 * @param isServBgp if it is a server or not
43 public BGPPipelineFactory(BGPControllerImpl ctrlImpl, boolean isServBgp) {
45 bgpCtrlImpl = ctrlImpl;
47 readTimeoutHandler = new ReadTimeoutHandler(TIMER, bgpCtrlImpl.getConfig().getHoldTime());
51 public ChannelPipeline getPipeline() throws Exception {
52 BGPChannelHandler handler = new BGPChannelHandler(bgpCtrlImpl);
54 ChannelPipeline pipeline = Channels.pipeline();
55 pipeline.addLast("bgpmessagedecoder", new BGPMessageDecoder());
56 pipeline.addLast("bgpmessageencoder", new BGPMessageEncoder());
57 pipeline.addLast("holdTime", readTimeoutHandler);
58 pipeline.addLast("PassiveHandler", handler);
64 public void releaseExternalResources() {