Floodlight 在 ChannelPipeline 图
生活随笔
收集整理的這篇文章主要介紹了
Floodlight 在 ChannelPipeline 图
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
我們知道,在Netty架構(gòu),一個(gè)ServerBootstrap用于生成server端的Channel的時(shí)候都須要提供一個(gè)ChannelPipelineFactory類型的參數(shù),用于服務(wù)于建立連接的Channel,流水線處理來(lái)自某個(gè)client的請(qǐng)求。所以這里的?OpenflowPipelineFactory 就是Floodlight 為建立連接的openflow交換機(jī)創(chuàng)建ChannelPipeline。
1.?IdleStateHandler 當(dāng)Channel上沒(méi)有運(yùn)行對(duì)應(yīng)的讀寫(xiě)操作一定時(shí)間的時(shí)候出發(fā)一個(gè) IdleStateEvent 事件; 2.?ReadTimeoutHandler 讀超時(shí)處理; 3.?HandshakeTimeoutHandler 設(shè)置一個(gè)定時(shí)器檢查連接的狀態(tài),握手階段 。 4 .?OFChannelHandler 核心,處理全部的業(yè)務(wù)。
代碼例如以下: 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; ??? } }
1.?IdleStateHandler 當(dāng)Channel上沒(méi)有運(yùn)行對(duì)應(yīng)的讀寫(xiě)操作一定時(shí)間的時(shí)候出發(fā)一個(gè) IdleStateEvent 事件; 2.?ReadTimeoutHandler 讀超時(shí)處理; 3.?HandshakeTimeoutHandler 設(shè)置一個(gè)定時(shí)器檢查連接的狀態(tài),握手階段 。 4 .?OFChannelHandler 核心,處理全部的業(yè)務(wù)。
代碼例如以下: 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; ??? } }
版權(quán)聲明:本文博客原創(chuàng)文章,博客,未經(jīng)同意,不得轉(zhuǎn)載。
總結(jié)
以上是生活随笔為你收集整理的Floodlight 在 ChannelPipeline 图的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: JQuery Tree 树形结构插件 z
- 下一篇: 一个C实现的线程池(产品暂未运用)