patch 4.0
This commit is contained in:
@ -14,13 +14,15 @@
|
||||
#include "share/ob_lease_struct.h"
|
||||
#include "lib/utility/ob_print_utils.h"
|
||||
#include "lib/utility/ob_serialization_helper.h"
|
||||
namespace oceanbase {
|
||||
using namespace common;
|
||||
namespace share {
|
||||
|
||||
const char* server_service_status_to_str(const ServerServiceStatus status)
|
||||
namespace oceanbase
|
||||
{
|
||||
const char* str = "UNKNOWN";
|
||||
using namespace common;
|
||||
namespace share
|
||||
{
|
||||
|
||||
const char *server_service_status_to_str(const ServerServiceStatus status)
|
||||
{
|
||||
const char *str = "UNKNOWN";
|
||||
switch (status) {
|
||||
case OBSERVER_INVALID_STATUS:
|
||||
str = "INVALID_STATUS";
|
||||
@ -31,8 +33,11 @@ const char* server_service_status_to_str(const ServerServiceStatus status)
|
||||
case OBSERVER_SWITCHING:
|
||||
str = "SWITCHING";
|
||||
break;
|
||||
case OBSERVER_FLASHBACK:
|
||||
str = "FLASHBACK";
|
||||
case OBSERVER_FLASHBACK_USER:
|
||||
str = "FLASHBACK_USER";
|
||||
break;
|
||||
case OBSERVER_FLASHBACK_INNER:
|
||||
str = "FLASHBACK_INNER";
|
||||
break;
|
||||
case OBSERVER_DISABLED:
|
||||
str = "DISABLED";
|
||||
@ -55,68 +60,106 @@ ObServerResourceInfo::ObServerResourceInfo()
|
||||
void ObServerResourceInfo::reset()
|
||||
{
|
||||
cpu_ = 0;
|
||||
mem_in_use_ = 0;
|
||||
mem_total_ = 0;
|
||||
disk_in_use_ = 0;
|
||||
disk_total_ = 0;
|
||||
disk_actual_ = 0;
|
||||
partition_cnt_ = -1; // compatible with old server
|
||||
report_cpu_assigned_ = 0;
|
||||
report_cpu_max_assigned_ = 0;
|
||||
|
||||
mem_total_ = 0;
|
||||
report_mem_assigned_ = 0;
|
||||
report_mem_max_assigned_ = 0;
|
||||
mem_in_use_ = 0;
|
||||
|
||||
log_disk_total_ = 0;
|
||||
report_log_disk_assigned_ = 0;
|
||||
|
||||
disk_total_ = 0;
|
||||
disk_in_use_ = 0;
|
||||
}
|
||||
|
||||
bool ObServerResourceInfo::is_valid() const
|
||||
{
|
||||
return cpu_ > 0 && mem_in_use_ >= 0 && mem_total_ > 0 && disk_in_use_ >= 0 && disk_total_ > 0 &&
|
||||
disk_actual_ >= 0 && partition_cnt_ >= -1 && report_cpu_assigned_ >= 0 && report_cpu_max_assigned_ >= 0 &&
|
||||
report_mem_assigned_ >= 0 && report_mem_max_assigned_ >= 0;
|
||||
return cpu_ > 0
|
||||
&& report_cpu_assigned_ >= 0
|
||||
&& report_cpu_max_assigned_ >= 0
|
||||
&& mem_total_ > 0
|
||||
&& report_mem_assigned_ >= 0
|
||||
&& mem_in_use_ >= 0
|
||||
&& log_disk_total_ > 0
|
||||
&& report_log_disk_assigned_ >= 0
|
||||
&& disk_total_ > 0
|
||||
&& disk_in_use_ >= 0;
|
||||
}
|
||||
|
||||
bool ObServerResourceInfo::operator==(const ObServerResourceInfo& other) const
|
||||
bool ObServerResourceInfo::operator==(const ObServerResourceInfo &other) const
|
||||
{
|
||||
return std::fabs(cpu_ - other.cpu_) < OB_DOUBLE_EPSINON && mem_in_use_ == other.mem_in_use_ &&
|
||||
mem_total_ == other.mem_total_ && disk_in_use_ == other.disk_in_use_ && disk_total_ == other.disk_total_ &&
|
||||
disk_actual_ == other.disk_actual_ &&
|
||||
partition_cnt_ == other.partition_cnt_ &&
|
||||
std::fabs(report_cpu_assigned_ - other.report_cpu_assigned_) < OB_DOUBLE_EPSINON &&
|
||||
std::fabs(report_cpu_max_assigned_ - other.report_cpu_max_assigned_) < OB_DOUBLE_EPSINON &&
|
||||
report_mem_assigned_ == other.report_mem_assigned_ &&
|
||||
report_mem_max_assigned_ == other.report_mem_max_assigned_;
|
||||
return std::fabs(cpu_ - other.cpu_) < OB_DOUBLE_EPSINON
|
||||
&& std::fabs(report_cpu_assigned_ - other.report_cpu_assigned_) < OB_DOUBLE_EPSINON
|
||||
&& std::fabs(report_cpu_max_assigned_ - other.report_cpu_max_assigned_) < OB_DOUBLE_EPSINON
|
||||
&& mem_total_ == other.mem_total_
|
||||
&& report_mem_assigned_ == other.report_mem_assigned_
|
||||
&& mem_in_use_ == other.mem_in_use_
|
||||
&& log_disk_total_ == other.log_disk_total_
|
||||
&& report_log_disk_assigned_ == other.report_log_disk_assigned_
|
||||
&& disk_total_ == other.disk_total_
|
||||
&& disk_in_use_ == other.disk_in_use_;
|
||||
}
|
||||
|
||||
bool ObServerResourceInfo::operator!=(const ObServerResourceInfo& other) const
|
||||
bool ObServerResourceInfo::operator!=(const ObServerResourceInfo &other) const
|
||||
{
|
||||
return std::fabs(cpu_ - other.cpu_) > OB_DOUBLE_EPSINON || mem_in_use_ != other.mem_in_use_ ||
|
||||
mem_total_ != other.mem_total_ || disk_in_use_ != other.disk_in_use_ || disk_total_ != other.disk_total_ ||
|
||||
disk_actual_ != other.disk_actual_ ||
|
||||
partition_cnt_ != other.partition_cnt_ ||
|
||||
std::fabs(report_cpu_assigned_ - other.report_cpu_assigned_) > OB_DOUBLE_EPSINON ||
|
||||
std::fabs(report_cpu_max_assigned_ - other.report_cpu_max_assigned_) > OB_DOUBLE_EPSINON ||
|
||||
report_mem_assigned_ != other.report_mem_assigned_ ||
|
||||
report_mem_max_assigned_ != other.report_mem_max_assigned_;
|
||||
return std::fabs(cpu_ - other.cpu_) > OB_DOUBLE_EPSINON
|
||||
|| std::fabs(report_cpu_assigned_ - other.report_cpu_assigned_) > OB_DOUBLE_EPSINON
|
||||
|| std::fabs(report_cpu_max_assigned_ - other.report_cpu_max_assigned_) > OB_DOUBLE_EPSINON
|
||||
|| mem_total_ != other.mem_total_
|
||||
|| report_mem_assigned_ != other.report_mem_assigned_
|
||||
|| mem_in_use_ != other.mem_in_use_
|
||||
|| log_disk_total_ != other.log_disk_total_
|
||||
|| report_log_disk_assigned_ != other.report_log_disk_assigned_
|
||||
|| disk_total_ != other.disk_total_
|
||||
|| disk_in_use_ != other.disk_in_use_;
|
||||
}
|
||||
|
||||
int ObServerResourceInfo::assign(const ObServerResourceInfo& other)
|
||||
OB_SERIALIZE_MEMBER(ObServerResourceInfo,
|
||||
cpu_,
|
||||
report_cpu_assigned_,
|
||||
report_cpu_max_assigned_,
|
||||
mem_total_,
|
||||
report_mem_assigned_,
|
||||
mem_in_use_,
|
||||
log_disk_total_,
|
||||
report_log_disk_assigned_,
|
||||
disk_total_,
|
||||
disk_in_use_);
|
||||
|
||||
DEF_TO_STRING(ObServerResourceInfo)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
cpu_ = other.cpu_;
|
||||
mem_in_use_ = other.mem_in_use_;
|
||||
mem_total_ = other.mem_total_;
|
||||
disk_in_use_ = other.disk_in_use_;
|
||||
disk_total_ = other.disk_total_;
|
||||
partition_cnt_ = other.partition_cnt_;
|
||||
report_cpu_assigned_ = other.report_cpu_assigned_;
|
||||
report_cpu_max_assigned_ = other.report_cpu_max_assigned_;
|
||||
report_mem_assigned_ = other.report_mem_assigned_;
|
||||
report_mem_max_assigned_ = other.report_mem_max_assigned_;
|
||||
disk_actual_ = other.disk_actual_;
|
||||
return ret;
|
||||
int64_t pos = 0;
|
||||
J_OBJ_START();
|
||||
(void)databuff_printf(buf, buf_len, pos,
|
||||
"cpu_capacity:%.6g, "
|
||||
"cpu_assigned:%.6g, "
|
||||
"cpu_assigned_max:%.6g, "
|
||||
"mem_capacity:\"%.9gGB\", "
|
||||
"mem_assigned:\"%.9gGB\", "
|
||||
"mem_in_use:%.9gGB, "
|
||||
"log_disk_capacity:%.9gGB, "
|
||||
"log_disk_assigned:%.9gGB, "
|
||||
"data_disk_capacity:%.9gGB, "
|
||||
"data_disk_in_use:%.9gGB",
|
||||
cpu_,
|
||||
report_cpu_assigned_,
|
||||
report_cpu_max_assigned_,
|
||||
(double)mem_total_/1024/1024/1024,
|
||||
(double)report_mem_assigned_/1024/1024/1024,
|
||||
(double)mem_in_use_/1024/1024/1024,
|
||||
(double)log_disk_total_/1024/1024/1024,
|
||||
(double)report_log_disk_assigned_/1024/1024/1024,
|
||||
(double)disk_total_/1024/1024/1024,
|
||||
(double)disk_in_use_/1024/1024/1024);
|
||||
J_OBJ_END();
|
||||
return pos;
|
||||
}
|
||||
|
||||
OB_SERIALIZE_MEMBER(ObServerResourceInfo, cpu_, mem_in_use_, mem_total_, disk_in_use_, disk_total_, partition_cnt_,
|
||||
report_cpu_assigned_, report_cpu_max_assigned_, report_mem_assigned_, report_mem_max_assigned_, disk_actual_);
|
||||
|
||||
OB_SERIALIZE_MEMBER(ObLeaseRequest::TLRqKeyVersion,
|
||||
max_flushed_key_version_);
|
||||
|
||||
ObLeaseRequest::ObLeaseRequest()
|
||||
{
|
||||
@ -129,7 +172,7 @@ void ObLeaseRequest::reset()
|
||||
zone_.reset();
|
||||
server_.reset();
|
||||
memset(build_version_, 0, OB_SERVER_VERSION_LENGTH);
|
||||
inner_port_ = 0;
|
||||
sql_port_ = 0;
|
||||
resource_info_.reset();
|
||||
start_service_time_ = 0;
|
||||
current_server_time_ = 0;
|
||||
@ -138,19 +181,38 @@ void ObLeaseRequest::reset()
|
||||
ssl_key_expired_time_ = 0;
|
||||
tenant_config_version_.reset();
|
||||
timeout_partition_ = 0;
|
||||
tenant_max_flushed_key_version_.reset();
|
||||
request_lease_time_ = 0;
|
||||
}
|
||||
|
||||
bool ObLeaseRequest::is_valid() const
|
||||
{
|
||||
// No need to determine the value of server_status_
|
||||
return version_ > 0 && !zone_.is_empty() && server_.is_valid() && inner_port_ > 0 && resource_info_.is_valid() &&
|
||||
start_service_time_ >= 0 && current_server_time_ >= 0 && round_trip_time_ >= 0;
|
||||
return version_ > 0 && !zone_.is_empty() && server_.is_valid()
|
||||
&& sql_port_ > 0 && resource_info_.is_valid()
|
||||
&& start_service_time_ >= 0 && current_server_time_ >= 0 && round_trip_time_ >= 0;
|
||||
}
|
||||
|
||||
OB_SERIALIZE_MEMBER(ObLeaseRequest, version_, zone_, server_, inner_port_, build_version_, resource_info_,
|
||||
start_service_time_, current_server_time_, round_trip_time_, server_status_, tenant_config_version_,
|
||||
ssl_key_expired_time_, timeout_partition_, request_lease_time_)
|
||||
OB_SERIALIZE_MEMBER(ObLeaseRequest,
|
||||
version_,
|
||||
zone_,
|
||||
server_,
|
||||
sql_port_,
|
||||
build_version_,
|
||||
resource_info_,
|
||||
start_service_time_,
|
||||
current_server_time_,
|
||||
round_trip_time_,
|
||||
server_status_,
|
||||
tenant_config_version_,
|
||||
ssl_key_expired_time_,
|
||||
timeout_partition_,
|
||||
request_lease_time_,
|
||||
tenant_max_flushed_key_version_);
|
||||
|
||||
OB_SERIALIZE_MEMBER(ObLeaseResponse::TLRpKeyVersion,
|
||||
max_key_version_,
|
||||
max_available_key_version_);
|
||||
|
||||
ObLeaseResponse::ObLeaseResponse()
|
||||
{
|
||||
@ -167,19 +229,16 @@ void ObLeaseResponse::reset()
|
||||
server_id_ = OB_INVALID_ID;
|
||||
frozen_status_.reset();
|
||||
force_frozen_status_ = false;
|
||||
rs_server_status_ = RSS_IS_WORKING; // for compatibility
|
||||
global_max_decided_trans_version_ = 0;
|
||||
rs_server_status_ = RSS_IS_WORKING; // for compatibility
|
||||
refresh_schema_info_.reset();
|
||||
cluster_info_.reset();
|
||||
server_service_status_ = OBSERVER_INVALID_STATUS;
|
||||
tenant_config_version_.reset();
|
||||
baseline_schema_version_ = 0;
|
||||
sync_cluster_ids_.reset();
|
||||
redo_options_.reset();
|
||||
heartbeat_expire_time_ = -1;
|
||||
tenant_max_key_version_.reset();
|
||||
}
|
||||
|
||||
int ObLeaseResponse::assign(const ObLeaseResponse& other)
|
||||
int ObLeaseResponse::assign(const ObLeaseResponse &other)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
version_ = other.version_;
|
||||
@ -191,7 +250,6 @@ int ObLeaseResponse::assign(const ObLeaseResponse& other)
|
||||
frozen_status_ = other.frozen_status_;
|
||||
force_frozen_status_ = other.force_frozen_status_;
|
||||
rs_server_status_ = other.rs_server_status_;
|
||||
global_max_decided_trans_version_ = other.global_max_decided_trans_version_;
|
||||
server_service_status_ = other.server_service_status_;
|
||||
baseline_schema_version_ = other.baseline_schema_version_;
|
||||
heartbeat_expire_time_ = other.heartbeat_expire_time_;
|
||||
@ -199,26 +257,40 @@ int ObLeaseResponse::assign(const ObLeaseResponse& other)
|
||||
LOG_WARN("failed to assign ohter schema info", KR(ret), "this", *this, K(other));
|
||||
} else if (OB_FAIL(tenant_config_version_.assign(other.tenant_config_version_))) {
|
||||
LOG_WARN("failed to assign tenant config version", KR(ret), K(other), "this", *this);
|
||||
} else if (OB_FAIL(sync_cluster_ids_.assign(other.sync_cluster_ids_))) {
|
||||
LOG_WARN("failed to assign sync cluster ids", KR(ret), K(other), "this", *this);
|
||||
} else if (OB_FAIL(redo_options_.assign(other.redo_options_))) {
|
||||
LOG_WARN("failed to redo transport options", KR(ret), K(other));
|
||||
} else if (OB_FAIL(tenant_max_key_version_.assign(
|
||||
other.tenant_max_key_version_))) {
|
||||
LOG_WARN("failed to assign tenant max available key version", KR(ret));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
OB_SERIALIZE_MEMBER(ObLeaseResponse, version_, lease_expire_time_, lease_info_version_, frozen_version_,
|
||||
schema_version_, server_id_, frozen_status_, force_frozen_status_, rs_server_status_,
|
||||
global_max_decided_trans_version_, refresh_schema_info_, cluster_info_, server_service_status_,
|
||||
tenant_config_version_, baseline_schema_version_, sync_cluster_ids_, redo_options_, heartbeat_expire_time_);
|
||||
OB_SERIALIZE_MEMBER(ObLeaseResponse,
|
||||
version_,
|
||||
lease_expire_time_,
|
||||
lease_info_version_,
|
||||
frozen_version_,
|
||||
schema_version_,
|
||||
server_id_,
|
||||
frozen_status_,
|
||||
force_frozen_status_,
|
||||
rs_server_status_,
|
||||
refresh_schema_info_,
|
||||
server_service_status_,
|
||||
tenant_config_version_,
|
||||
baseline_schema_version_,
|
||||
heartbeat_expire_time_,
|
||||
tenant_max_key_version_);
|
||||
|
||||
|
||||
bool ObLeaseResponse::is_valid() const
|
||||
{
|
||||
// other member may be invalid value while RS restart.
|
||||
return version_ > 0 && schema_version_ > 0 && heartbeat_expire_time_ > 0;
|
||||
return version_ > 0
|
||||
&& schema_version_ > 0
|
||||
&& heartbeat_expire_time_ > 0;
|
||||
}
|
||||
|
||||
int ObLeaseResponse::set(const ObLeaseResponse& that)
|
||||
int ObLeaseResponse::set(const ObLeaseResponse &that)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
version_ = that.version_;
|
||||
@ -232,9 +304,7 @@ int ObLeaseResponse::set(const ObLeaseResponse& that)
|
||||
frozen_status_ = that.frozen_status_;
|
||||
force_frozen_status_ = that.force_frozen_status_;
|
||||
rs_server_status_ = that.rs_server_status_;
|
||||
global_max_decided_trans_version_ = that.global_max_decided_trans_version_;
|
||||
refresh_schema_info_ = that.refresh_schema_info_;
|
||||
cluster_info_ = that.cluster_info_;
|
||||
server_service_status_ = that.server_service_status_;
|
||||
baseline_schema_version_ = that.baseline_schema_version_;
|
||||
heartbeat_expire_time_ = that.heartbeat_expire_time_;
|
||||
@ -246,9 +316,8 @@ int ObLeaseResponse::set(const ObLeaseResponse& that)
|
||||
|
||||
bool ObZoneLeaseInfo::is_valid() const
|
||||
{
|
||||
return !zone_.is_empty() && privilege_version_ >= 0 && config_version_ >= 0 && lease_info_version_ >= 0 &&
|
||||
broadcast_version_ > 0 && last_merged_version_ > 0 && global_last_merged_version_ > 0 &&
|
||||
time_zone_info_version_ >= 0;
|
||||
return !zone_.is_empty() && privilege_version_ >= 0 && config_version_ >= 0
|
||||
&& lease_info_version_ >= 0 && time_zone_info_version_ >= 0;
|
||||
}
|
||||
|
||||
// ====================== ObInZoneHbRequest =======================
|
||||
@ -262,14 +331,15 @@ void ObInZoneHbRequest::reset()
|
||||
server_.reset();
|
||||
}
|
||||
|
||||
OB_SERIALIZE_MEMBER(ObInZoneHbRequest, server_);
|
||||
OB_SERIALIZE_MEMBER(ObInZoneHbRequest,
|
||||
server_);
|
||||
|
||||
// =================== ObInZoneHbResponse =====================
|
||||
bool ObInZoneHbResponse::is_valid() const
|
||||
{
|
||||
/* in_zone_hb_expire_time_ > 0 means in_zone_mgr is still granting heartbeat,
|
||||
* in_zone_hb_expire_time_ == 0 means in_zone_mgr no longer grants heartbeat
|
||||
* in_zone_hb_expire_time_ < 0 means invalid
|
||||
/* in_zone_hb_expire_time_ > 0 时表示in_zone_mgr还在继续授予heartbeat,
|
||||
* in_zone_hb_expire_time_ == 0 时表示in_zone_mgr不再授予heartbeat了
|
||||
* in_zone_hb_expire_time_ < 0 是表示无效
|
||||
*/
|
||||
return in_zone_hb_expire_time_ >= 0;
|
||||
}
|
||||
@ -279,7 +349,8 @@ void ObInZoneHbResponse::reset()
|
||||
in_zone_hb_expire_time_ = -1;
|
||||
}
|
||||
|
||||
OB_SERIALIZE_MEMBER(ObInZoneHbResponse, in_zone_hb_expire_time_);
|
||||
OB_SERIALIZE_MEMBER(ObInZoneHbResponse,
|
||||
in_zone_hb_expire_time_);
|
||||
|
||||
} // end namespace share
|
||||
} // end namespace oceanbase
|
||||
} // end namespace share
|
||||
} // end namespace oceanbase
|
||||
|
||||
Reference in New Issue
Block a user