Download Introduction to MINA

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
Introduction to MINA
Trustin Lee
[email protected]
http://people.apache.org/~trustin/
Agenda
•
•
•
•
•
December 13, 2005
Overview
In-depth View
Implementation Demo
Future
Conclusion
ApacheCon US 2005
2
Overview
A Multipurpose Infrastructure for Network Applications
Overview
What is MINA?
• An acronym for
A Multipurpose
Infrastructure
For Network
Applications
• A network application framework
• A subproject of
• the Apache Directory Project
December 13, 2005
ApacheCon US 2005
4
Overview
Features
• Unified API
• Easy
• Event-driven
• Abstracted from existing I/O APIs
• Elegant application design
December 13, 2005
ApacheCon US 2005
5
Overview
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>
December 13, 2005
ApacheCon US 2005
6
Overview
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
December 13, 2005
ApacheCon US 2005
7
Overview
Who Uses MINA?
• The Apache Directory Project
• LDAP
• Kerberos
• DNS
• NTP
• 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
December 13, 2005
ApacheCon US 2005
8
In-depth View
A Multipurpose Infrastructure for Network Applications
In-depth
At the First Glance
Low-level
I/O
Low-level
I/O
Remote Peer
I/O Event
Filtered I/O
Request
IoSessionManager
IoFilterChain
IoFilter #1
IoFilter #2
Filtered I/O
Event
I/O
Request
IoFilter #3
IoSession
IoHandler
December 13, 2005
Legend
Core
Extension Point
Protocol Implementation
• 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
ApacheCon US 2005
10
In-depth
IoSessionManagers
Server-side:
Accepts clients
IoSessionManager
IoAcceptor
nio::SocketAcceptor
IoConnector
And their
implementations
nio::DatagramAcceptor
nio::SocketConnector
nio::DatagramConnector
v mpipe::VmPipeAcceptor
December 13, 2005
Client-side:
Connects to a server
v mpipe::VmPipeConnector
ApacheCon US 2005
11
In-depth
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
December 13, 2005
ApacheCon US 2005
12
In-depth
IoHandler
• Where you implement your network
application
«interface»
common::IoHandler
~
~
~
~
~
~
~
December 13, 2005
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
ApacheCon US 2005
13
In-depth
IoFilter
• A reusable event & request interceptor
• Hot-deployable
• Scope:
• An IoSession or an IoSessionManager
Event A
December 13, 2005
IoFilter
ApacheCon US 2005
Event A’
14
In-depth
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
December 13, 2005
ApacheCon US 2005
15
In-depth
Thread Pooling with IoFilter
No thread pool: single thread setting for minimal latency
IoAcceptor
IoHandler
One thread pool: general setting for high throughput
Thread
Pool
Filter
IoAcceptor
IoHandler
More than one thread pool: special setting for CPU-intensive jobs
IoAcceptor
December 13, 2005
Thread
Pool
Filter
CPUintensive
jobs
(IoFilter)
ApacheCon US 2005
Thread
Pool
Filter
IoHandler
16
In-depth
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
December 13, 2005
ApacheCon US 2005
17
In-depth
Protocol Codec (Cont’d)
Legend
Remote Peer
Core
Low-level
I/O
Low-level
I/O
Extension Point
Protocol Implementation
Filtered I/O
Event
I/O
Request
Decode
Decoder
ProtocolCodecFilter
Encode
Encoder
IoFilterChain
Protocol Codec Factory
I/O Event
Filtered I/O
Request
IoSessionManager
IoSession
IoHandler
December 13, 2005
ApacheCon US 2005
18
In-depth
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
December 13, 2005
ApacheCon US 2005
19
Implementation Demo
A Multipurpose Infrastructure for Network Applications
Demo
More Complex Examples
• Realistic examples:
• Visit Here:
http://directory.apache.org
/subprojects/network/getting_started.html
December 13, 2005
ApacheCon US 2005
21
Future
A Multipurpose Infrastructure for Network Applications
Future
MINA as a Platform
Real-Time
Management
System
Integration
with Apache
ASN.1 for
complex protocols
HTTP
SMTP
FTP
……
Popular
Protocols
Rapidly
Users
can build customized
Just like drawing
servers
Prototyped
Kerberos
with
ready-made protocol
an ER
Diagrams!
codecs.
Protocol
Visual Protocol
Designer
(ASN.1-based)
LDAP
Others
ASN.1
Codec
MINA
December 13, 2005
ApacheCon US 2005
23
Future
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>
December 13, 2005
ApacheCon US 2005
24
Future
We Need Your Participation!
• Sounds exciting?
• Please help MINA team!
• Try MINA
• Ask questions
• Criticize
• Report bugs
• Benchmark
• Contribute code
• Contribute a tutorial
December 13, 2005
ApacheCon US 2005
25
Conclusion
A Multipurpose Infrastructure for Network Applications
Conclusion
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.
December 13, 2005
ApacheCon US 2005
27
Resources
• Homepage
• http://directory.apache.org/subprojects/network/
• Mailing List
• [email protected]
(Please use ‘[mina] prefix)
December 13, 2005
ApacheCon US 2005
28
Thank You!
Q&A
Related documents