我们知道,在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. Linux网络编程一站式学习

    提要 学过非常多遍计算机网络,依旧不会网络编程. 看完这篇文章之后就不会是这样了. 环境:Ubuntu14.04 64bit 何为Socket 是基于TCP/IP的网络应用编程中使用的有关数据通信的概 ...

  2. 新秀nginx源代码分析数据结构篇(四)红黑树ngx_rbtree_t

    新秀nginx源代码分析数据结构篇(四)红黑树ngx_rbtree_t Author:Echo Chen(陈斌) Email:chenb19870707@gmail.com Blog:Blog.csd ...

  3. nRF905 - 系列示意图

    一个.截图 备份文件:sch20110521.7z 版权声明:本文博客原创文章,博客,未经同意,不得转载.

  4. hdu 3001 Travelling (TSP问题 )

    Travelling Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total ...

  5. CentOS7 安装Bind

    简要记录安装Bind的过程以及遇到的问题 一. 虚拟机准备 准备了2台虚拟机,都是装的CentOS7 64_1的IP地址为192.168.1.160,2的地址为161.161作为DNS服务器. 二.下 ...

  6. java 面试题汇总(未完成)

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

  7. EXCEL Pivot table manipulate

    Add filter For the Demo time,I would like to filter out the products which not in Red and Black colo ...

  8. Composer生成PHP依赖包

    近期在用一些扩展或者类库的时候,偶尔会碰到使用Composer生成php包的问题.总结步骤如下:window下安装composer:参考http://www.kankanews.com/ICkengi ...

  9. 有一定基础的 C++ 学习者该怎样学习 Windows 编程?

    人的心理有个奇异的特性:一项知识一旦学会之后,学习过程中面临的困惑和不解非常快就会忘得干干净净,似乎一切都是自然而然,本来就该这种.因此,关于「怎样入门」这类问题,找顶尖高手来回答,未必能比一个刚入门 ...

  10. YUV422蓝色屏幕输出的调试援助

    YUV422蓝色屏幕输出的调试援助 YUV422有YUYV,YVYU,UYVY,VYUY四种,以下笔者就就以UYVY为例介绍一下数据构成.因为常常要跟视频输入打交道,所以YUV422这种常见的视频信号 ...