mina Server Architecture

 

Server Architecture

We have exposed the MINA Application Architecture in the previous section. Let's now focus on the Server Architecture. Basically, a Server listens on a port for incoming requests, process them and send replies. It also creates and handles a session for each client (whenever we have a TCP or UDP based protocol), this will be explain more extensively in the chapter 4.

我在上一章節中介紹了mina的應用架構。讓我們來了解一個服務端的架構。

服務端主要監聽端口進來的請求,處理請求和發送回覆,爲處理每一個客戶端(基本tcp 或者udp協議)創建一個會話 。在第4個會更詳細的介紹。

 

  • IOAcceptor listens on the network for incoming connections/packets
  • For a new connection, a new session is created and all subsequent request from IP Address/Port combination are handled in that Session
  • All packets received for a Session, traverses the Filter Chain as specified in the diagram. Filters can be used to modify the content of packets (like converting to Objects, adding/removing information etc). For converting to/from raw bytes to High Level Objects, PacketEncoder/Decoder are particularly useful
  • Finally the packet or converted object lands in IOHandlerIOHandlers can be used to fulfill business needs.

IOAcceptor 監聽來自網絡的連接和數據包

一個新鏈接,創建一個會話,這個ip地趾端口尾隨而來的請求在這個會話中處理。

會話所有的數據包會經過filter chain 。filter 被用修改數據包的內容,爲轉換byte爲更高的對象(如string等),數據編碼/解碼常用到。

最數據包被轉換成對象傳給iohanlder ,iohanlder 被用於滿足業務邏輯的需求。

 

 

Session creation

Whenever a client connects on a MINA server, we will create a new session to store persistent data into it. Even if the protocol is not connected, this session will be created. The following schema shows how MINA handles incoming connections :

當客戶連接mina服務端,將會創建一個新的會話用於存儲待久數據,甚至這個協議沒有連接這個session也被創建。

下面的說明mina是如何處理請求鏈接的。

Incoming connections handling

Incoming messages processing

We will now explain how MINA processes incoming messages.

Assuming that a session has been created, any new incoming message will result in a selector being waken up

假如一個會話被創建。一個新消息的到將使一個選擇器被人喚醒

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章