zoukankan      html  css  js  c++  java
  • Floodlight 在 ChannelPipeline 图

    我们知道,在Netty架构,一个ServerBootstrap用于生成server端的Channel的时候都须要提供一个ChannelPipelineFactory类型的參数,用于服务于建立连接的Channel,流水线处理来自某个client的请求。所以这里的 OpenflowPipelineFactory 就是Floodlight 为建立连接的openflow交换机创建ChannelPipeline。





    1. IdleStateHandler 当Channel上没有运行对应的读写操作一定时间的时候出发一个 IdleStateEvent 事件;
    2. ReadTimeoutHandler 读超时处理;
    3. HandshakeTimeoutHandler 设置一个定时器检查连接的状态,握手阶段 。
    4 . OFChannelHandler 核心,处理全部的业务。

    代码例如以下:
    public class OpenflowPipelineFactory implements ChannelPipelineFactory {

        protected Controller controller ;
        protected ThreadPoolExecutor pipelineExecutor ;
        protected Timer timer;
        protected IdleStateHandler idleHandler ;
        protected ReadTimeoutHandler readTimeoutHandler ;
       
        public OpenflowPipelineFactory(Controller controller,
                                       ThreadPoolExecutor pipelineExecutor) {
            super ();
            this .controller = controller;
            this .pipelineExecutor = pipelineExecutor;
            this .timer new HashedWheelTimer();
            this .idleHandler new IdleStateHandler( timer, 20, 25, 0);
            this .readTimeoutHandler new ReadTimeoutHandler(timer , 30);
        }
     
        @Override
        public ChannelPipeline getPipeline() throws Exception {
            OFChannelState state = new OFChannelState();
           
            ChannelPipeline pipeline = Channels. pipeline();
            pipeline.addLast( "ofmessagedecoder" new OFMessageDecoder());
            pipeline.addLast( "ofmessageencoder" new OFMessageEncoder());
            pipeline.addLast( "idle" idleHandler );
            pipeline.addLast( "timeout" readTimeoutHandler );
            pipeline.addLast( "handshaketimeout" ,
                             new HandshakeTimeoutHandler(state, timer , 15));
            if (pipelineExecutor != null)
                pipeline.addLast( "pipelineExecutor" ,
                                 new ExecutionHandler(pipelineExecutor ));
            //OFChannelHandler 是核心
            pipeline.addLast( "handler" controller .getChannelHandler(state));
            return pipeline;
        }
    }




    版权声明:本文博客原创文章,博客,未经同意,不得转载。

  • 相关阅读:
    EL表达式
    ASP.NET excel导出功能通用类
    ASP.NET MVC4应用程序无法建立控制器的解决方案
    SQLServer 2008以上误操作数据库恢复方法——日志尾部备份
    Jquery中选择器整理
    JQuery mouse事件运用方法
    js中substring和substr的用法
    JS replace用法
    Jquery ajax执行顺序 返回自定义错误信息
    Jquery checkbox, select 取值
  • 原文地址:https://www.cnblogs.com/mengfanrong/p/4684451.html
Copyright © 2011-2022 走看看