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

@ -17,26 +17,39 @@
#include "share/ob_unit_getter.h"
#include "share/schema/ob_multi_version_schema_service.h"
#include "rootserver/ob_unit_manager.h"
#include "storage/ob_file_system_router.h"
using namespace oceanbase::common;
using namespace oceanbase::share;
using namespace oceanbase::rootserver;
ObUnitStatManager::ObUnitStatManager()
: inited_(false), schema_service_(NULL), unit_mgr_(NULL), unit_stat_getter_(NULL), unit_stat_map_()
{}
: inited_(false),
schema_service_(NULL),
unit_mgr_(NULL),
unit_stat_getter_(),
unit_stat_map_()
{
}
int ObUnitStatManager::init(share::schema::ObMultiVersionSchemaService& schema_service, ObUnitManager& unit_mgr,
share::ObUnitStatGetter& unit_stat_getter)
int ObUnitStatManager::init(
share::schema::ObMultiVersionSchemaService &schema_service,
ObUnitManager &unit_mgr,
share::ObCheckStopProvider &check_stop_provider)
{
int ret = OB_SUCCESS;
schema_service_ = &schema_service;
unit_mgr_ = &unit_mgr;
unit_stat_getter_ = &unit_stat_getter;
if (OB_FAIL(unit_stat_map_.init(TenantBalanceStat::MAX_UNIT_CNT))) {
if (OB_UNLIKELY(inited_)) {
ret = OB_INIT_TWICE;
LOG_WARN("init twice", K(inited_));
} else if (OB_FAIL(unit_stat_getter_.init(check_stop_provider))) {
LOG_WARN("init unit stat getter fail", KR(ret));
} else if (OB_FAIL(unit_stat_map_.init(500000))) { /// FIXME: use more accurate CONSTANT
LOG_WARN("fail init unit stat map", K(ret));
} else {
schema_service_ = &schema_service;
unit_mgr_ = &unit_mgr;
inited_ = true;
}
inited_ = true;
return ret;
}
@ -61,9 +74,8 @@ int ObUnitStatManager::gather_stat()
if (OB_FAIL(unit_mgr_->get_unit_ids(unit_ids))) {
LOG_WARN("fail get unit ids", K(ret));
} else {
ObUnitStatMap::Item* stat = NULL;
FOREACH_CNT_X(unit_id, unit_ids, OB_SUCC(ret))
{
ObUnitStatMap::Item *stat = NULL;
FOREACH_CNT_X(unit_id, unit_ids, OB_SUCC(ret)) {
if (OB_FAIL(unit_stat_map_.locate(*unit_id, stat))) {
LOG_WARN("fail init stat for unit", K(*unit_id), K(ret));
}
@ -71,10 +83,9 @@ int ObUnitStatManager::gather_stat()
}
// walk through all meta tables to gather unit stat data
FOREACH_CNT_X(id, tenant_ids, OB_SUCC(ret))
{
FOREACH_CNT_X(id, tenant_ids, OB_SUCC(ret)) {
const uint64_t tenant_id = *id;
if (OB_FAIL(unit_stat_getter_->get_unit_stat(tenant_id, unit_stat_map_))) {
if (OB_FAIL(unit_stat_getter_.get_unit_stat(tenant_id, unit_stat_map_))) {
LOG_WARN("fail get unit stat", K(tenant_id), K(ret));
}
}
@ -82,14 +93,25 @@ int ObUnitStatManager::gather_stat()
return ret;
}
int ObUnitStatManager::get_unit_stat(uint64_t unit_id, share::ObUnitStat& unit_stat)
int ObUnitStatManager::get_unit_stat(
uint64_t unit_id,
const common::ObZone &zone,
share::ObUnitStat &unit_stat)
{
int ret = OB_SUCCESS;
if (!inited_) {
ret = OB_NOT_INIT;
LOG_WARN("not init", K(ret));
} else if (OB_FAIL(unit_stat_map_.get(unit_id, unit_stat))) {
LOG_WARN("fail get unit stat from map", K(unit_id), K(ret));
} else {
int tmp_ret = unit_stat_map_.get(unit_id, unit_stat);
if (OB_SUCCESS == tmp_ret) {
// good
} else {
ret = tmp_ret;
LOG_WARN("fail to get unit stat", KR(ret), K(unit_id), K(zone));
}
}
return ret;
}