patch 4.0

This commit is contained in:
wangzelin.wzl
2022-10-24 10:34:53 +08:00
parent 4ad6e00ec3
commit 93a1074b0c
10533 changed files with 2588271 additions and 2299373 deletions

View File

@ -13,8 +13,10 @@
#include "share/ob_proposal_id.h"
#include "share/ob_cluster_version.h"
namespace oceanbase {
namespace common {
namespace oceanbase
{
namespace common
{
void ObProposalID::reset()
{
ts_ = OB_INVALID_TIMESTAMP;
@ -26,45 +28,47 @@ bool ObProposalID::is_valid() const
return ts_ != OB_INVALID_TIMESTAMP && addr_.is_valid();
}
int ObProposalID::to_yson(char* buf, const int64_t buf_len, int64_t& pos) const
int ObProposalID::to_yson(char *buf, const int64_t buf_len, int64_t &pos) const
{
return oceanbase::yson::databuff_encode_elements(buf, buf_len, pos, OB_ID(time_to_usec), ts_, OB_ID(server), addr_);
}
bool ObProposalID::operator<(const ObProposalID& pid) const
bool ObProposalID::operator < (const ObProposalID &pid) const
{
return (ts_ == OB_INVALID_TIMESTAMP && pid.ts_ != OB_INVALID_TIMESTAMP) || (ts_ < pid.ts_) ||
((ts_ == pid.ts_) && (addr_ < pid.addr_));
return (ts_ == OB_INVALID_TIMESTAMP && pid.ts_ != OB_INVALID_TIMESTAMP)
|| (ts_ < pid.ts_)
|| ((ts_ == pid.ts_) && (addr_ < pid.addr_));
}
bool ObProposalID::operator>(const ObProposalID& pid) const
bool ObProposalID::operator > (const ObProposalID &pid) const
{
return (ts_ != OB_INVALID_TIMESTAMP && pid.ts_ == OB_INVALID_TIMESTAMP) || (ts_ > pid.ts_) ||
((ts_ == pid.ts_) && (pid.addr_ < addr_));
return (ts_ != OB_INVALID_TIMESTAMP && pid.ts_ == OB_INVALID_TIMESTAMP)
|| (ts_ > pid.ts_)
|| ((ts_ == pid.ts_) && (pid.addr_ < addr_));
}
bool ObProposalID::operator>=(const ObProposalID& pid) const
bool ObProposalID::operator >= (const ObProposalID &pid) const
{
return !((*this) < pid);
}
bool ObProposalID::operator<=(const ObProposalID& pid) const
bool ObProposalID::operator <= (const ObProposalID &pid) const
{
return !((*this) > pid);
}
void ObProposalID::operator=(const ObProposalID& pid)
void ObProposalID::operator = (const ObProposalID &pid)
{
ts_ = pid.ts_;
addr_ = pid.addr_;
}
bool ObProposalID::operator==(const ObProposalID& pid) const
bool ObProposalID::operator == (const ObProposalID &pid) const
{
return (ts_ == pid.ts_) && (addr_ == pid.addr_);
}
bool ObProposalID::operator!=(const ObProposalID& pid2) const
bool ObProposalID::operator != (const ObProposalID &pid2) const
{
return !(*this == pid2);
}
@ -82,13 +86,13 @@ DEFINE_SERIALIZE(ObProposalID)
}
if (OB_SUCC(ret)) {
if (PROPOSAL_ID_VERSION6 == current_version &&
GET_MIN_CLUSTER_VERSION() > CLUSTER_CURRENT_VERSION) { // FIXME: Does not take effect first
if (PROPOSAL_ID_VERSION6 == current_version) {
if ((OB_FAIL(addr_.serialize(buf, buf_len, new_pos)))) {
CLOG_LOG(WARN, "serialize addr error", K(ret), K(buf), K(buf_len), K(pos), K(new_pos));
}
} else {
if ((OB_FAIL(serialization::encode_i64(buf, buf_len, new_pos, addr_.get_ipv4_server_id())))) {
if ((OB_FAIL(serialization::encode_i64(buf, buf_len, new_pos,
addr_.get_ipv4_server_id())))) {
CLOG_LOG(WARN, "serialize addr error", K(ret), K(buf), K(buf_len), K(pos), K(new_pos));
}
}
@ -117,8 +121,7 @@ DEFINE_DESERIALIZE(ObProposalID)
}
if (OB_SUCC(ret)) {
if (PROPOSAL_ID_VERSION6 == current_version &&
GET_MIN_CLUSTER_VERSION() > CLUSTER_CURRENT_VERSION) { // FIXME: Does not take effect first
if (PROPOSAL_ID_VERSION6 == current_version) {
ret = addr_.deserialize(buf, data_len, new_pos);
} else {
ret = serialization::decode_i64(buf, data_len, new_pos, &server_id);
@ -143,8 +146,7 @@ DEFINE_GET_SERIALIZE_SIZE(ObProposalID)
int8_t current_version = addr_.using_ipv4() ? PROPOSAL_ID_VERSION : PROPOSAL_ID_VERSION6;
size += serialization::encoded_length_i8(current_version);
size += serialization::encoded_length_i64(ts_);
if (PROPOSAL_ID_VERSION6 == current_version &&
GET_MIN_CLUSTER_VERSION() > CLUSTER_CURRENT_VERSION) { // FIXME: Does not take effect first
if (PROPOSAL_ID_VERSION6 == current_version) {
size += addr_.get_serialize_size();
} else {
size += serialization::encoded_length_i64(addr_.get_ipv4_server_id());
@ -152,5 +154,5 @@ DEFINE_GET_SERIALIZE_SIZE(ObProposalID)
return size;
}
} // end namespace common
} // end namespace oceanbase
}//end namespace common
}//end namespace oceanbase