提交 e93afdc7 编写于 作者: Z zs0 提交者: wangzelin.wzl

check before auto migrate unit

上级 d011a522
......@@ -203,7 +203,8 @@ int ObServerBalancer::distribute_pool_for_standalone_sys_unit(
}
} else if (OB_FAIL(get_unit_resource_reservation(unit->unit_id_, migrate_server, in_migrate_unit_stat))) {
LOG_WARN("fail to get unit resource reservation", K(ret), K(unit), K(migrate_server));
} else if (OB_FAIL(try_migrate_unit(unit->unit_id_, unit_stat, in_migrate_unit_stat, migrate_server))) {
} else if (OB_FAIL(try_migrate_unit(
unit->unit_id_, pool.tenant_id_, unit_stat, in_migrate_unit_stat, migrate_server))) {
LOG_WARN("fail to migrate unit", K(ret), K(unit), K(unit_stat), K(in_migrate_unit_stat));
}
}
......@@ -319,8 +320,8 @@ int ObServerBalancer::distribute_for_unit_intersect()
} else if (OB_FAIL(get_unit_resource_reservation(
unit.unit_.unit_id_, migrate_server, in_migrate_unit_stat))) {
LOG_WARN("fail to get unit resource reservation", K(ret), K(unit), K(migrate_server));
} else if (OB_FAIL(
try_migrate_unit(unit.unit_.unit_id_, unit_stat, in_migrate_unit_stat, migrate_server))) {
} else if (OB_FAIL(try_migrate_unit(
unit.unit_.unit_id_, tenant_id, unit_stat, in_migrate_unit_stat, migrate_server))) {
LOG_WARN("fail to migrate unit", K(ret), K(unit), K(unit_stat), K(in_migrate_unit_stat));
}
}
......@@ -575,7 +576,11 @@ int ObServerBalancer::distribute_for_permanent_offline_or_delete(
ObArray<ObUnitStat> in_migrate_unit_stat;
if (OB_FAIL(get_unit_resource_reservation(unit_info.unit_.unit_id_, migrate_server, in_migrate_unit_stat))) {
LOG_WARN("get_unit_resource_reservation failed", K(unit_info), K(ret));
} else if (OB_FAIL(try_migrate_unit(unit_info.unit_.unit_id_, unit_stat, in_migrate_unit_stat, migrate_server))) {
} else if (OB_FAIL(try_migrate_unit(unit_info.unit_.unit_id_,
unit_info.pool_.tenant_id_,
unit_stat,
in_migrate_unit_stat,
migrate_server))) {
LOG_WARN("fail to try migrate unit", "unit", unit_info.unit_, K(migrate_server), K(ret));
} else {
LOG_INFO("migrate unit success", K(unit_info), K(status), "dest_server", migrate_server);
......@@ -649,7 +654,11 @@ int ObServerBalancer::distribute_for_migrate_in_blocked(const ObUnitInfo& unit_i
K(ret));
} else if (OB_FAIL(get_unit_resource_reservation(unit_info.unit_.unit_id_, new_server, in_migrate_unit_stat))) {
LOG_WARN("get_unit_resource_reservation failed", K(unit_info), K(ret));
} else if (OB_FAIL(try_migrate_unit(unit_info.unit_.unit_id_, unit_stat, in_migrate_unit_stat, new_server))) {
} else if (OB_FAIL(try_migrate_unit(unit_info.unit_.unit_id_,
unit_info.pool_.tenant_id_,
unit_stat,
in_migrate_unit_stat,
new_server))) {
LOG_WARN("fail to try migrate unit ", "unit", unit_info.unit_, K(new_server), K(ret));
}
}
......@@ -699,15 +708,15 @@ int ObServerBalancer::get_unit_resource_reservation(
return ret;
}
int ObServerBalancer::try_migrate_unit(const uint64_t unit_id, const ObUnitStat& unit_stat,
const ObIArray<ObUnitStat>& migrating_unit_stat, const ObAddr& dst)
int ObServerBalancer::try_migrate_unit(const uint64_t unit_id, const uint64_t tenant_id, const ObUnitStat &unit_stat,
const ObIArray<ObUnitStat> &migrating_unit_stat, const ObAddr &dst)
{
int ret = OB_SUCCESS;
if (!inited_) {
ret = OB_NOT_INIT;
LOG_WARN("server balancer not init", K_(inited), K(ret));
} else {
ret = unit_mgr_->try_migrate_unit(unit_id, unit_stat, migrating_unit_stat, dst);
ret = unit_mgr_->try_migrate_unit(unit_id, tenant_id, unit_stat, migrating_unit_stat, dst);
unit_migrated_ = true;
}
return ret;
......@@ -3222,6 +3231,7 @@ int ObServerBalancer::do_migrate_unit_task(const common::ObIArray<UnitMigrateSta
in_migrate_unit_stat))) {
LOG_WARN("fail to get unit resource reservation", K(ret));
} else if (OB_FAIL(try_migrate_unit(unit_migrate_stat.unit_load_.unit_->unit_id_,
unit_migrate_stat.unit_load_.pool_->tenant_id_,
unit_stat,
in_migrate_unit_stat,
unit_migrate_stat.arranged_pos_))) {
......@@ -3279,6 +3289,7 @@ int ObServerBalancer::do_migrate_unit_task(const common::ObIArray<UnitMigrateSta
in_migrate_unit_stat))) {
LOG_WARN("fail to get unit resource reservation", K(ret));
} else if (OB_FAIL(try_migrate_unit(unit_migrate_stat->unit_load_.unit_->unit_id_,
unit_migrate_stat->unit_load_.pool_->tenant_id_,
unit_stat,
in_migrate_unit_stat,
unit_migrate_stat->arranged_pos_))) {
......
......@@ -272,8 +272,8 @@ private:
int get_unit_resource_reservation(
uint64_t unit_id, const common::ObAddr& new_server, common::ObIArray<share::ObUnitStat>& in_migrate_unit_stat);
int try_migrate_unit(const uint64_t unit_id, const share::ObUnitStat& unit_stat,
const common::ObIArray<share::ObUnitStat>& migrating_unit_stat, const common::ObAddr& dst);
int try_migrate_unit(const uint64_t unit_id, const uint64_t tenant_id, const share::ObUnitStat &unit_stat,
const common::ObIArray<share::ObUnitStat> &migrating_unit_stat, const common::ObAddr &dst);
int try_cancel_migrate_unit(const share::ObUnit& unit, bool& is_canceled);
......
......@@ -8187,8 +8187,8 @@ int ObUnitManager::check_can_migrate_in(const ObAddr& server, bool& can_migrate_
return ret;
}
int ObUnitManager::try_migrate_unit(const uint64_t unit_id, const ObUnitStat& unit_stat,
const ObIArray<ObUnitStat>& migrating_unit_stat, const ObAddr& dst, const bool is_manual)
int ObUnitManager::try_migrate_unit(const uint64_t unit_id, const uint64_t tenant_id, const ObUnitStat &unit_stat,
const ObIArray<ObUnitStat> &migrating_unit_stat, const ObAddr &dst, const bool is_manual)
{
int ret = OB_SUCCESS;
ObServerStatus server_status;
......@@ -8237,13 +8237,10 @@ int ObUnitManager::try_migrate_unit(const uint64_t unit_id, const ObUnitStat& un
if (OB_SUCC(ret)) {
bool can_migrate = false;
share::ObUnitInfo unit_info;
if (OB_FAIL(get_unit_info_by_id(unit_id, unit_info))) {
LOG_WARN("fail to get unit info by id", KR(ret), K(unit_id));
} else if (OB_FAIL(check_unit_can_migrate(unit_info.pool_.tenant_id_, can_migrate))) {
LOG_WARN("fail to check unit can migrate", KR(ret), K(unit_info), K(can_migrate));
if (OB_FAIL(check_unit_can_migrate(tenant_id, can_migrate))) {
LOG_WARN("fail to check unit can migrate", KR(ret), K(tenant_id), K(can_migrate));
} else if (!can_migrate) {
LOG_INFO("can't migrate unit, don't need auto migrate unit", K(unit_info));
LOG_INFO("can't migrate unit, don't need auto migrate unit", K(tenant_id));
} else if (OB_FAIL(migrate_unit(unit_id, dst, is_manual))) {
LOG_WARN("fail migrate unit", K(unit_id), K(dst), K(ret));
}
......
......@@ -411,8 +411,8 @@ protected:
// check whether the target unit space is sufficient,
// if it is insufficient, do not migrate,
// and return OB_OP_NOT_ALLOW
int try_migrate_unit(const uint64_t unit_id, const share::ObUnitStat& unit_stat,
const common::ObIArray<share::ObUnitStat>& migrating_unit_stat, const common::ObAddr& dst,
int try_migrate_unit(const uint64_t unit_id, const uint64_t tenant_id, const share::ObUnitStat &unit_stat,
const common::ObIArray<share::ObUnitStat> &migrating_unit_stat, const common::ObAddr &dst,
const bool is_manual = false);
int get_zone_units(const common::ObArray<share::ObResourcePool*>& pools, common::ObArray<ZoneUnit>& zone_units) const;
virtual int end_migrate_unit(const uint64_t unit_id, const EndMigrateOp end_migrate_op = COMMIT);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册