[rebuild] add get_election_leader()
This commit is contained in:
@ -404,6 +404,12 @@ int ObLogHandler::get_global_learner_list(common::GlobalLearnerList &learner_lis
|
||||
return palf_handle_.get_global_learner_list(learner_list);
|
||||
}
|
||||
|
||||
int ObLogHandler::get_election_leader(common::ObAddr &addr) const
|
||||
{
|
||||
RLockGuard guard(lock_);
|
||||
return palf_handle_.get_election_leader(addr);
|
||||
}
|
||||
|
||||
int ObLogHandler::enable_sync()
|
||||
{
|
||||
RLockGuard guard(lock_);
|
||||
|
||||
@ -96,6 +96,7 @@ public:
|
||||
virtual int get_end_scn(share::SCN &scn) const = 0;
|
||||
virtual int get_paxos_member_list(common::ObMemberList &member_list, int64_t &paxos_replica_num) const = 0;
|
||||
virtual int get_global_learner_list(common::GlobalLearnerList &learner_list) const = 0;
|
||||
virtual int get_election_leader(common::ObAddr &addr) const = 0;
|
||||
virtual int change_replica_num(const common::ObMemberList &member_list,
|
||||
const int64_t curr_replica_num,
|
||||
const int64_t new_replica_num,
|
||||
@ -292,6 +293,13 @@ public:
|
||||
// @brief, get global learner list of this paxos group
|
||||
// @param[out] common::GlobalLearnerList&
|
||||
int get_global_learner_list(common::GlobalLearnerList &learner_list) const override final;
|
||||
// @brief, get leader from election, used for non_palf_leader rebuilding
|
||||
// @param[out] addr: address of leader
|
||||
// retval:
|
||||
// OB_SUCCESS
|
||||
// OB_NOT_INIT
|
||||
// OB_LEADER_NOT_EXIST
|
||||
int get_election_leader(common::ObAddr &addr) const override final;
|
||||
// PalfBaseInfo include the 'base_lsn' and the 'prev_log_info' of sliding window.
|
||||
// @param[in] const LSN&, base_lsn of ls.
|
||||
// @param[out] PalfBaseInfo&, palf_base_info
|
||||
|
||||
@ -288,6 +288,12 @@ int PalfHandle::get_paxos_member_list(common::ObMemberList &member_list, int64_t
|
||||
return palf_handle_impl_->get_paxos_member_list(member_list, paxos_replica_num);
|
||||
}
|
||||
|
||||
int PalfHandle::get_election_leader(common::ObAddr &addr) const
|
||||
{
|
||||
CHECK_VALID;
|
||||
return palf_handle_impl_->get_election_leader(addr);
|
||||
}
|
||||
|
||||
int PalfHandle::change_replica_num(const common::ObMemberList &member_list,
|
||||
const int64_t curr_replica_num,
|
||||
const int64_t new_replica_num,
|
||||
|
||||
@ -178,6 +178,7 @@ public:
|
||||
|
||||
int get_global_learner_list(common::GlobalLearnerList &learner_list) const;
|
||||
int get_paxos_member_list(common::ObMemberList &member_list, int64_t &paxos_replica_num) const;
|
||||
int get_election_leader(common::ObAddr &addr) const;
|
||||
|
||||
// @brief: a special config change interface, change replica number of paxos group
|
||||
// @param[in] common::ObMemberList: current memberlist, for pre-check
|
||||
|
||||
@ -489,6 +489,14 @@ int PalfHandleImpl::get_paxos_member_list(
|
||||
return ret;
|
||||
}
|
||||
|
||||
int PalfHandleImpl::get_election_leader(ObAddr &addr) const
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
RLockGuard guard(lock_);
|
||||
ret = get_election_leader_without_lock_(addr);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int PalfHandleImpl::config_change_pre_check(const ObAddr &server,
|
||||
const LogGetMCStReq &req,
|
||||
LogGetMCStResp &resp)
|
||||
@ -3478,6 +3486,22 @@ int PalfHandleImpl::append_disk_log_to_sw_(const LSN &start_lsn)
|
||||
return ret;
|
||||
}
|
||||
|
||||
int PalfHandleImpl::get_election_leader_without_lock_(ObAddr &addr) const
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
int64_t unused_leader_epoch = -1;
|
||||
if (IS_NOT_INIT) {
|
||||
ret = OB_NOT_INIT;
|
||||
PALF_LOG(ERROR, "PalfHandleImpl has not inited", K(ret));
|
||||
} else if (OB_FAIL(election_.get_current_leader_likely(addr, unused_leader_epoch))) {
|
||||
PALF_LOG(WARN, "get_election_leader failed", K(ret), KPC(this));
|
||||
} else if (OB_UNLIKELY(!addr.is_valid())) {
|
||||
ret = OB_LEADER_NOT_EXIST;
|
||||
PALF_LOG(WARN, "election has no leader", K(ret), KPC(this));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int PalfHandleImpl::revoke_leader(const int64_t proposal_id)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
|
||||
@ -238,6 +238,7 @@ public:
|
||||
|
||||
virtual int get_global_learner_list(common::GlobalLearnerList &learner_list) const = 0;
|
||||
virtual int get_paxos_member_list(common::ObMemberList &member_list, int64_t &paxos_replica_num) const = 0;
|
||||
virtual int get_election_leader(common::ObAddr &addr) const = 0;
|
||||
|
||||
// @brief: a special config change interface, change replica number of paxos group
|
||||
// @param[in] common::ObMemberList: current memberlist, for pre-check
|
||||
@ -634,6 +635,7 @@ public:
|
||||
int change_leader_to(const common::ObAddr &dest_addr) override final;
|
||||
int get_global_learner_list(common::GlobalLearnerList &learner_list) const override final;
|
||||
int get_paxos_member_list(common::ObMemberList &member_list, int64_t &paxos_replica_num) const override final;
|
||||
int get_election_leader(common::ObAddr &addr) const;
|
||||
int change_replica_num(const common::ObMemberList &member_list,
|
||||
const int64_t curr_replica_num,
|
||||
const int64_t new_replica_num,
|
||||
@ -913,6 +915,7 @@ private:
|
||||
int check_need_advance_base_info_(const LSN &base_lsn,
|
||||
const LogInfo &base_prev_log_info,
|
||||
const bool is_rebuild);
|
||||
int get_election_leader_without_lock_(ObAddr &addr) const;
|
||||
// ========================= flashback ==============================
|
||||
int can_do_flashback_(const int64_t mode_version,
|
||||
const share::SCN &flashback_scn,
|
||||
|
||||
@ -409,6 +409,11 @@ public:
|
||||
}
|
||||
int enable_vote() { return OB_SUCCESS; }
|
||||
int disable_vote() { return OB_SUCCESS; }
|
||||
int get_election_leader(common::ObAddr &addr) const
|
||||
{
|
||||
UNUSED(addr);
|
||||
return OB_SUCCESS;
|
||||
}
|
||||
int register_rebuild_cb(palf::PalfRebuildCb *rebuild_cb)
|
||||
{
|
||||
UNUSED(rebuild_cb);
|
||||
|
||||
Reference in New Issue
Block a user