[FEAT MERGE] log4100 branch

Co-authored-by: tino247 <tino247@126.com>
Co-authored-by: BinChenn <binchenn.bc@gmail.com>
Co-authored-by: HaHaJeff <jeffzhouhhh@gmail.com>
This commit is contained in:
obdev
2023-01-28 18:17:31 +08:00
committed by ob-robot
parent a269ffe6be
commit 50024b39cd
772 changed files with 60275 additions and 11301 deletions

View File

@ -24,7 +24,9 @@ ObLogHandlerBase::ObLogHandlerBase() :
proposal_id_(palf::INVALID_PROPOSAL_ID),
id_(-1),
palf_handle_(),
palf_env_(NULL)
palf_env_(NULL),
is_in_stop_state_(true),
is_inited_(false)
{}
int ObLogHandlerBase::prepare_switch_role(common::ObRole &curr_role,
@ -63,5 +65,35 @@ int ObLogHandlerBase::change_leader_to(const common::ObAddr &dst_addr)
}
return ret;
}
int ObLogHandlerBase::get_role(common::ObRole &role, int64_t &proposal_id) const
{
int ret = OB_SUCCESS;
bool is_pending_state = false;
int64_t curr_palf_proposal_id;
ObRole curr_palf_role;
// 获取当前的proposal_id
RLockGuard guard(lock_);
const int64_t saved_proposal_id = ATOMIC_LOAD(&proposal_id_);
const ObRole saved_role = ATOMIC_LOAD(&role_);
if (IS_NOT_INIT) {
ret = OB_NOT_INIT;
} else if (is_in_stop_state_) {
ret = OB_NOT_RUNNING;
} else if (FOLLOWER == saved_role) {
role = FOLLOWER;
proposal_id = saved_proposal_id;
} else if (OB_FAIL(palf_handle_.get_role(curr_palf_role, curr_palf_proposal_id, is_pending_state))) {
CLOG_LOG(WARN, "get_role failed", K(ret));
} else if (curr_palf_proposal_id != saved_proposal_id) {
// palf的proposal_id已经发生变化,返回FOLLOWER
role = FOLLOWER;
proposal_id = saved_proposal_id;
} else {
role = curr_palf_role;
proposal_id = saved_proposal_id;
}
return ret;
}
} // end namespace logservice
} // end namespace oceanbase