1 package org.opendaylight.controller.protocol_plugin.openflow.core.internal;
3 import java.util.concurrent.ThreadPoolExecutor;
5 import org.jboss.netty.channel.ChannelPipeline;
6 import org.jboss.netty.channel.ChannelPipelineFactory;
7 import org.jboss.netty.channel.Channels;
8 import org.jboss.netty.handler.execution.ExecutionHandler;
9 import org.jboss.netty.handler.timeout.IdleStateHandler;
10 import org.jboss.netty.handler.timeout.ReadTimeoutHandler;
11 import org.jboss.netty.util.HashedWheelTimer;
12 import org.jboss.netty.util.Timer;
15 * Creates a ChannelPipeline for a server-side openflow channel
18 public class OpenflowPipelineFactory implements ChannelPipelineFactory {
20 private static final int READ_TIMEOUT = 30;
21 private static final int READER_IDLE_TIMEOUT = 20;
22 private static final int WRITER_IDLE_TIMEOUT = 25;
23 private static final int ALL_IDLE_TIMEOUT = 0;
25 protected EnhancedController controller;
26 protected ThreadPoolExecutor pipelineExecutor;
27 protected Timer timer;
28 protected IdleStateHandler idleHandler;
29 protected ReadTimeoutHandler readTimeoutHandler;
31 public OpenflowPipelineFactory(EnhancedController controller,
32 ThreadPoolExecutor pipelineExecutor) {
34 this.controller = controller;
35 this.pipelineExecutor = pipelineExecutor;
36 this.timer = new HashedWheelTimer();
37 this.idleHandler = new IdleStateHandler(timer, READER_IDLE_TIMEOUT, WRITER_IDLE_TIMEOUT, ALL_IDLE_TIMEOUT);
38 this.readTimeoutHandler = new ReadTimeoutHandler(timer, READ_TIMEOUT);
42 public ChannelPipeline getPipeline() throws Exception {
43 //OFChannelState state = new OFChannelState();
46 ChannelPipeline pipeline = Channels.pipeline();
49 if (pipelineExecutor != null)
50 pipeline.addLast("pipelineExecutor",
51 new ExecutionHandler(pipelineExecutor));*/
52 pipeline.addLast("ofmessagedecoder", new OFMessageDecoder());
53 pipeline.addLast("ofmessageencoder", new OFMessageEncoder());
54 pipeline.addLast("idle", idleHandler);
55 //pipeline.addLast("timeout", readTimeoutHandler);
56 //pipeline.addLast("handshaketimeout",
57 // new HandshakeTimeoutHandler(state, timer, 15));
60 if (pipelineExecutor != null)
61 pipeline.addLast("pipelineExecutor",
62 new ExecutionHandler(pipelineExecutor));*/
63 pipeline.addLast("handler", controller.getChannelHandler());