Apache Mina Server is built on the top of Java NIO Package. By using this framework you can create high performance, highly scalable applications. It gives abstract event driven asynchronous API over various transport such as TCP/IP and UDP/IP.
Lets go through a small architecture level explanation about apache MINA Server.
Mina Server Architecture
Apache MINA architecture can mainly splitup into 3 layers which are
Application Layer - Here resides the actual business logic. IOHandler is the heart of application layer.
Filters for incoming and outgoing messages - It filter or transforms the bytes into specific data structure and vice versa.
Performs I/O or IO Services - Here performs the actual IO. In Server side uses IO Acceptor and Client side uses IO Connector. These things are the API's at this level are responsible for performing actual IO operation over the network.
Mina Session
When a client connected to the server, a new session is created, and will be kept in memory until the client is disconnected. A session is used to store persistent informations about the connection, plus any kind of information the server might need to use during the request processing, and eventually during the whole session life.
Server Architecture
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)
Here is the complete server working in short
- 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, Packet Encoder/Decoder are particularly useful
-
Finally the packet or converted object lands in
IOHandler
.IOHandlers
can be used to fulfill business needs.
Client Architecture
lets see how Client looks like. Clients need to connect to a Server, send message and process the responses.
Here the working is
- 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
No comments:
Post a Comment