2PC code format about msg_cache and 2pc_role
This commit is contained in:
@ -129,22 +129,29 @@ int MockOb2pcCtx::on_clear()
|
||||
return OB_SUCCESS;
|
||||
}
|
||||
|
||||
bool MockOb2pcCtx::is_root() const
|
||||
Ob2PCRole MockOb2pcCtx::get_2pc_role() const
|
||||
{
|
||||
return participants_.size() != 0;
|
||||
|
||||
Ob2PCRole role;
|
||||
|
||||
if (participants_.size()!=0) {
|
||||
role = Ob2PCRole::ROOT;
|
||||
} else if (participants_.size()==0) {
|
||||
// not root & downstream is empty
|
||||
role = Ob2PCRole::LEAF;
|
||||
} else {
|
||||
role = Ob2PCRole::INTERNAL;
|
||||
}
|
||||
|
||||
return role;
|
||||
}
|
||||
|
||||
bool MockOb2pcCtx::is_leaf() const
|
||||
{
|
||||
return participants_.size() == 0;
|
||||
}
|
||||
|
||||
int64_t MockOb2pcCtx::get_participants_size()
|
||||
int64_t MockOb2pcCtx::get_downstream_size() const
|
||||
{
|
||||
return participants_.size();
|
||||
}
|
||||
|
||||
uint64_t MockOb2pcCtx::get_participant_id()
|
||||
int64_t MockOb2pcCtx::get_self_id()
|
||||
{
|
||||
int participant_id = 0;
|
||||
|
||||
@ -163,7 +170,7 @@ int MockOb2pcCtx::submit_log(const ObTwoPhaseCommitLogType& log_type)
|
||||
}
|
||||
|
||||
int MockOb2pcCtx::post_msg(const ObTwoPhaseCommitMsgType& msg_type,
|
||||
const uint8_t participant)
|
||||
const int64_t participant)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
int64_t to = 0;
|
||||
@ -200,17 +207,11 @@ int MockOb2pcCtx::post_msg(const ObTwoPhaseCommitMsgType& msg_type,
|
||||
return ret;
|
||||
}
|
||||
|
||||
int MockOb2pcCtx::post_msg(const ObTwoPhaseCommitMsgType& msg_type)
|
||||
int MockOb2pcCtx::apply_2pc_msg_(const ObTwoPhaseCommitMsgType msg_type)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
|
||||
for (int i = 0; i < participants_.size(); i++) {
|
||||
if (OB_FAIL(post_msg(msg_type, i))) {
|
||||
TRANS_LOG(WARN, "send mailbox failed", K(ret), K(msg_type));
|
||||
}
|
||||
}
|
||||
|
||||
TRANS_LOG(INFO, "post msg to participants success", K(*this), K(msg_type));
|
||||
UNUSED(msg_type);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user