TU14. Introduction to MINA -...
Transcript of TU14. Introduction to MINA -...
![Page 2: TU14. Introduction to MINA - home.apache.orgpeople.apache.org/~jim/ApacheCons/ApacheCon2005/slides/TU14/Intro... · Introduction to MINA Trustin Lee ... •Proprietary SMPP / SMS](https://reader031.fdocuments.in/reader031/viewer/2022021819/5ac195f57f8b9a1c768cf0cd/html5/thumbnails/2.jpg)
December 13, 2005 ApacheCon US 2005 2
Agenda
• Overview• In-depth View• Implementation Demo• Future• Conclusion
![Page 3: TU14. Introduction to MINA - home.apache.orgpeople.apache.org/~jim/ApacheCons/ApacheCon2005/slides/TU14/Intro... · Introduction to MINA Trustin Lee ... •Proprietary SMPP / SMS](https://reader031.fdocuments.in/reader031/viewer/2022021819/5ac195f57f8b9a1c768cf0cd/html5/thumbnails/3.jpg)
OverviewA Multipurpose Infrastructure for Network Applications
![Page 4: TU14. Introduction to MINA - home.apache.orgpeople.apache.org/~jim/ApacheCons/ApacheCon2005/slides/TU14/Intro... · Introduction to MINA Trustin Lee ... •Proprietary SMPP / SMS](https://reader031.fdocuments.in/reader031/viewer/2022021819/5ac195f57f8b9a1c768cf0cd/html5/thumbnails/4.jpg)
December 13, 2005 ApacheCon US 2005 4
What is MINA?
• An acronym forA Multipurpose
InfrastructureFor Network
Applications
• A network application framework• A subproject of
• the Apache Directory Project
Overview
![Page 5: TU14. Introduction to MINA - home.apache.orgpeople.apache.org/~jim/ApacheCons/ApacheCon2005/slides/TU14/Intro... · Introduction to MINA Trustin Lee ... •Proprietary SMPP / SMS](https://reader031.fdocuments.in/reader031/viewer/2022021819/5ac195f57f8b9a1c768cf0cd/html5/thumbnails/5.jpg)
December 13, 2005 ApacheCon US 2005 5
Features
• Unified API• Easy• Event-driven• Abstracted from existing I/O APIs• Elegant application design
Overview
![Page 6: TU14. Introduction to MINA - home.apache.orgpeople.apache.org/~jim/ApacheCons/ApacheCon2005/slides/TU14/Intro... · Introduction to MINA Trustin Lee ... •Proprietary SMPP / SMS](https://reader031.fdocuments.in/reader031/viewer/2022021819/5ac195f57f8b9a1c768cf0cd/html5/thumbnails/6.jpg)
December 13, 2005 ApacheCon US 2005 6
Supported Transport Layers
• Out-of-the-box• Based on Java NIO (New I/O)
• Socket (TCP/IP)• Datagram (UDP/IP)
• In-VM pipe
• Pending:• Multicast• Serial and parallel port• <your favorite one>
Overview
![Page 7: TU14. Introduction to MINA - home.apache.orgpeople.apache.org/~jim/ApacheCons/ApacheCon2005/slides/TU14/Intro... · Introduction to MINA Trustin Lee ... •Proprietary SMPP / SMS](https://reader031.fdocuments.in/reader031/viewer/2022021819/5ac195f57f8b9a1c768cf0cd/html5/thumbnails/7.jpg)
December 13, 2005 ApacheCon US 2005 7
Elegant Application Design
• Unit test friendly• The Abstract API lets you test your
application without a real client or server via mock objects.
• Extensible• Runtime modification of application
behavior using ‘filters’
• Maintainable and Reusable• Separation of networking code (MINA),
protocol codec, and business logic
Overview
![Page 8: TU14. Introduction to MINA - home.apache.orgpeople.apache.org/~jim/ApacheCons/ApacheCon2005/slides/TU14/Intro... · Introduction to MINA Trustin Lee ... •Proprietary SMPP / SMS](https://reader031.fdocuments.in/reader031/viewer/2022021819/5ac195f57f8b9a1c768cf0cd/html5/thumbnails/8.jpg)
December 13, 2005 ApacheCon US 2005 8
Who Uses MINA?• The Apache Directory Project
• QuickFIX – QuickFIXEngine.org• Financial Information eXchange Protocol
• RED5 Server – OSFlash.org• Macromedia Flash Media RTMP
• JStyx – JStyx.sf.net• Styx, a file sharing NFS-like protocol
• Proprietary SMPP / SMS servers
• DNS• NTP
• LDAP• Kerberos
Overview
![Page 9: TU14. Introduction to MINA - home.apache.orgpeople.apache.org/~jim/ApacheCons/ApacheCon2005/slides/TU14/Intro... · Introduction to MINA Trustin Lee ... •Proprietary SMPP / SMS](https://reader031.fdocuments.in/reader031/viewer/2022021819/5ac195f57f8b9a1c768cf0cd/html5/thumbnails/9.jpg)
In-depth ViewA Multipurpose Infrastructure for Network Applications
![Page 10: TU14. Introduction to MINA - home.apache.orgpeople.apache.org/~jim/ApacheCons/ApacheCon2005/slides/TU14/Intro... · Introduction to MINA Trustin Lee ... •Proprietary SMPP / SMS](https://reader031.fdocuments.in/reader031/viewer/2022021819/5ac195f57f8b9a1c768cf0cd/html5/thumbnails/10.jpg)
December 13, 2005 ApacheCon US 2005 10
At the First GlanceRemote Peer
IoSessionManager
IoHandler
IoFilterChain
Core
Extension Point
Protocol Implementation
Legend
IoFilter #1
IoFilter #2
IoFilter #3
IoSession
• IoSessionManager• Where real I/O occurs• Generates I/O events• Processes I/O requests
• IoFilters• Filters I/O events and requests
• IoHandler• <Your protocol logic>
• IoSession• Represents a connection
In-depth
![Page 11: TU14. Introduction to MINA - home.apache.orgpeople.apache.org/~jim/ApacheCons/ApacheCon2005/slides/TU14/Intro... · Introduction to MINA Trustin Lee ... •Proprietary SMPP / SMS](https://reader031.fdocuments.in/reader031/viewer/2022021819/5ac195f57f8b9a1c768cf0cd/html5/thumbnails/11.jpg)
December 13, 2005 ApacheCon US 2005 11
IoSessionManagersIn-depth
IoAcceptor IoConnector
nio::DatagramConnector
nio::SocketConnector
vmpipe::VmPipeAcceptor vmpipe::VmPipeConnector
nio::DatagramAcceptor
nio::SocketAcceptor
IoSessionManagerServer-side:
Accepts clientsClient-side:Connects to a server
And their implementations
![Page 12: TU14. Introduction to MINA - home.apache.orgpeople.apache.org/~jim/ApacheCons/ApacheCon2005/slides/TU14/Intro... · Introduction to MINA Trustin Lee ... •Proprietary SMPP / SMS](https://reader031.fdocuments.in/reader031/viewer/2022021819/5ac195f57f8b9a1c768cf0cd/html5/thumbnails/12.jpg)
December 13, 2005 ApacheCon US 2005 12
IoSession
• A connection between an IoHandler and a remote peer• Provides ways to send an I/O request
• Write a message• Close the current connection
• State information• Idleness• Last I/O time
• Transport layer parameters• Attributes: Protocol-specific data storage
In-depth
![Page 13: TU14. Introduction to MINA - home.apache.orgpeople.apache.org/~jim/ApacheCons/ApacheCon2005/slides/TU14/Intro... · Introduction to MINA Trustin Lee ... •Proprietary SMPP / SMS](https://reader031.fdocuments.in/reader031/viewer/2022021819/5ac195f57f8b9a1c768cf0cd/html5/thumbnails/13.jpg)
December 13, 2005 ApacheCon US 2005 13
IoHandler• Where you implement your network
application
«interface»common::IoHandler
~ sessionCreated(IoSession) : void~ sessionOpened(IoSession) : void~ sessionClosed(IoSession) : void~ sessionIdle(IoSession, IdleStatus) : void~ exceptionCaught(IoSession, Throwable) : void~ messageReceived(IoSession, Object) : void~ messageSent(IoSession, Object) : void
In-depth
![Page 14: TU14. Introduction to MINA - home.apache.orgpeople.apache.org/~jim/ApacheCons/ApacheCon2005/slides/TU14/Intro... · Introduction to MINA Trustin Lee ... •Proprietary SMPP / SMS](https://reader031.fdocuments.in/reader031/viewer/2022021819/5ac195f57f8b9a1c768cf0cd/html5/thumbnails/14.jpg)
December 13, 2005 ApacheCon US 2005 14
IoFilter
• A reusable event & request interceptor• Hot-deployable
• Scope:• An IoSession or an IoSessionManager
In-depth
![Page 15: TU14. Introduction to MINA - home.apache.orgpeople.apache.org/~jim/ApacheCons/ApacheCon2005/slides/TU14/Intro... · Introduction to MINA Trustin Lee ... •Proprietary SMPP / SMS](https://reader031.fdocuments.in/reader031/viewer/2022021819/5ac195f57f8b9a1c768cf0cd/html5/thumbnails/15.jpg)
December 13, 2005 ApacheCon US 2005 15
IoFilter (Cont’d)
• Out-of-the box filters:• SSL / TLS• Remote peer blacklisting• Thread pool• Logger
• Pending filters:• Profiler• Traffic throttle• Lightweight firewall• Overload prevention
In-depth
![Page 16: TU14. Introduction to MINA - home.apache.orgpeople.apache.org/~jim/ApacheCons/ApacheCon2005/slides/TU14/Intro... · Introduction to MINA Trustin Lee ... •Proprietary SMPP / SMS](https://reader031.fdocuments.in/reader031/viewer/2022021819/5ac195f57f8b9a1c768cf0cd/html5/thumbnails/16.jpg)
December 13, 2005 ApacheCon US 2005 16
IoAcceptor IoHandler
No thread pool: single thread setting for minimal latency
Thread Pooling with IoFilter
IoAcceptorThread
PoolFilter
IoHandler
One thread pool: general setting for high throughput
In-depth
![Page 17: TU14. Introduction to MINA - home.apache.orgpeople.apache.org/~jim/ApacheCons/ApacheCon2005/slides/TU14/Intro... · Introduction to MINA Trustin Lee ... •Proprietary SMPP / SMS](https://reader031.fdocuments.in/reader031/viewer/2022021819/5ac195f57f8b9a1c768cf0cd/html5/thumbnails/17.jpg)
December 13, 2005 ApacheCon US 2005 17
Protocol Codec
• By default,• IoHandler uses a ByteBuffer to do I/O⇒ Tight coupling of
protocol codec and business logic :(
• ProtocolCodecFilter is an IoFilter• Performs transformation between
a ByteBuffer and a POJO (Plain Old Java Object)
⇒ Clear separation
In-depth
![Page 18: TU14. Introduction to MINA - home.apache.orgpeople.apache.org/~jim/ApacheCons/ApacheCon2005/slides/TU14/Intro... · Introduction to MINA Trustin Lee ... •Proprietary SMPP / SMS](https://reader031.fdocuments.in/reader031/viewer/2022021819/5ac195f57f8b9a1c768cf0cd/html5/thumbnails/18.jpg)
December 13, 2005 ApacheCon US 2005 18
Protocol Codec (Cont’d)Remote Peer
IoSessionManager
IoHandler
IoFilterChain
Core
Extension Point
Protocol Implementation
Legend
IoSession
ProtocolCodecFilterEncode
Decode
In-depth
![Page 19: TU14. Introduction to MINA - home.apache.orgpeople.apache.org/~jim/ApacheCons/ApacheCon2005/slides/TU14/Intro... · Introduction to MINA Trustin Lee ... •Proprietary SMPP / SMS](https://reader031.fdocuments.in/reader031/viewer/2022021819/5ac195f57f8b9a1c768cf0cd/html5/thumbnails/19.jpg)
December 13, 2005 ApacheCon US 2005 19
In-VM Pipe Transport Type
• A virtual pipe• Requires no protocol codec• I/O events and requests are converted into
direct method invocations.
• Two MINA servers in the same VM• Can bypass:
• Protocol codec• Network latency
In-depth
![Page 20: TU14. Introduction to MINA - home.apache.orgpeople.apache.org/~jim/ApacheCons/ApacheCon2005/slides/TU14/Intro... · Introduction to MINA Trustin Lee ... •Proprietary SMPP / SMS](https://reader031.fdocuments.in/reader031/viewer/2022021819/5ac195f57f8b9a1c768cf0cd/html5/thumbnails/20.jpg)
Implementation DemoA Multipurpose Infrastructure for Network Applications
![Page 21: TU14. Introduction to MINA - home.apache.orgpeople.apache.org/~jim/ApacheCons/ApacheCon2005/slides/TU14/Intro... · Introduction to MINA Trustin Lee ... •Proprietary SMPP / SMS](https://reader031.fdocuments.in/reader031/viewer/2022021819/5ac195f57f8b9a1c768cf0cd/html5/thumbnails/21.jpg)
December 13, 2005 ApacheCon US 2005 21
More Complex Examples
• Realistic examples:• Visit Here:
http://directory.apache.org/subprojects/network/getting_started.html
Demo
![Page 22: TU14. Introduction to MINA - home.apache.orgpeople.apache.org/~jim/ApacheCons/ApacheCon2005/slides/TU14/Intro... · Introduction to MINA Trustin Lee ... •Proprietary SMPP / SMS](https://reader031.fdocuments.in/reader031/viewer/2022021819/5ac195f57f8b9a1c768cf0cd/html5/thumbnails/22.jpg)
FutureA Multipurpose Infrastructure for Network Applications
![Page 23: TU14. Introduction to MINA - home.apache.orgpeople.apache.org/~jim/ApacheCons/ApacheCon2005/slides/TU14/Intro... · Introduction to MINA Trustin Lee ... •Proprietary SMPP / SMS](https://reader031.fdocuments.in/reader031/viewer/2022021819/5ac195f57f8b9a1c768cf0cd/html5/thumbnails/23.jpg)
December 13, 2005 ApacheCon US 2005 23
Integration with Apache ASN.1 for complex protocols
Users can build customized servers with ready-made protocol codecs.
Design custom protocols just like drawing a UML!
MINA as a PlatformFuture
HTTP
SMTP
FTP
……
Popular Protocols
Visual Protocol Designer
(ASN.1-based)
Rapidly Prototyped Protocol
Others
![Page 24: TU14. Introduction to MINA - home.apache.orgpeople.apache.org/~jim/ApacheCons/ApacheCon2005/slides/TU14/Intro... · Introduction to MINA Trustin Lee ... •Proprietary SMPP / SMS](https://reader031.fdocuments.in/reader031/viewer/2022021819/5ac195f57f8b9a1c768cf0cd/html5/thumbnails/24.jpg)
December 13, 2005 ApacheCon US 2005 24
Real-Time Management System
• A universal management view• JMX console and Web browser• Real time access
• Server traffic• IoFilter Hot-deploy• Which client is sending what message now?• Which message takes toolong to process?• And <what you want to monitor>
Future
![Page 25: TU14. Introduction to MINA - home.apache.orgpeople.apache.org/~jim/ApacheCons/ApacheCon2005/slides/TU14/Intro... · Introduction to MINA Trustin Lee ... •Proprietary SMPP / SMS](https://reader031.fdocuments.in/reader031/viewer/2022021819/5ac195f57f8b9a1c768cf0cd/html5/thumbnails/25.jpg)
December 13, 2005 ApacheCon US 2005 25
We Need Your Participation!
• Sounds exciting?• Please help MINA team!
• Try MINA• Ask questions• Criticize• Report bugs• Benchmark• Contribute code• Contribute a tutorial
Future
![Page 26: TU14. Introduction to MINA - home.apache.orgpeople.apache.org/~jim/ApacheCons/ApacheCon2005/slides/TU14/Intro... · Introduction to MINA Trustin Lee ... •Proprietary SMPP / SMS](https://reader031.fdocuments.in/reader031/viewer/2022021819/5ac195f57f8b9a1c768cf0cd/html5/thumbnails/26.jpg)
ConclusionA Multipurpose Infrastructure for Network Applications
![Page 27: TU14. Introduction to MINA - home.apache.orgpeople.apache.org/~jim/ApacheCons/ApacheCon2005/slides/TU14/Intro... · Introduction to MINA Trustin Lee ... •Proprietary SMPP / SMS](https://reader031.fdocuments.in/reader031/viewer/2022021819/5ac195f57f8b9a1c768cf0cd/html5/thumbnails/27.jpg)
December 13, 2005 ApacheCon US 2005 27
Conclusion
• MINA is an extensible network application framework that helps you implement your network application elegantly without compromising productivity.
• MINA can be a complete network application development & management platform if we get our effort together.
Conclusion
![Page 28: TU14. Introduction to MINA - home.apache.orgpeople.apache.org/~jim/ApacheCons/ApacheCon2005/slides/TU14/Intro... · Introduction to MINA Trustin Lee ... •Proprietary SMPP / SMS](https://reader031.fdocuments.in/reader031/viewer/2022021819/5ac195f57f8b9a1c768cf0cd/html5/thumbnails/28.jpg)
December 13, 2005 ApacheCon US 2005 28
Resources
• Homepage• http://directory.apache.org/subprojects/network/
• Mailing List• [email protected]
(Please use ‘[mina] prefix)
![Page 29: TU14. Introduction to MINA - home.apache.orgpeople.apache.org/~jim/ApacheCons/ApacheCon2005/slides/TU14/Intro... · Introduction to MINA Trustin Lee ... •Proprietary SMPP / SMS](https://reader031.fdocuments.in/reader031/viewer/2022021819/5ac195f57f8b9a1c768cf0cd/html5/thumbnails/29.jpg)
Thank You!Q & A