Floodlight 在 ChannelPipeline 图
生活随笔
收集整理的這篇文章主要介紹了
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; ??? } }
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 图的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: JQuery Tree 树形结构插件 z
- 下一篇: 一个C实现的线程池(产品暂未运用)