refine ObFuncType interface
This commit is contained in:
@ -668,34 +668,6 @@ int ObResourceManagerProxy::check_if_user_exist(
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObResourceManagerProxy::check_if_function_exist(const ObString &function_name, bool &exist)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
if (0 == function_name.compare("COMPACTION_HIGH") ||
|
||||
0 == function_name.compare("HA_HIGH") ||
|
||||
0 == function_name.compare("COMPACTION_MID") ||
|
||||
0 == function_name.compare("HA_MID") ||
|
||||
0 == function_name.compare("COMPACTION_LOW") ||
|
||||
0 == function_name.compare("HA_LOW") ||
|
||||
0 == function_name.compare("DDL_HIGH") ||
|
||||
0 == function_name.compare("DDL") ||
|
||||
0 == function_name.compare("CLOG_LOW") ||
|
||||
0 == function_name.compare("CLOG_MID") ||
|
||||
0 == function_name.compare("CLOG_HIGH") ||
|
||||
0 == function_name.compare("OPT_STATS") ||
|
||||
0 == function_name.compare("IMPORT") ||
|
||||
0 == function_name.compare("EXPORT") ||
|
||||
0 == function_name.compare("SQL_AUDIT") ||
|
||||
0 == function_name.compare("GC_MACRO_BLOCK") ||
|
||||
0 == function_name.compare("MICRO_MINI_MERGE")) {
|
||||
exist = true;
|
||||
} else {
|
||||
exist = false;
|
||||
LOG_WARN("invalid function name", K(function_name));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObResourceManagerProxy::check_if_column_exist(
|
||||
uint64_t tenant_id,
|
||||
const ObString &db_name,
|
||||
@ -1414,7 +1386,7 @@ int ObResourceManagerProxy::replace_function_mapping_rule(ObMySQLTransaction &tr
|
||||
bool function_exist = false;
|
||||
if (OB_SUCC(ret)) {
|
||||
// Same as user rule, the mapping is unsuccessful but no error is thrown
|
||||
if (OB_FAIL(check_if_function_exist(value, function_exist))) {
|
||||
if (OB_FAIL(oceanbase::share::check_if_function_exist(value, function_exist))) {
|
||||
LOG_WARN("fail check if function exist", K(tenant_id), K(value), K(ret));
|
||||
} else if (OB_UNLIKELY(!function_exist)) {
|
||||
ret = OB_INVALID_CONFIG;
|
||||
|
@ -212,7 +212,6 @@ private:
|
||||
uint64_t tenant_id,
|
||||
const common::ObString &user_name,
|
||||
bool &exist);
|
||||
int check_if_function_exist(const common::ObString &function_name, bool &exist);
|
||||
int check_if_column_exist(
|
||||
uint64_t tenant_id,
|
||||
const common::ObString &db_name,
|
||||
|
@ -16,64 +16,32 @@
|
||||
using namespace oceanbase::common;
|
||||
using namespace oceanbase::share;
|
||||
|
||||
int oceanbase::share::check_if_function_exist(const ObString &function_name, bool &exist)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
if (
|
||||
#define OB_RESOURCE_FUNCTION_TYPE_DEF(function_type_string) 0 == function_name.compare(#function_type_string) ||
|
||||
#include "ob_resource_plan_info.h"
|
||||
#undef OB_RESOURCE_FUNCTION_TYPE_DEF
|
||||
0) {
|
||||
exist = true;
|
||||
} else {
|
||||
exist = false;
|
||||
LOG_WARN("invalid function name", K(function_name));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
ObString oceanbase::share::get_io_function_name(ObFunctionType function_type)
|
||||
{
|
||||
ObString ret_name;
|
||||
switch (function_type) {
|
||||
case share::ObFunctionType::DEFAULT_FUNCTION:
|
||||
ret_name = "DEFAULT_FUNCTION";
|
||||
break;
|
||||
case ObFunctionType::PRIO_COMPACTION_HIGH:
|
||||
ret_name = ObString("COMPACTION_HIGH");
|
||||
break;
|
||||
case ObFunctionType::PRIO_HA_HIGH:
|
||||
ret_name = ObString("HA_HIGH");
|
||||
break;
|
||||
case ObFunctionType::PRIO_COMPACTION_MID:
|
||||
ret_name = ObString("COMPACTION_MID");
|
||||
break;
|
||||
case ObFunctionType::PRIO_HA_MID:
|
||||
ret_name = ObString("HA_MID");
|
||||
break;
|
||||
case ObFunctionType::PRIO_COMPACTION_LOW:
|
||||
ret_name = ObString("COMPACTION_LOW");
|
||||
break;
|
||||
case ObFunctionType::PRIO_HA_LOW:
|
||||
ret_name = ObString("HA_LOW");
|
||||
break;
|
||||
case ObFunctionType::PRIO_DDL:
|
||||
ret_name = ObString("DDL");
|
||||
break;
|
||||
case ObFunctionType::PRIO_DDL_HIGH:
|
||||
ret_name = ObString("DDL_HIGH");
|
||||
break;
|
||||
case ObFunctionType::PRIO_GC_MACRO_BLOCK:
|
||||
ret_name = ObString("GC_MACRO_BLOCK");
|
||||
break;
|
||||
case ObFunctionType::PRIO_CLOG_LOW:
|
||||
ret_name = ObString("CLOG_LOW");
|
||||
break;
|
||||
case ObFunctionType::PRIO_CLOG_MID:
|
||||
ret_name = ObString("CLOG_MID");
|
||||
break;
|
||||
case ObFunctionType::PRIO_CLOG_HIGH:
|
||||
ret_name = ObString("CLOG_HIGH");
|
||||
break;
|
||||
case ObFunctionType::PRIO_OPT_STATS:
|
||||
ret_name = ObString("OPT_STATS");
|
||||
break;
|
||||
case ObFunctionType::PRIO_IMPORT:
|
||||
ret_name = ObString("IMPORT");
|
||||
break;
|
||||
case ObFunctionType::PRIO_EXPORT:
|
||||
ret_name = ObString("EXPORT");
|
||||
break;
|
||||
case ObFunctionType::PRIO_SQL_AUDIT:
|
||||
ret_name = ObString("SQL_AUDIT");
|
||||
break;
|
||||
case ObFunctionType::PRIO_MICRO_MINI_MERGE:
|
||||
ret_name = ObString("MICRO_MINI_MERGE");
|
||||
#define OB_RESOURCE_FUNCTION_TYPE_DEF(function_type_string) \
|
||||
case ObFunctionType::PRIO_##function_type_string: \
|
||||
ret_name = ObString(#function_type_string); \
|
||||
break;
|
||||
#include "ob_resource_plan_info.h"
|
||||
#undef OB_RESOURCE_FUNCTION_TYPE_DEF
|
||||
default:
|
||||
ret_name = ObString("OTHER_GROUPS");
|
||||
break;
|
||||
|
@ -10,6 +10,38 @@
|
||||
* See the Mulan PubL v2 for more details.
|
||||
*/
|
||||
|
||||
// Define a function type of resource manager
|
||||
// Examples:
|
||||
// Defination:
|
||||
// DAG_SCHEDULER_DAG_PRIO_DEF(TEST_FUNCTION)
|
||||
// Use this function type:
|
||||
// ObFunctionType func_type = ObFunctionType::PRIO_TEST_FUNCTION
|
||||
// Get function name:
|
||||
// ObString functiono_name = get_io_function_name(ObFunctionType::PRIO_TEST_FUNCTION)
|
||||
// Check if function name exist:
|
||||
// bool is_exist = false;
|
||||
// check_if_function_exist("TEST_FUNCTION", is_exist)
|
||||
#ifdef OB_RESOURCE_FUNCTION_TYPE_DEF
|
||||
// DAG_SCHEDULER_DAG_PRIO_DEF(function_type_string)
|
||||
OB_RESOURCE_FUNCTION_TYPE_DEF(COMPACTION_HIGH)
|
||||
OB_RESOURCE_FUNCTION_TYPE_DEF(HA_HIGH)
|
||||
OB_RESOURCE_FUNCTION_TYPE_DEF(COMPACTION_MID)
|
||||
OB_RESOURCE_FUNCTION_TYPE_DEF(HA_MID)
|
||||
OB_RESOURCE_FUNCTION_TYPE_DEF(COMPACTION_LOW)
|
||||
OB_RESOURCE_FUNCTION_TYPE_DEF(HA_LOW)
|
||||
OB_RESOURCE_FUNCTION_TYPE_DEF(DDL)
|
||||
OB_RESOURCE_FUNCTION_TYPE_DEF(DDL_HIGH)
|
||||
OB_RESOURCE_FUNCTION_TYPE_DEF(GC_MACRO_BLOCK) // block manager scans for bad blocks in the background
|
||||
OB_RESOURCE_FUNCTION_TYPE_DEF(CLOG_LOW)
|
||||
OB_RESOURCE_FUNCTION_TYPE_DEF(CLOG_MID)
|
||||
OB_RESOURCE_FUNCTION_TYPE_DEF(CLOG_HIGH)
|
||||
OB_RESOURCE_FUNCTION_TYPE_DEF(OPT_STATS)
|
||||
OB_RESOURCE_FUNCTION_TYPE_DEF(IMPORT)
|
||||
OB_RESOURCE_FUNCTION_TYPE_DEF(EXPORT)
|
||||
OB_RESOURCE_FUNCTION_TYPE_DEF(SQL_AUDIT)
|
||||
OB_RESOURCE_FUNCTION_TYPE_DEF(MICRO_MINI_MERGE)
|
||||
#endif
|
||||
|
||||
#ifndef OB_SHARE_RESOURCE_MANAGER_OB_PLAN_INFO_H_
|
||||
#define OB_SHARE_RESOURCE_MANAGER_OB_PLAN_INFO_H_
|
||||
|
||||
@ -29,30 +61,13 @@ namespace share
|
||||
enum ObFunctionType : uint8_t
|
||||
{
|
||||
DEFAULT_FUNCTION = 0,
|
||||
PRIO_COMPACTION_HIGH = 1,
|
||||
PRIO_HA_HIGH = 2,
|
||||
PRIO_COMPACTION_MID = 3,
|
||||
PRIO_HA_MID = 4,
|
||||
PRIO_COMPACTION_LOW = 5,
|
||||
PRIO_HA_LOW = 6,
|
||||
PRIO_DDL = 7,
|
||||
PRIO_DDL_HIGH = 8,
|
||||
PRIO_GC_MACRO_BLOCK = 9, // block manager scans for bad blocks in the background
|
||||
PRIO_CLOG_LOW = 10,
|
||||
PRIO_CLOG_MID = 11,
|
||||
PRIO_CLOG_HIGH = 12,
|
||||
PRIO_OPT_STATS = 13,
|
||||
PRIO_IMPORT = 14,
|
||||
PRIO_EXPORT = 15,
|
||||
/* add new function type here, or you will have compatibility issues. */
|
||||
PRIO_SQL_AUDIT = 16,
|
||||
|
||||
PRIO_MICRO_MINI_MERGE = 17,
|
||||
|
||||
/* add new function, can learn by "grep -rnI 'CLOG_HIGH' src/" */
|
||||
#define OB_RESOURCE_FUNCTION_TYPE_DEF(function_type_string) PRIO_##function_type_string,
|
||||
#include "ob_resource_plan_info.h"
|
||||
#undef OB_RESOURCE_FUNCTION_TYPE_DEF
|
||||
MAX_FUNCTION_NUM
|
||||
};
|
||||
ObString get_io_function_name(ObFunctionType function_type);
|
||||
int check_if_function_exist(const ObString &function_name, bool &exist);
|
||||
|
||||
// 为了便于作为 hash value,所以把 ObString 包一下
|
||||
class ObResMgrVarcharValue
|
||||
|
Reference in New Issue
Block a user