我们知道,在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;
    }
}



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

Floodlight 在 ChannelPipeline 图的更多相关文章

  1. ChannelPipeline

    Netty的ChannelPipeline和ChannelHandler机制类似于Servlet和Filter过滤器,这类拦截器实际上是职责链模式的一种变形,主要是为了方便事件的拦截和用户业务逻辑的定 ...

  2. Floodlight之 FloodlightContextStore 数据结构

         FloodlightContextStore 代表的是一种缓存模型(利用的是ConcurrentHashMap).里面存储的是上下文相关的对象,可以依据对应的key得到详细的 Object. ...

  3. Floodlight 处理交换机增加/移除过程

         Floodlight 使用的是Netty架构,在Controller.java 入口函数中显示创建ServerBootstrap,设置套接字选项,ChannelPipeline,此时监听套接 ...

  4. 【Netty】(8)---理解ChannelPipeline

    ChannelPipeline ChannelPipeline不是单独存在,它肯定会和Channel.ChannelHandler.ChannelHandlerContext关联在一起,所以有关概念这 ...

  5. Netty实战六之ChannelHandler和ChannelPipeline

    1.Channel的生命周期 Interface Channel定义了一组和ChannelInboundHandler API密切相关的简单但功能强大的状态模型,以下列出Channel的4个状态. C ...

  6. Netty 系列四(ChannelHandler 和 ChannelPipeline).

    一.概念 先来整体的介绍一下这篇博文要介绍的几个概念(Channel.ChannelHandler.ChannelPipeline.ChannelHandlerContext.ChannelPromi ...

  7. mininet实验 连接floodlight控制器

    参考博客一 参考博客二 事先准备-floodlight安装 Java安装方法及环境变量配置 执行ifconfig命令获取floodlight所在服务器的IP地址. 1.启动floodlight jav ...

  8. Netty的ChannelHandler,ChannelHandlerContext,ChannelPipeline

    本小节一起学习一下ChannelHandler,ChannelHandlerContext,ChannelPipeline这三个Netty常用的组件,不探究它们的底层源码,我们就简单的分析一下用法 首 ...

  9. ChannelHandler,ChannelHandlerContext,ChannelPipeline

    本小节一起学习一下ChannelHandler,ChannelHandlerContext,ChannelPipeline这三个Netty常用的组件,不探究它们的底层源码,我们就简单的分析一下用法 首 ...

随机推荐

  1. 腾讯2014在广州站实习生offer经验(TEG-开发背景)

    研究在过去的一年是linux 什么系统编程和网络编程.比较熟悉的语言c/c++,python只写一些测试client.是后台开发类,比方前面笔面的网易CC(面完hr后挂).大概3月15号就在腾讯 jo ...

  2. Ubuntu14.04设备JDK

    1.设备JDK 打开命令直插式工具.输入以下三个命令: sudo add-apt-repository ppa:webupd8team/java sudo apt-get update sudo ap ...

  3. Ceph 存储集群

    Ceph 存储集群 Ceph 作为软件定义存储的代表之一,最近几年其发展势头很猛,也出现了不少公司在测试和生产系统中使用 Ceph 的案例,尽管与此同时许多人对它的抱怨也一直存在.本文试着整理作者了解 ...

  4. 简单的方法来改善手机3G上网速度(2G转3G)

           这里提到的方法是将手机信号不好的地方(也就是2G信号)强制转换为3G信号上网以至于提高上网速度,大家常常看到在某个地方(比方坐地铁)手机明明是3G卡,却显示的是2G信号,这就是手机老在2 ...

  5. ExtJs4得知(五岁以下儿童)主要的Ext分类

    Ext类是ExtJs最常见的.最基本的类,它是一个全局对象,它封装了全班.辛格尔顿和 Sencha 该方法提供了一种有用的库. 嵌套在该命名空间中一个较低的水平最用户界面组件. 但是提供了很多有用的功 ...

  6. dom 规划(html和xml)

    html dom与xml dom关联: 什么是 DOM? DOM 是 W3C(万维网联盟)的标准. DOM 定义了訪问 HTML 和 XML 文档的标准: "W3C 文档对象模型 (DOM) ...

  7. centos安装wget 及配置(转)

    yum -y install wget #yum install perl Searching for GCC... The path "" is not valid path t ...

  8. 图片 Base64码 转换

    import sun.misc.BASE64Decoder; private String getBase64Picture(String imgBase64Str) { FileOutputStre ...

  9. 【Python】Python的urllib模、urllib2模块的网络下载文件

    因为需要从一些下载一个页PDF文件.但是需要下载PDF有数百个文件,这是不可能用人工点击下载.只是Python有相关模块,所以写一个程序PDF文件下载,顺便熟悉Python的urllib模块和ulrl ...

  10. ASP.NET MVC+EF框架+EasyUI实现权限管理系列(10)- VSS源代码管理

    原文:ASP.NET MVC+EF框架+EasyUI实现权限管理系列(10)- VSS源代码管理 ASP.NET MVC+EF框架+EasyUI实现权限管系列 (开篇)   (1):框架搭建    ( ...