![Page 1: Introduction to MINA A M ultipurpose I nfrastructure for N etwork A pplications April 2005, Trustin Lee, ASF](https://reader036.vdocuments.site/reader036/viewer/2022062423/56649e985503460f94b9b2a7/html5/thumbnails/1.jpg)
Introduction to MINA
A Multipurpose Infrastructure
for Network Applications
April 2005, Trustin Lee, ASF
![Page 2: Introduction to MINA A M ultipurpose I nfrastructure for N etwork A pplications April 2005, Trustin Lee, ASF](https://reader036.vdocuments.site/reader036/viewer/2022062423/56649e985503460f94b9b2a7/html5/thumbnails/2.jpg)
Contents
Overview How to Program Filter Mechanism Proof of Productivity Architecture Review Conclusion
![Page 3: Introduction to MINA A M ultipurpose I nfrastructure for N etwork A pplications April 2005, Trustin Lee, ASF](https://reader036.vdocuments.site/reader036/viewer/2022062423/56649e985503460f94b9b2a7/html5/thumbnails/3.jpg)
Overview
![Page 4: Introduction to MINA A M ultipurpose I nfrastructure for N etwork A pplications April 2005, Trustin Lee, ASF](https://reader036.vdocuments.site/reader036/viewer/2022062423/56649e985503460f94b9b2a7/html5/thumbnails/4.jpg)
What is MINA?
A network application framework
Feature-rich Extensible Designed for agile client/server
programming
Client- or server-less unit testing Very high reusability and maintainability
Yet scalable / high performance
![Page 5: Introduction to MINA A M ultipurpose I nfrastructure for N etwork A pplications April 2005, Trustin Lee, ASF](https://reader036.vdocuments.site/reader036/viewer/2022062423/56649e985503460f94b9b2a7/html5/thumbnails/5.jpg)
Architecture: I/O Layer
MINA abstracts all low-level I/O via abstract API. IoHandlers get notified when I/O events occur. You communicate by reading and writing data buffers.
Clients
IoAcceptor
IoHandler
L o w - L e v e l
I / O
I / O E v e n t s
Core
Protocol Implementation
Legend
![Page 6: Introduction to MINA A M ultipurpose I nfrastructure for N etwork A pplications April 2005, Trustin Lee, ASF](https://reader036.vdocuments.site/reader036/viewer/2022062423/56649e985503460f94b9b2a7/html5/thumbnails/6.jpg)
Architecture: Protocol Layer
Protocol Provider
ProtocolAcceptor
Encode/D
ecode
Protocol Codec Protocol Handler
Clients
IoAcceptor
IoHandler
L o w - L e v e l
I / O
I / O E v e n t s I / O E v e n t s
P r o t o c o l
E v e n t s
<<IoHandler>>‘I/O Layer to Protocol Layer‘
Bridge
I/O Layer
Protocol Layer
Core
Protocol Implementation
Legend
Built upon I/O layer Good when you implement complex protocols You communicate by sending and receiving message objects..
![Page 7: Introduction to MINA A M ultipurpose I nfrastructure for N etwork A pplications April 2005, Trustin Lee, ASF](https://reader036.vdocuments.site/reader036/viewer/2022062423/56649e985503460f94b9b2a7/html5/thumbnails/7.jpg)
MINA Abstract API
Single API for various transport types
Highly extensible
Unit-test your server using mock objects. no real clients anymore!
![Page 8: Introduction to MINA A M ultipurpose I nfrastructure for N etwork A pplications April 2005, Trustin Lee, ASF](https://reader036.vdocuments.site/reader036/viewer/2022062423/56649e985503460f94b9b2a7/html5/thumbnails/8.jpg)
MINA Abstract API (Cont’d)
Once a protocol implemented, it works for: NIO sockets
TCP/IP UDP/IP
In-VM pipe Coming soon:
Non-NIO sockets Serial port Parallel port Multicast (when Mustang is ready)
![Page 9: Introduction to MINA A M ultipurpose I nfrastructure for N etwork A pplications April 2005, Trustin Lee, ASF](https://reader036.vdocuments.site/reader036/viewer/2022062423/56649e985503460f94b9b2a7/html5/thumbnails/9.jpg)
How to Program
![Page 10: Introduction to MINA A M ultipurpose I nfrastructure for N etwork A pplications April 2005, Trustin Lee, ASF](https://reader036.vdocuments.site/reader036/viewer/2022062423/56649e985503460f94b9b2a7/html5/thumbnails/10.jpg)
What MINA Does For You
You NEVER need to program...
Stream I/O
NIO
Thread management
Buffer management
because it does ALL of them for you!Then what do you have to do?
![Page 11: Introduction to MINA A M ultipurpose I nfrastructure for N etwork A pplications April 2005, Trustin Lee, ASF](https://reader036.vdocuments.site/reader036/viewer/2022062423/56649e985503460f94b9b2a7/html5/thumbnails/11.jpg)
What You Should Do
The first way to implement your protocol:
Using I/O Layer: IoHandler You communicate by reading and writing data buffers.
![Page 12: Introduction to MINA A M ultipurpose I nfrastructure for N etwork A pplications April 2005, Trustin Lee, ASF](https://reader036.vdocuments.site/reader036/viewer/2022062423/56649e985503460f94b9b2a7/html5/thumbnails/12.jpg)
What You Should Do (Cont’d)
cd io
<<interface>>
IoHandler
~ sessionCreated(IoSession) : void~ sessionOpened(IoSession) : void~ sessionClosed(IoSession) : void~ sessionIdle(IoSession, IdleStatus) : void~ exceptionCaught(IoSession, Throwable) : void~ dataRead(IoSession, ByteBuffer) : void~ dataWritten(IoSession, Object) : void
![Page 13: Introduction to MINA A M ultipurpose I nfrastructure for N etwork A pplications April 2005, Trustin Lee, ASF](https://reader036.vdocuments.site/reader036/viewer/2022062423/56649e985503460f94b9b2a7/html5/thumbnails/13.jpg)
What You Should Do (Cont’d)
The second way to implement your protocol: Using Protocol Layer: ProtocolProvider
You communicate by exchanging objects (POJO).
Your codec performs transformations betweendata buffers and message objects.
Reusable Pluggable (thanks to polymorphism)
You take full advantage of OOP for message objects
Inheritance
![Page 14: Introduction to MINA A M ultipurpose I nfrastructure for N etwork A pplications April 2005, Trustin Lee, ASF](https://reader036.vdocuments.site/reader036/viewer/2022062423/56649e985503460f94b9b2a7/html5/thumbnails/14.jpg)
What You Should Do (Cont’d)
cd protocol
<<interface>>
ProtocolHandler
~ sessionCreated(ProtocolSession) : void~ sessionOpened(ProtocolSession) : void~ sessionClosed(ProtocolSession) : void~ sessionIdle(ProtocolSession, IdleStatus) : void~ exceptionCaught(ProtocolSession, Throwable) : void~ messageReceived(ProtocolSession, Object) : void~ messageSent(ProtocolSession, Object) : void
<<interface>>
ProtocolProvider
~ getCodecFactory() : ProtocolCodecFactory~ getHandler() : ProtocolHandler
<<interface>>
ProtocolCodecFactory
~ newEncoder() : ProtocolEncoder~ newDecoder() : ProtocolDecoder
ProtocolDecoderProtocolEncoder
![Page 15: Introduction to MINA A M ultipurpose I nfrastructure for N etwork A pplications April 2005, Trustin Lee, ASF](https://reader036.vdocuments.site/reader036/viewer/2022062423/56649e985503460f94b9b2a7/html5/thumbnails/15.jpg)
Filter Mechanism
![Page 16: Introduction to MINA A M ultipurpose I nfrastructure for N etwork A pplications April 2005, Trustin Lee, ASF](https://reader036.vdocuments.site/reader036/viewer/2022062423/56649e985503460f94b9b2a7/html5/thumbnails/16.jpg)
Architecture (with Filters)
Protocol Provider
ProtocolAcceptor
Encode/D
ecode
Protocol Codec Protocol Handler
Clients
IoAcceptor
IoHandler
IoFilters
L o w - L e v e l
I / O
I / O E v e n t s
F i l t e r e d
I / O E v e n t s
F i l t e r e d
I / O E v e n t s
P r o t o c o l
E v e n t s
<<IoHandler>>‘I/O Layer to Protocol Layer‘
Bridge
ProtocolFiltersF i l t e r e d
P r o t o c o l
E v e n t s
I/O Layer
Protocol Layer
Core
Extension Point
Protocol Implementation
Legend
![Page 17: Introduction to MINA A M ultipurpose I nfrastructure for N etwork A pplications April 2005, Trustin Lee, ASF](https://reader036.vdocuments.site/reader036/viewer/2022062423/56649e985503460f94b9b2a7/html5/thumbnails/17.jpg)
What is Filter
A reusable event interceptor Similar to Servlet filters
Can be added and removed “on-the-fly”
Works in both coarse- and fine-grained way: Per Server Port Per Individual Session
![Page 18: Introduction to MINA A M ultipurpose I nfrastructure for N etwork A pplications April 2005, Trustin Lee, ASF](https://reader036.vdocuments.site/reader036/viewer/2022062423/56649e985503460f94b9b2a7/html5/thumbnails/18.jpg)
Filter Use Cases
Implemented filters: Thread pool (= customizable thread model!) SSL Client blacklisting
Coming soon: Logging, Profiling, StartTLS, Peak Point Control, T
raffic throttling, Firewall, and many more ... Any contributions are welcome!
![Page 19: Introduction to MINA A M ultipurpose I nfrastructure for N etwork A pplications April 2005, Trustin Lee, ASF](https://reader036.vdocuments.site/reader036/viewer/2022062423/56649e985503460f94b9b2a7/html5/thumbnails/19.jpg)
Filter Use Cases (Cont’d)
Customizable thread models
MINA runs in single thread mode by default Good for low-latency apps
Add a ThreadPoolFilter to make MINA multi-threaded Good for high-scalability apps
![Page 20: Introduction to MINA A M ultipurpose I nfrastructure for N etwork A pplications April 2005, Trustin Lee, ASF](https://reader036.vdocuments.site/reader036/viewer/2022062423/56649e985503460f94b9b2a7/html5/thumbnails/20.jpg)
Proof of Productivity
![Page 21: Introduction to MINA A M ultipurpose I nfrastructure for N etwork A pplications April 2005, Trustin Lee, ASF](https://reader036.vdocuments.site/reader036/viewer/2022062423/56649e985503460f94b9b2a7/html5/thumbnails/21.jpg)
Comparison
*) A Core Java Tech Tips example 100% CPU consumption while socket buffer is
full. (doesn’t register for OP_WRITE) No SSL support (never trivial)
Plain NIO MINA
Echo server 109 lines* 50 lines (45%)
Reusability Poor All reusable:Filters, Codecs, Handler
s
Maintainability
Poor Very good
![Page 22: Introduction to MINA A M ultipurpose I nfrastructure for N etwork A pplications April 2005, Trustin Lee, ASF](https://reader036.vdocuments.site/reader036/viewer/2022062423/56649e985503460f94b9b2a7/html5/thumbnails/22.jpg)
More Complex Protocols
Even echo server is hard to maintain. Writing complex protocols with plain NIO is
the beginning of your nightmare.
MINA Protocol Layer is your cozy pillow.
Known implementations: LDAP SMTP DNS
Kerberos IMAPv4 NTP
![Page 23: Introduction to MINA A M ultipurpose I nfrastructure for N etwork A pplications April 2005, Trustin Lee, ASF](https://reader036.vdocuments.site/reader036/viewer/2022062423/56649e985503460f94b9b2a7/html5/thumbnails/23.jpg)
Architecture Review
![Page 24: Introduction to MINA A M ultipurpose I nfrastructure for N etwork A pplications April 2005, Trustin Lee, ASF](https://reader036.vdocuments.site/reader036/viewer/2022062423/56649e985503460f94b9b2a7/html5/thumbnails/24.jpg)
Architecture Review
Protocol Provider
ProtocolAcceptor
Encode/D
ecode
Protocol Codec Protocol Handler
Clients
IoAcceptor
IoHandler
IoFilters
L o w - L e v e l
I / O
I / O E v e n t s
F i l t e r e d
I / O E v e n t s
F i l t e r e d
I / O E v e n t s
P r o t o c o l
E v e n t s
<<IoHandler>>‘I/O Layer to Protocol Layer‘
Bridge
ProtocolFiltersF i l t e r e d
P r o t o c o l
E v e n t s
I/O Layer
Protocol Layer
Core
Extension Point
Protocol Implementation
Legend
![Page 25: Introduction to MINA A M ultipurpose I nfrastructure for N etwork A pplications April 2005, Trustin Lee, ASF](https://reader036.vdocuments.site/reader036/viewer/2022062423/56649e985503460f94b9b2a7/html5/thumbnails/25.jpg)
Conclusion
![Page 26: Introduction to MINA A M ultipurpose I nfrastructure for N etwork A pplications April 2005, Trustin Lee, ASF](https://reader036.vdocuments.site/reader036/viewer/2022062423/56649e985503460f94b9b2a7/html5/thumbnails/26.jpg)
Conclusion
MINA isa flexible and extensible
network application frameworkthat boosts developer productivity.
![Page 27: Introduction to MINA A M ultipurpose I nfrastructure for N etwork A pplications April 2005, Trustin Lee, ASF](https://reader036.vdocuments.site/reader036/viewer/2022062423/56649e985503460f94b9b2a7/html5/thumbnails/27.jpg)
How to Contribute
MINA is a subproject ofthe Apache Directory Project
Homepage:http://directory.apache.org/subprojects/network
Mailing List:[email protected] (Use ‘[mina]’ prefix)