In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces the example analysis of the Dispatcher module in ceph, which has a certain reference value, and interested friends can refer to it. I hope you will gain a lot after reading this article.
The Dipatcher class is the interface of message distribution. OSD, MON, and other classes all inherit this class, and implement the message distribution interface of Dipatcher.
1079 class OSD: public Dispatcher,- 1080 public md_config_obs_t {| 1081 / * * OSD * * / 128class Monitor: public Dispatcher,- 129public md_config_obs_t {| 1079 public: | 131l / / me | 132string name
Add different types of Dipatcher to the SimpleMessenger instance in the OSD::init () function
| | 2146 / / add_dispatcher_head ready! | 2147 client_messenger- > add_dispatcher_head (this); | 2148 cluster_messenger- > add_dispatcher_head (this); | 2149 | 2150 hbclient_messenger- > add_dispatcher_head (& heartbeat_dispatcher); | 2151 hb_front_server_messenger- > add_dispatcher_head (& heartbeat_dispatcher); | 2152 hb_back_server_messenger- > add_dispatcher_head (& heartbeat_dispatcher) | | | 2153 | 2154 objecter_messenger- > add_dispatcher_head (service.objecter) |
Add Messenger::list dispatchers to Messenger::add_dispatcher_head (Dispatcher * d) and call ready (), which overrides the ready of the base class.
| |-358 void add_dispatcher_head (Dispatcher * d) {| | 359 bool first = dispatchers.empty (); | | 360 dispatchers.push_front (d); | | 361 if (d-> ms_can_fast_dispatch_any ()) | | 362fast_dispatchers.push_front (d); | | 363if (first) | | 364 ready (); | | 365} |
Call DispatchQueue::start in the ready function, the start () function starts the DispatchQueue::DispatchThread and DispatchQueue:: LocalDeliveryThread thread classes, and finally calls DispatchQueue::entry () and DispatchQueue::run_local_delivery.
216 void DispatchQueue::start ()-217 {| 218 assert (! stop); | 219 assert (! dispatch_thread.is_started ()); | 220 dispatch_thread.create ("ms_dispatch"); / / call Thread::create- > Thread::try_create- > Thread::_entry_func- > Thread::entry_wrapper- > DispatchThread::entry | 221 local_delivery_thread.create ("ms_local") | | 98 class DispatchThread: public Thread {| | 99 DispatchQueue * dq; | | 100 public: | 101 explicit DispatchThread (DispatchQueue * dq): dq (dq) {} | |-102 void * entry () {| | 103 dq- > entry (); | | 104 return 0; | | 105} | 106} dispatch_thread |
Call handlers in different Messenger classes according to different command codes in DispatchQueue::entry ()
Void DispatchQueue::entry () {. . Switch (qitem.get_code ()) {case D_BAD_REMOTE_RESET: msgr- > ms_deliver_handle_remote_reset (qitem.get_connection ()); break; case D_CONNECT: msgr- > ms_deliver_handle_connect (qitem.get_connection ()); break; case D_ACCEPT: msgr- > ms_deliver_handle_accept (qitem.get_connection ()) Break; case D_BAD_RESET: msgr- > ms_deliver_handle_reset (qitem.get_connection ()); break; default: assert (0);} else {Message * m = qitem.get_message (); if (stop) {ldout (cct,10)
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.