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.pcep.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.IdleStateHandler;
23 import org.jboss.netty.handler.timeout.ReadTimeoutHandler;
24 import org.jboss.netty.util.ExternalResourceReleasable;
25 import org.jboss.netty.util.HashedWheelTimer;
26 import org.jboss.netty.util.Timer;
29 * Creates a ChannelPipeline for a server-side pcep channel.
31 public class PcepPipelineFactory
32 implements ChannelPipelineFactory, ExternalResourceReleasable {
34 protected Controller controller;
35 static final Timer TIMER = new HashedWheelTimer();
36 protected IdleStateHandler idleHandler;
37 protected ReadTimeoutHandler readTimeoutHandler;
38 static final int DEFAULT_KEEP_ALIVE_TIME = 30;
39 static final int DEFAULT_DEAD_TIME = 120;
40 static final int DEFAULT_WAIT_TIME = 60;
42 public PcepPipelineFactory(Controller controller) {
44 this.controller = controller;
45 this.idleHandler = new IdleStateHandler(TIMER, DEFAULT_DEAD_TIME, DEFAULT_KEEP_ALIVE_TIME, 0);
46 this.readTimeoutHandler = new ReadTimeoutHandler(TIMER, DEFAULT_WAIT_TIME);
50 public ChannelPipeline getPipeline() throws Exception {
51 PcepChannelHandler handler = new PcepChannelHandler(controller);
53 ChannelPipeline pipeline = Channels.pipeline();
54 pipeline.addLast("pcepmessagedecoder", new PcepMessageDecoder());
55 pipeline.addLast("pcepmessageencoder", new PcepMessageEncoder());
56 pipeline.addLast("idle", idleHandler);
57 pipeline.addLast("waittimeout", readTimeoutHandler);
58 pipeline.addLast("handler", handler);
63 public void releaseExternalResources() {