rgw && message

原链接

http://blog.csdn.net/litianze99/article/details/51489550


librados::IoCtxImpl::operate_read()                    //do read operation
    Objecter:md_config_obs_t:Dispatcher
        prepare_read_op()                              //new a Op instance is used by Objecter
        op_submit()                                    //submit operation
            _op_submit_with_budget()
                _op_submit()
                    _cal_target()                       //1.cacluate th up/active OSD sets 2.select primary osd as the target
                    _get_session()                      //1.Objecter keeps an OSDSession with each osd 2.new MOSDOp which will be used by OSD
                    _prepare_osd_osd_op()
                    _session_op_assign()                
                    _send_op()
                        op->session-con->send_message()
                            SimpleMessager->send_message()
                                _send_message()
                                    submit_message()
                                        Pip->_send(m)
                                            Pip->cond.signal()
                                                |
                                                |
                                            Pipe::write()
                                                _get_next_outgoing()
                                                write_message()
                                                    do_sendmsg()
                                                        sendmsg()


OSDSession *s = new OSDSession(cct, osd);
  osd_sessions[osd] = s;
  s->con = messenger->get_connection(osdmap->get_inst(osd));
  logger->inc(l_osdc_osd_session_open);
  logger->inc(l_osdc_osd_sessions, osd_sessions.size());
  s->get();
  *session = s;

using SimpleMessager
SimpleMessenger::get_connection()
    return local_connection  //if my_instd.addr equal dest.addr
    _lookup_pipe(dest.addr)  //if don't found exsit pipe we will new a pipe instance


 // create pipe
  Pipe *pipe = new Pipe(this, Pipe::STATE_CONNECTING,
            static_cast<PipeConnection*>(con));
  pipe->pipe_lock.Lock();
  pipe->set_peer_type(type);
  pipe->set_peer_addr(addr);
  pipe->policy = get_policy(type);
  pipe->start_writer();
  if (first)
    pipe->_send(first);
  pipe->pipe_lock.Unlock();
  pipe->register_pipe();                         //add pip instance to SimpleMessager->rack_pipe map
  pipes.insert(pipe);                            //add pip instance to SimpleMessager->pipes set

  return pipe;

 client side commponents Messager
 Responsibility
    a network entity in ceph
    handles transmission and reception osd messages
    based on socket
 Implementation
    SimpleMessenger
    AsyncMessenger
    Xio
 Role
    cluster_messenger:responsible for communicationg with other OSDs/Monitors
    client_messenger: responsible for communicating with client(qemu/kvm、ceph-fuse,etc)
    hbclient_messenger、hb_front_server_messenger hb_back_server_messenger



 SimpleMessager:

/*
 * This class handles transmission and reception of messages. Generally
 * speaking, there are several major components:
 *
 * - Connection(PipConnection)
 *    Each logical session is associated with a Connection.
 * - Pipe
 *    Each network connection is handled through a pipe, which handles
 *    the input and output of each message.  There is normally a 1:1
 *    relationship between Pipe and Connection, but logical sessions may
 *    get handed off between Pipes when sockets reconnect or during
 *    connection races.
 * - IncomingQueue
 *    Incoming messages are associated with an IncomingQueue, and there
 *    is one such queue associated with each Pipe.
 * - DispatchQueue
 *    IncomingQueues get queued in the DIspatchQueue, which is responsible
 *    for doing a round-robin sweep and processing them via a worker thread.
 * - SimpleMessenger
 *    It's the exterior class passed to the external message handler and
 *    most of the API details.
 *
 * Lock ordering:
 *
 *   SimpleMessenger::lock
 *       Pipe::pipe_lock
 *           DispatchQueue::lock
 *               IncomingQueue::lock
 */

 Accepter:
 /**
 * If the SimpleMessenger binds to a specific address, the Accepter runs
 * and listens for incoming connections.
 */


 DispatchQueue:
 /**
 * The DispatchQueue contains all the Pipes which have Messages
 * they want to be dispatched, carefully organized by Message priority
 * and permitted to deliver in a round-robin fashion.
 * See SimpleMessenger::dispatch_entry for details.
 */

 DispatchThread (in DispatchQueue)
  /**
   * The DispatchThread runs dispatch_entry to empty out the dispatch_queue.
   */


 Pip
 /**
   * The Pipe is the most complex SimpleMessenger component. It gets
   * two threads, one each for reading and writing on a socket it's handed
   * at creation time, and is responsible for everything that happens on
   * that socket. Besides message transmission, it's responsible for
   * propagating socket errors to the SimpleMessenger and then sticking
   * around in a state where it can provide enough data for the SimpleMessenger
   * to provide reliable Message delivery when it manages to reconnect.
   */
   Reader(in Pip)
   /**
     * The Reader thread handles all reads off the socket -- not just
     * Messages, but also acks and other protocol bits (excepting startup,
     * when the Writer does a couple of reads).
     * All the work is implemented in Pipe itself, of course.
     */
     Writer(in Pip)
    /**
     * The Writer thread handles all writes to the socket (after startup).
     * All the work is implemented in Pipe itself, of course.
     */

1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md或论文文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。 5、资源来自互联网采集,如有侵权,私聊博主删除。 6、可私信博主看论文后选择购买源代码。 1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md或论文文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。 5、资源来自互联网采集,如有侵权,私聊博主删除。 6、可私信博主看论文后选择购买源代码。 1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md或论文文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。 5、资源来自互联网采集,如有侵权,私聊博主删除。 6、可私信博主看论文后选择购买源代码。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值