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;

}

}

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

时间: 2024-08-05 21:44:19

Floodlight 在 ChannelPipeline 图的相关文章

Floodlight 中 ChannelPipeline 结构图

1. IdleStateHandler 当Channel上没有执行相应的读写操作一定时间的时候出发一个 IdleStateEvent 事件: 2. ReadTimeoutHandler 读超时处理: 3. HandshakeTimeoutHandler 设置一个定时器检查连接的状态,握手阶段 : 4 . OFChannelHandler 核心,处理所有的业务. Floodlight 中 ChannelPipeline 结构图

Netty in Action (七) 第三章节 Netty组件和设计

这个章节包括: 1)Netty的架构设计和技术点 2)Channel,EventLoop和ChannelFuture 3)ChannelHandler 和 ChannelPipeline 4)Bootstrap 在第一章节中,我们讲述了java在高性能的网络编程的发展历史和对网络方面的技术基础的积累,这给对Netty的核心组件和构建模块分析提供了一个很好的氛围 在第二章节中,我们扩大了我们的讨论范围,我们构建了我们第一个基于Netty的应用,通过构建简单的服务器端和客户端让我们了解了如何启动Ne

利用filter实时切换big5和gb2312,以及gb2312的简繁体

IEEE Spectrum 杂志发布了一年一度的编程语言排行榜,这也是他们发布的第四届编程语言 Top 榜. 据介绍,IEEE Spectrum 的排序是来自 10 个重要线上数据源的综合,例如 Stack Overflow.Twitter.Reddit.IEEE Xplore.GitHub.CareerBuilder 等,对 48 种语言进行排行. 与其他排行榜不同的是,IEEE Spectrum 可以让读者自己选择参数组合时的权重,得到不同的排序结果.考虑到典型的 Spectrum 读者需求

俑烟汲的诿樟透磺勒秤窗mvus

IEEE Spectrum 杂志发布了一年一度的编程语言排行榜,这也是他们发布的第四届编程语言 Top 榜. 据介绍,IEEE Spectrum 的排序是来自 10 个重要线上数据源的综合,例如 Stack Overflow.Twitter.Reddit.IEEE Xplore.GitHub.CareerBuilder 等,对 48 种语言进行排行. 与其他排行榜不同的是,IEEE Spectrum 可以让读者自己选择参数组合时的权重,得到不同的排序结果.考虑到典型的 Spectrum 读者需求

[原创]Floodlight安装

Floodlight安装:一.安装环境: ubuntu-12.04-64bit二.安装Floodlight: #apt-get update #apt-get install build-essential default-jdk ant python-dev #apt-get install git #git clone git://github.com/floodlight/floodlight.git #cd floodlight #git checkout fl-last-passed-

Netty in Action (十五) 第六章节 第一部分 ChannelHandler和ChannelPipeline

本章内容包括: 1)ChannelHandler和ChannelPipeline的APIs 2)检测内存泄漏 3)异常处理 在之前的一个章节中,我们学习了ByteBuf,Netty的数据容器,在这个章节中,我们将讲解Netty的数据流和对应的处理组件,然后我们将我们已经学过的所有组件整合在一起 你已经知道多个ChannelHandler可以被链式的放入ChannelPipeline来将所有的处理逻辑组织在一起,我们将学习包涵这些有关类的很多用户案例和他们之间的对应关系------ChannelH

Netty3 源码分析 - ChannelPipeline

ChannelPipeline的作用就是组织一系列的ChannelHandlers 为某一个Channel服务,处理各种事件.实现了拦截过滤器模式的高级形式(an advanced form of the Intercepting Filter pattern),进而有效控制如何处理一个事件以及ChannelHandlers之间如何交互.类型结构图为: 流水线的创建:对于每个新的通道,必须为其创建和添置一个Pipeline,一旦设置,他们之间的耦合就是永久的,这个通道不同添置另一个流水线,不能解

Floodlight之 FloodlightContextStore 数据结构

FloodlightContextStore 代表的是一种缓存模型(利用的是ConcurrentHashMap),里面存储的是上下文相关的对象,能够根据相应的key得到具体的 Object,存在的意义是Floodlight中注册监听某个事件的listener可以在被调用的时候直接从中取出上下文信息(context information).下面是重要的代码片段. 基本数据结构: public class FloodlightContext { protected ConcurrentHashMa

Floodlight 处理交换机加入/移除过程

Floodlight 使用的是Netty架构,在Controller.java 入口函数中显示创建ServerBootstrap,设置套接字选项,ChannelPipeline,此时监听套接字就准备好处理来自SW的各种消息:这里最核心的就是 OpenflowPipelineFactory ,会加入各个业务相关的Handler,代码如下: public ChannelPipeline getPipeline() throws Exception { OFChannelState state = n