what's MINA?

what's MINA?

Apache MINA is a network application framework which helps users develop high performance and high scalability network applications easily. It provides an abstract ·event-driven · asynchronous API over various transports such as TCP/IP and UDP/IP via Java NIO.

Apache MINA is often called:

    * NIO framework · library,
    * client · server framework · library, or
    * a networking · socket library.

the architecture of MINA based application
what's MINA?_第1张图片

a deeper dive into the details
what's MINA?_第2张图片

Broadly, MINA based applications are divided into 3 layers
    * I/O Service - Performs actual I/O
    * I/O Filter Chain - Filters/Transforms bytes into desired Data Structures and vice-versa
    * I/O Handler - Here resides the actual business logic

So, how to create a MINA based Application
   1. Create I/O service - Choose from already available Services (*Acceptor) or create your own
   2. Create Filter Chain - Choose from already existing Filters or create a custom Filter for transforming request/response
   3. Create I/O Handler - Write business logic, on handling different messages


Server Architecture

We have seen, MINA based Application Architecture in previous section. Lets focus on Server Architecture. A Server listens on a port for incoming requests, process them and send replies.
what's MINA?_第3张图片

    * 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 IOHandler. IOHandlers can be used to full fill business needs.


Client Architecture


We had a brief look at MINA based Server Architecture, lets see how Client looks like. Clients need to connect to a Server, send message and process the responses.
what's MINA?_第4张图片

    * Client first creates an IOConnector (MINA Construct for connecting to Socket), initiates a bind with Server
    * Upon Connection creation, a Session is created and is associated with Connection
    * Application/Client writes to the Session, resulting in data being sent to Server, after traversing the Filter Chain
    * All the responses/messages received from Server are traverses the Filter Chain and lands at IOHandler, for processing

link to user-guide

你可能感兴趣的:(apache,socket,Mina,performance)