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;
        }
    }




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

  • 相关阅读:
    字符串与Unicode码的相互转换
    关于es6中的yield
    ajax请求中的6个全局事件
    用H5上传文件
    类型化数组
    git笔记-9-29
    js正则表达式验证身份证号和密码
    assertThat用法
    java产生随机数的几种方式
    jQuery之Deferred对象详解
  • 原文地址:https://www.cnblogs.com/mengfanrong/p/4684451.html
Copyright © 2011-2022 走看看