MDSTableClient类用于和MDSTableServer通信,向MDSTableServer类发送消息以及从MDSTableServer类接收消息回复
MDSTableClient::handle_request() client端总路由调度函数,根据消息的操作类型不同,调用不同的handle_*()函数进行处理
|__TABLESERVER_OP_QUERY_REPLY
|__handle_query_result()
|__TABLESERVER_OP_AGREE
|__对于回复在pending_prepare数组中
|__设置pending_prepare[reqid].ptid = tid
|__设置pending_prepare[reqid].pbl = m->bl
|__删除pending_prepare[reqid]
|__设置prepared_update[tid] = reqid
|__对于回复在prepared_update数组中
|__重复回复
|__对于回复在pending_commit数组中
|__对于回复不再上述数组中
|__创建MMDSTableRequest类消息(TABLESERVER_OP_ROLLBACK)
|__mds->send_message_mds() 将消息发送给Server
|__TABLESERVER_OP_ACK
|__对于回复在pending_commit数组中
|__删除pending_commit[tid]->pending_commit_tids[table]
|__删除pending_commit[tid]
|__mds->mdlog->start_submit_entry()
|__TABLESERVER_OP_SERVER_READY
|__设置server_ready = true
|__resend_queries()
|__resend_prepares()
|__resend_commits()
MDSTableClient::_logged_ack() 对于TABLESERVER_OP_ACK操作写log的回调函数
|__对于ack_waiters[tid]
|__mds->queue_waiters(ack_waiters[tid])
|__清除ack_waiters[tid]
MDSTableClient::_prepare()
|__对于tableserver未准备好,则将prepare消息插入到waiting_for_reqid数组中
|__获取reqid = ++last_reqid
|__填充pending_prepare[reqid]数组
|__若tableserver准备好
|__创建MMDSTableRequest类消息(TABLESERVER_OP_PREPARE)
|__mds->send_message_mds() 发送消息到tableserver
MDSTableClient::commit()
|__删除prepared_update[tid]
|__设置pending_commit[tid] = ls
|__若tableserver准备好
|__创建MMDSTableRequest类消息(TABLESERVER_OP_COMMIT)
|__mds->send_message_mds() 发送消息到tableserver
MDSTableClient::got_journaled_agree()
|__pending_commit[tid] = ls
MDSTableClient::got_journaled_ack()
|__删除pending_commit[tid]
MDSTableClient::resend_prepares()
|__遍历waiting_for_reqid数组
|__将该数组中的内容复制到pending_prepare[++last_reqid]
|__删除waiting_for_reqid数组对应的项
|__遍历pending_prepare数组
|__创建MMDSTableRequest类消息(TABLESERVER_OP_PREPARE)
|__mds->send_message_mds() 将类消息发送给tableserver
MDSTableClient::resend_commits()
|__遍历pending_commit数组
|__创建MMDSTableRequest类消息(TABLESERVER_OP_COMMIT)
|__mds->send_message_mds() 将类消息发送给tableserver
MDSTableClient::handle_mds_failure()
|__设置server_ready = false
SnapClient类继承于MDSTableClient类,实际上SnapClient就是封装了一些处理函数,SnapClient具体操作函数说明如下:
SnapClient::prepare_create()
|__设置op = TABLE_OP_CREATE
|__将op/dirino/name/stamp序列化到bufferlist中
|__MDSTableClient::_prepare()
SnapClient::prepare_create_realm()
|__设置op = TABLE_OP_CREATE
|__将op/ino序列化到bufferlist中
|__MDSTableClient::_prepare()
SnapClient::prepare_destroy()
|__设置op = TABLE_OP_DESTROY
|__将op/ino/snapid序列化到bufferlist中
|__MDSTableClient::_prepare()
SnapClient::prepare_update()
|__设置op = TABLE_OP_UPDATE
|__将op/ino/snapid/name/stamp序列化到bufferlist中
|__MDSTableClient::_prepare()
SnapClient和MDSTableClient的对应关系如下图所示: