ü\Óü¿Æ¼¼Íø

 ÕÒ»ØÃÜÂë
 Á¢¼´×¢²á
mito
²é¿´: 3157|»Ø¸´: 3

[JAVA] Java¶ÁÔ´ÂëÖ®NettyÉîÈëÆÊÎö ½âÎönetty¸÷´ó×é¼þϸ½Ú/°ÙÍò¼¶ÐÔÄܵ÷ÓÅ/Éè¼ÆÄ£...

[¸´ÖÆÁ´½Ó]

8Íò

Ö÷Ìâ

608

»ØÌû

27Íò

»ý·Ö

¹ÜÀíÔ±

Rank: 9Rank: 9Rank: 9

»ý·Ö
275170
QQ
·¢±íÓÚ 2018-9-21 08:49:36 | ÏÔʾȫ²¿Â¥²ã |ÔĶÁģʽ
¿Î³ÌÃû³Æ:  JAVA¶ÁÔ´ÂëÖ®NettyÉîÈëÆÊÎö ½âÎönetty¸÷´ó×é¼þϸ½Ú/°ÙÍò¼¶ÐÔÄܵ÷ÓÅ/Éè¼ÆÄ£Ê½Êµ¼ÊÔËÓÃ

¿Î³Ì¼ò½é:


ÕâÊÇÒ»ÃŶÔJAVA¿ª·¢ÈËÔ±·Ç³£ÖØÒªµÄ¿Î³Ì£¬Ô´ÂëµÄѧϰ·½Ê½ÊDz»¿ÉÌӱܵġ£NettyÒ²ÊÇ´óÐÍ»¥ÁªÍø¹«Ë¾ÃæÊԱر¸µÄÎÊÌ⣬Èç¹ûûÓзֲ¼Ê½¿ª·¢¾­Ñ飬ÔÚÃæÊÔʱÌá³ö×Ô¼ºÔĶÁ¹ýNettyÔ´Â룬²¢ÄÜÇåÎú±í´ïµÄ»°¡£¡£¿Î³Ì¶ÔNettyµÄÒªÇóÊÇֻҪʹÓùýNetty£¬Ð´¹ýһЩNetty·þÎñ¶ËºÍ¿Í»§¶ËͨÐŵĴúÂë¼´¿É£¬²»ÐèÒª·Ç³£ÊìÁ·£¬ÒòΪÕâÃſγ̵ÄÄ¿µÄ¾ÍÊÇΪÁËÈÃÄãÄܹ»·Ç³£ÊìÁ·Netty£¬ÕÆÎÕ¸ü¸ß¼¶±ðµÄÓ÷¨¡£


----------------------¿Î³ÌĿ¼------------------------------
1-1 NettyÉîÈëÆÊÎö


Netty»ù±¾×é¼þ
ʹÓÃÒ»¸ö¼òµ¥µÄsocketÀý×Ó¸ÅÀ¨NettyÀïÃæµÄ»ù±¾×é¼þ£¬°üÀ¨NioEventLoop£¬Channel£¬ByteBuf£¬Pipeline£¬ChannelHandler
2-1 Ò»¸ö¼òµ¥µÄsocketÀý×Ó
2-2 Netty¶ÔÓÚsocketµÄ³éÏó
2-3 Netty×é¼þ¼òµ¥½éÉÜ


Netty·þÎñ¶ËÆô¶¯
·ÖÎö·þÎñ¶ËÆô¶¯Á÷³Ì£¬°üÀ¨·þÎñ¶ËChannelµÄ´´½¨£¬³õʼ»¯£¬ÒÔ¼°×¢²áµ½selector
3-1 ·þÎñ¶ËÆô¶¯demo
3-2 ·þÎñ¶ËChannelµÄ´´½¨
3-3 ·þÎñ¶ËChannelµÄ³õʼ»¯
3-4 ×¢²áselector
3-5 ·þÎñ¶Ë¿ÚµÄ°ó¶¨
3-6 ·þÎñ¶ËÆô¶¯×ܽá


NioEventLoop
·ÖÎöNetty reactorÏ̴߳¦Àí¹ý³Ì£¬°üÀ¨Ê¼þ¼àÌý£¬Ê¼þ´¦Àí£¬³£¹æÈÎÎñ´¦ÀíºÍ¶¨Ê±ÈÎÎñ´¦Àí
4-1 NioEventLoop¸ÅÊö
4-2 NioEventLoop´´½¨¸ÅÊö
4-3 ThreadPerTaskThread
4-4 ´´½¨NioEventLoopÏß³Ì
4-5 ´´½¨Ïß³ÌÑ¡ÔñÆ÷
4-6 NioEventLoopµÄÆô¶¯
4-7 NioEventLoopÖ´ÐиÅÊö
4-8 ¼ì²âIOʼþ
4-9 ´¦ÀíIOʼþ
4-10 -reactorÏß³ÌÈÎÎñµÄÖ´ÐÐ
4-11 -NioEventLoop×ܽá


ÐÂÁ¬½Ó½ÓÈë
·ÖÎöÐÂÁ¬½Ó½ÓÈëÒÔ¼°°ó¶¨reactorỊ̈߳¬°ó¶¨µ½selectorµÄ¹ý³Ì
5-1 ÐÂÁ¬½Ó½ÓÈë¸ÅÊö
5-2 ÐÂÁ¬½Ó¼ì²â
5-3 NIOSocketChannelµÄ´´½¨
5-4 ChannelµÄ·ÖÀà
5-5 ÐÂÁ¬½ÓNioEventLoopµÄ·ÖÅäºÍselector×¢²á
5-6 NioSocketChannel¶ÁʼþµÄ×¢²á
5-7 ÐÂÁ¬½Ó½ÓÈë×ܽá


pipeline
·ÖÎöpipelineµÄ´´½¨£¬³õʼ»¯£¬Ìí¼ÓºÍɾ³ýChannelHandler£¬Ê¼þ´«²¥»úÖÆ£¬Òì³£´«²¥»úÖÆ
6-1 pipeline¸ÅÊö
6-2 pipeline³õʼ»¯
6-3 Ìí¼ÓChannelHandler
6-4 ɾ³ýChannelHandler
6-5 inBoundʼþµÄ´«²¥
6-6 outBoundʼþµÄ´«²¥
6-7 Òì³£µÄ´«²¥
6-8 pipeline×ܽá.mp4


ByteBuf
Ïêϸ·ÖÎöByteBufÖÖÀ࣬ÈçºÎ¼õÉÙ¶àÏß³ÌÄÚ´æ·ÖÅ侺Õù£¬²»Í¬´óСÄÚ´æÊÇÈçºÎ·ÖÅäµÄ
7-1 ÄÚ´æ·ÖÅä¸ÅÊö
7-2 ByteBuf½á¹¹ÒÔ¼°ÖØÒªapi
7-3 ByteBuf·ÖÀà
7-4 ÄÚ´æ·ÖÅäÆ÷ByteBufAllocator·ÖÎö
7-5 UnPooledByteBufAllocator·ÖÎö
7-6 PooledByteBufAllocator¸ÅÊö
7-7 directArena·ÖÅädirectÄÚ´æµÄÁ÷³Ì
7-8 ÄÚ´æ¹æ¸ñµÄ½éÉÜ
7-9 »º´æÊý¾Ý½á¹¹
7-10 ÃüÖлº´æµÄ·ÖÅäÁ÷³Ì
7-11 arena¡¢chunk¡¢page¡¢subpage¸ÅÄî
7-12 page ¼¶±ðÄÚ´æ·ÖÅä
7-13 subpage ¼¶±ðµÄÄÚ´æ·ÖÅä
7-14 ByteBufµÄ»ØÊÕ
7-15 ×ܽá


Netty½âÂë
Ïêϸ·ÖÎöNetty½âÂëÔ­Àí£¬½âÂëÆ÷³éÏó£¬ÒÔ¼°¼¸ÖÖ³£¼ûµÄ½âÂëÆ÷
8-1 Netty½âÂë¸ÅÊö
8-2 ³éÏó½âÂëÆ÷ByteToMessageDecoder
8-3 »ùÓڹ̶¨³¤¶È½âÂëÆ÷·ÖÎö
8-4 ÐнâÂëÆ÷·ÖÎö
8-5 »ùÓÚ·Ö¸ô·û½âÂëÆ÷·ÖÎö
8-6 »ùÓÚ³¤¶ÈÓò½âÂëÆ÷²ÎÊý·ÖÎö
8-7 »ùÓÚ³¤¶ÈÓò½âÂëÆ÷·ÖÎö
8-8 ½âÂëÆ÷×ܽá


Netty±àÂë¼°writeAndFlush()
writeAndFlush´«²¥Á÷³Ì£¬±àÂëÆ÷³éÏó£¬writeAndFlushÏêϸÁ÷³Ì
9-1 Netty±àÂë¸ÅÊö
9-2 writeAndFlush()³éÏó²½Öè
9-3 ³éÏó±àÂëÆ÷MessageToByteEncoder
9-4 дbuffer¶ÓÁÐ
9-5 Ë¢ÐÂbuffer¶ÓÁÐ
9-6 ×ܽá


NettyÐÔÄÜÓÅ»¯¹¤¾ßÀà½âÎö
Ïêϸ·ÖÎöNettyÀïÃæ×î¸ßƵʹÓõÄÁ½¸öÐÔÄÜÓÅ»¯ÀàFastThreadLocalÒÔ¼°ÇáÁ¿¼¶¶ÔÏó³ØRecycler
10-1 ÐÔÄÜÓÅ»¯¹¤¾ßÀà¸ÅÊö
10-2 FastThreadLocalµÄʹÓÃ
10-3 FastThreadLocalµÄ´´½¨ºÍget()ʵÏÖ
10-4 FastThreadLocalµÄsetʵÏÖ
10-5 RecyclerµÄʹÓÃ
10-6 RecyclerµÄ´´½¨
10-7 ´ÓRecyclerÖлñÈ¡¶ÔÏó
10-8 ͬÏ̻߳ØÊÕ¶ÔÏó
10-9 ÒìÏ̻߳ØÊÕ¶ÔÏó
10-10 ÒìÏß³ÌÊÕ¸î¶ÔÏó
10-11 ÐÔÄÜÓÅ»¯¹¤¾ßÀà×ܽá


NettyÉè¼ÆÄ£Ê½Ó¦ÓÃ
·ÖÎö¸÷Àà³£¼ûÉè¼ÆÄ£Ê½ÒÔ¼°ÔÚNettyÖеÄÓ¦ÓÃ
11-1 µ¥ÀýģʽÔÚNettyÀïÃæµÄÓ¦ÓÃ
11-2 ²ßÂÔģʽÔÚNettyÀïÃæµÄÓ¦ÓÃ
11-3 ×°ÊÎÕßģʽÔÚNettyÀïÃæµÄÓ¦ÓÃ
11-4 ¹Û²ìÕßģʽÔÚNettyÀïÃæµÄÓ¦ÓÃ
11-5 µü´úÆ÷ģʽÔÚNettyÀïÃæµÄÓ¦ÓÃ
11-6 ÔðÈÎÁ´Ä£Ê½ÔÚNettyÀïÃæµÄÓ¦ÓÃ


Netty¸ßÐÔÄܲ¢·¢µ÷ÓÅ
ϵͳ²ãÃæµ¥»úÈçºÎÖ§³Ö°ÙÍòÁ¬½Ó£¬ÈçºÎÌáÉýÓ¦ÓòãÃæÐÔÄÜ
12-1 ÐÔÄܵ÷ÓŸÅÊö
12-2 µ¥»ú°ÙÍòÁ¬½ÓÄ£ÄâÓëÆ¿¾±
12-3 µ¥»ú°ÙÍòÁ¬½Óµ÷ÓŹý³Ì
12-4 NettyÓ¦Óü¶±ðÐÔÄÜÆ¿¾±
12-5 NettyÓ¦Óü¶±ðÐÔÄܵ÷ÓŹý³Ì



ÏÂÔØµØÖ·£º
Óοͣ¬Èç¹ûÄúÒª²é¿´±¾ÌûÒþ²ØÄÚÈÝÇë»Ø¸´





¸ü¶àÌû×ÓÍÆ¼ö

»Ø¸´

ʹÓõÀ¾ß ¾Ù±¨

tcdaluo ¸ÃÓû§Òѱ»É¾³ý
·¢±íÓÚ 2018-9-28 14:50:33 | ÏÔʾȫ²¿Â¥²ã
Ìáʾ: ×÷Õß±»½ûÖ¹»òɾ³ý ÄÚÈÝ×Ô¶¯ÆÁ±Î
»Ø¸´

ʹÓõÀ¾ß ¾Ù±¨

0

Ö÷Ìâ

679

»ØÌû

1578

»ý·Ö

½ðÅÆ»áÔ±

Rank: 5Rank: 5

»ý·Ö
1578
·¢±íÓÚ 2018-11-15 20:14:09 | ÏÔʾȫ²¿Â¥²ã
ava¶ÁÔ´ÂëÖ®NettyÉîÈëÆÊÎö ½âÎönetty¸÷´ó×é¼þϸ½Ú
»Ø¸´

ʹÓõÀ¾ß ¾Ù±¨

0

Ö÷Ìâ

2Íò

»ØÌû

4Íò

»ý·Ö

½ûÖ¹·ÃÎÊ

»ý·Ö
41607
·¢±íÓÚ 2021-10-11 17:56:05 | ÏÔʾȫ²¿Â¥²ã
Ìáʾ: ×÷Õß±»½ûÖ¹»òɾ³ý ÄÚÈÝ×Ô¶¯ÆÁ±Î
»Ø¸´

ʹÓõÀ¾ß ¾Ù±¨

QQ|Archiver|ÊÖ»ú°æ|ü\Óü¿Æ¼¼Íø

GMT+8, 2025-11-30 07:27 , Processed in 0.199211 second(s), 26 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

¿ìËٻظ´ ·µ»Ø¶¥²¿ ·µ»ØÁбí