init push

This commit is contained in:
oceanbase-admin
2021-05-31 22:56:52 +08:00
commit cea7de1475
7020 changed files with 5689869 additions and 0 deletions

View File

@ -0,0 +1,48 @@
/**
* Copyright (c) 2021 OceanBase
* OceanBase CE is licensed under Mulan PubL v2.
* You can use this software according to the terms and conditions of the Mulan PubL v2.
* You may obtain a copy of Mulan PubL v2 at:
* http://license.coscl.org.cn/MulanPubL-2.0
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PubL v2 for more details.
*/
#include "share/parameter/ob_parameter_attr.h"
namespace oceanbase {
namespace common {
#define _ATTR_STR(enum_str) #enum_str
#define _ATTR(enum_name) [enum_name] = _ATTR_STR(enum_name)
#define DEF_ATTR_VALUES(ATTR_CLS, args...) const char* ATTR_CLS::VALUES[] = {LST_DO(_ATTR, (, ), args)}
DEF_ATTR_VALUES(Section, ROOT_SERVICE, LOAD_BALANCE, DAILY_MERGE, LOCATION_CACHE, SSTABLE, CLOG, CACHE, TRANS, TENANT,
RPC, OBPROXY, OBSERVER);
DEF_ATTR_VALUES(Scope, CLUSTER, TENANT);
DEF_ATTR_VALUES(Source, DEFAULT, FILE, OBADMIN, CMDLINE, CLUSTER, TENANT);
DEF_ATTR_VALUES(Session, NO, YES);
DEF_ATTR_VALUES(VisibleLevel, SYS, COMMON, INVISIBLE);
DEF_ATTR_VALUES(EditLevel, READONLY, STATIC_EFFECTIVE, DYNAMIC_EFFECTIVE);
DEF_ATTR_VALUES(CompatMode, MYSQL, ORACLE, COMMON);
bool ObParameterAttr::is_static() const
{
return edit_level_ == EditLevel::STATIC_EFFECTIVE;
}
bool ObParameterAttr::is_readonly() const
{
return edit_level_ == EditLevel::READONLY;
}
bool ObParameterAttr::is_invisible() const
{
return visible_level_ == VisibleLevel::INVISIBLE;
}
} // namespace common
} // namespace oceanbase

View File

@ -0,0 +1,115 @@
/**
* Copyright (c) 2021 OceanBase
* OceanBase CE is licensed under Mulan PubL v2.
* You can use this software according to the terms and conditions of the Mulan PubL v2.
* You may obtain a copy of Mulan PubL v2 at:
* http://license.coscl.org.cn/MulanPubL-2.0
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PubL v2 for more details.
*/
#ifndef OCEANBASE_SHARE_PARAMETER_OB_PARAMETER_ATTR_H_
#define OCEANBASE_SHARE_PARAMETER_OB_PARAMETER_ATTR_H_
#include "lib/utility/ob_macro_utils.h"
namespace oceanbase {
namespace common {
#define _ENUM_EXP(arg) arg
#define DECL_ATTR(ATTR_CLS, args...) \
typedef struct ATTR_CLS { \
enum ATTR_CLS##Info{LST_DO(_ENUM_EXP, (, ), args)}; \
static const char* VALUES[]; \
} ATTR_CLS;
DECL_ATTR(Section, ROOT_SERVICE, LOAD_BALANCE, DAILY_MERGE, LOCATION_CACHE, SSTABLE, CLOG, CACHE, TRANS, TENANT, RPC,
OBPROXY, OBSERVER);
DECL_ATTR(Scope, CLUSTER, TENANT);
DECL_ATTR(Source, DEFAULT, FILE, OBADMIN, CMDLINE, CLUSTER, TENANT);
DECL_ATTR(Session, NO, YES);
DECL_ATTR(VisibleLevel, SYS, COMMON, INVISIBLE);
DECL_ATTR(EditLevel, READONLY, STATIC_EFFECTIVE, DYNAMIC_EFFECTIVE);
DECL_ATTR(CompatMode, MYSQL, ORACLE, COMMON);
// TODO: whether we need this
struct InfluencePlan {};
struct NeedSerialize {};
class ObParameterAttr {
public:
ObParameterAttr()
: section_(Section::OBSERVER),
scope_(Scope::CLUSTER),
source_(Source::DEFAULT),
session_(Session::NO),
visible_level_(VisibleLevel::COMMON),
edit_level_(EditLevel::DYNAMIC_EFFECTIVE),
compat_mode_(CompatMode::COMMON)
{}
// constructor without scope, session, visible_level and compat_mode
ObParameterAttr(
Section::SectionInfo section_info, Source::SourceInfo source_info, EditLevel::EditLevelInfo edit_level_info)
: section_(section_info),
scope_(Scope::CLUSTER),
source_(source_info),
session_(Session::NO),
visible_level_(VisibleLevel::COMMON),
edit_level_(edit_level_info),
compat_mode_(CompatMode::COMMON)
{}
void set_scope(Scope::ScopeInfo scope_info)
{
scope_ = scope_info;
}
const char* get_section() const
{
return Section::VALUES[section_];
}
const char* get_scope() const
{
return Scope::VALUES[scope_];
}
const char* get_source() const
{
return Source::VALUES[source_];
}
const char* get_session() const
{
return Session::VALUES[session_];
}
const char* get_visible_level() const
{
return VisibleLevel::VALUES[visible_level_];
}
const char* get_edit_level() const
{
return EditLevel::VALUES[edit_level_];
}
const char* get_compat_mode() const
{
return CompatMode::VALUES[compat_mode_];
}
bool is_static() const;
bool is_readonly() const;
bool is_invisible() const;
private:
Section::SectionInfo section_;
Scope::ScopeInfo scope_;
Source::SourceInfo source_;
Session::SessionInfo session_;
VisibleLevel::VisibleLevelInfo visible_level_;
EditLevel::EditLevelInfo edit_level_;
CompatMode::CompatModeInfo compat_mode_;
};
} // namespace common
} // namespace oceanbase
#endif

View File

@ -0,0 +1,170 @@
/**
* Copyright (c) 2021 OceanBase
* OceanBase CE is licensed under Mulan PubL v2.
* You can use this software according to the terms and conditions of the Mulan PubL v2.
* You may obtain a copy of Mulan PubL v2 at:
* http://license.coscl.org.cn/MulanPubL-2.0
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PubL v2 for more details.
*/
#ifndef OCEANBASE_SHARE_PARAMETER_OB_PARAMETER_MACRO_H_
#define OCEANBASE_SHARE_PARAMETER_OB_PARAMETER_MACRO_H_
////////////////////////////////////////////////////////////////////////////////
// SCOPE macro to support cluster or tenant parameter
////////////////////////////////////////////////////////////////////////////////
#define _OB_CLUSTER_PARAMETER common::Scope::CLUSTER
#define _OB_TENANT_PARAMETER common::Scope::TENANT
#define _DEF_PARAMETER_SCOPE_EASY(param, name, SCOPE, args...) SCOPE(_DEF_PARAMETER_EASY(param, _##SCOPE, name, args))
#define _DEF_PARAMETER_SCOPE_RANGE_EASY(param, name, SCOPE, args...) \
SCOPE(_DEF_PARAMETER_RANGE_EASY(param, _##SCOPE, name, args))
#define _DEF_PARAMETER_SCOPE_CHECKER_EASY(param, name, SCOPE, args...) \
SCOPE(_DEF_PARAMETER_CHECKER_EASY(param, _##SCOPE, name, args))
#define _DEF_PARAMETER_SCOPE_IP_EASY(param, name, SCOPE, def, args...) \
SCOPE(_DEF_PARAMETER_CHECKER_EASY(param, _##SCOPE, name, def, common::ObConfigIpChecker, args))
#define _DEF_PARAMETER_SCOPE_LOG_LEVEL_EASY(param, name, SCOPE, def, args...) \
SCOPE(_DEF_PARAMETER_CHECKER_EASY(param, _##SCOPE, name, def, common::ObConfigLogLevelChecker, args))
#define _DEF_PARAMETER_SCOPE_WORK_AREA_POLICY_EASY(param, name, SCOPE, def, args...) \
SCOPE(_DEF_PARAMETER_CHECKER_EASY(param, _##SCOPE, name, def, common::ObConfigWorkAreaPolicyChecker, args))
// TODO: use parameter instead of config
#define _DEF_PARAMETER_EASY(param, scope, name, args...) \
class ObConfig##param##Item##_##name : public common::ObConfig##param##Item { \
public: \
ObConfig##param##Item##_##name() : common::ObConfig##param##Item(local_container(), scope, #name, args) \
{} \
template <class T> \
ObConfig##param##Item##_##name& operator=(T value) \
{ \
common::ObConfig##param##Item::operator=(value); \
return *this; \
} \
} name;
#define _DEF_PARAMETER_RANGE_EASY(param, scope, name, args...) \
class ObConfig##param##Item##_##name : public common::ObConfig##param##Item { \
public: \
ObConfig##param##Item##_##name() : common::ObConfig##param##Item(local_container(), scope, #name, args) \
{} \
template <class T> \
ObConfig##param##Item##_##name& operator=(T value) \
{ \
common::ObConfig##param##Item::operator=(value); \
return *this; \
} \
} name;
#define _DEF_PARAMETER_CHECKER_EASY(param, scope, name, def, checker, args...) \
class ObConfig##param##Item##_##name : public common::ObConfig##param##Item { \
public: \
ObConfig##param##Item##_##name() : common::ObConfig##param##Item(local_container(), scope, #name, def, args) \
{ \
add_checker(new (std::nothrow) checker()); \
} \
template <class T> \
ObConfig##param##Item##_##name& operator=(T value) \
{ \
common::ObConfig##param##Item::operator=(value); \
return *this; \
} \
} name;
////////////////////////////////////////////////////////////////////////////////
#define DEF_INT(args...) _DEF_PARAMETER_SCOPE_RANGE_EASY(Int, args)
#define DEF_INT_WITH_CHECKER(args...) _DEF_PARAMETER_SCOPE_CHECKER_EASY(Int, args)
#define DEF_DBL(args...) _DEF_PARAMETER_SCOPE_RANGE_EASY(Double, args)
#define DEF_CAP(args...) _DEF_PARAMETER_SCOPE_RANGE_EASY(Capacity, args)
#define DEF_CAP_WITH_CHECKER(args...) _DEF_PARAMETER_SCOPE_CHECKER_EASY(Capacity, args)
#define DEF_TIME(args...) _DEF_PARAMETER_SCOPE_RANGE_EASY(Time, args)
#define DEF_TIME_WITH_CHECKER(args...) _DEF_PARAMETER_SCOPE_CHECKER_EASY(Time, args)
#define DEF_BOOL(args...) _DEF_PARAMETER_SCOPE_EASY(Bool, args)
#define DEF_STR(args...) _DEF_PARAMETER_SCOPE_EASY(String, args)
#define DEF_STR_WITH_CHECKER(args...) _DEF_PARAMETER_SCOPE_CHECKER_EASY(String, args)
#define DEF_IP(args...) _DEF_PARAMETER_SCOPE_IP_EASY(String, args)
#define DEF_MOMENT(args...) _DEF_PARAMETER_SCOPE_EASY(Moment, args)
#define DEF_INT_LIST(args...) _DEF_PARAMETER_SCOPE_EASY(IntList, args)
#define DEF_STR_LIST(args...) _DEF_PARAMETER_SCOPE_EASY(StrList, args)
#define DEF_LOG_ARCHIVE_OPTIONS_WITH_CHECKER(args...) _DEF_PARAMETER_SCOPE_CHECKER_EASY(LogArchiveOptions, args)
#define DEF_LOG_LEVEL(args...) _DEF_PARAMETER_SCOPE_LOG_LEVEL_EASY(String, args)
#define DEF_WORK_AREA_POLICY(args...) _DEF_PARAMETER_SCOPE_WORK_AREA_POLICY_EASY(String, args)
// for ERRSIM
#ifdef ERRSIM
#define ERRSIM_DEF_INT(args...) _DEF_PARAMETER_SCOPE_RANGE_EASY(Int, args)
#define ERRSIM_DEF_INT_WITH_CHECKER(args...) _DEF_PARAMETER_SCOPE_CHECKER_EASY(Int, args)
#define ERRSIM_DEF_DBL(args...) _DEF_PARAMETER_SCOPE_RANGE_EASY(Double, args)
#define ERRSIM_DEF_CAP(args...) _DEF_PARAMETER_SCOPE_RANGE_EASY(Capacity, args)
#define ERRSIM_DEF_CAP_WITH_CHECKER(args...) _DEF_PARAMETER_SCOPE_CHECKER_EASY(Capacity, args)
#define ERRSIM_DEF_TIME(args...) _DEF_PARAMETER_SCOPE_RANGE_EASY(Time, args)
#define ERRSIM_DEF_TIME_WITH_CHECKER(args...) _DEF_PARAMETER_SCOPE_CHECKER_EASY(Time, args)
#define ERRSIM_DEF_BOOL(args...) _DEF_PARAMETER_SCOPE_EASY(Bool, args)
#define ERRSIM_DEF_STR(args...) _DEF_PARAMETER_SCOPE_EASY(String, args)
#define ERRSIM_DEF_STR_WITH_CHECKER(args...) _DEF_PARAMETER_SCOPE_CHECKER_EASY(String, args)
#define ERRSIM_DEF_IP(args...) _DEF_PARAMETER_SCOPE_IP_EASY(String, args)
#define ERRSIM_DEF_MOMENT(args...) _DEF_PARAMETER_SCOPE_EASY(Moment, args)
#define ERRSIM_DEF_INT_LIST(args...) _DEF_PARAMETER_SCOPE_EASY(IntList, args)
#define ERRSIM_DEF_STR_LIST(args...) _DEF_PARAMETER_SCOPE_EASY(StrList, args)
#define ERRSIM_DEF_LOG_ARCHIVE_OPTIONS_WITH_CHECKER(args...) _DEF_PARAMETER_SCOPE_CHECKER_EASY(LogArchiveOptions, args)
#define ERRSIM_DEF_LOG_LEVEL(args...) _DEF_PARAMETER_SCOPE_LOG_LEVEL_EASY(String, args)
#define ERRSIM_DEF_WORK_AREA_POLICY(args...) _DEF_PARAMETER_SCOPE_WORK_AREA_POLICY_EASY(String, args)
#else
#define ERRSIM_DEF_INT(args...)
#define ERRSIM_DEF_INT_WITH_CHECKER(args...)
#define ERRSIM_DEF_DBL(args...)
#define ERRSIM_DEF_CAP(args...)
#define ERRSIM_DEF_CAP_WITH_CHECKER(args...)
#define ERRSIM_DEF_TIME(args...)
#define ERRSIM_DEF_TIME_WITH_CHECKER(args...)
#define ERRSIM_DEF_BOOL(args...)
#define ERRSIM_DEF_STR(args...)
#define ERRSIM_DEF_STR_WITH_CHECKER(args...)
#define ERRSIM_DEF_IP(args...)
#define ERRSIM_DEF_MOMENT(args...)
#define ERRSIM_DEF_INT_LIST(args...)
#define ERRSIM_DEF_STR_LIST(args...)
#define ERRSIM_DEF_LOG_ARCHIVE_OPTIONS_WITH_CHECKER(args...)
#define ERRSIM_DEF_LOG_LEVEL(args...)
#define ERRSIM_DEF_WORK_AREA_POLICY(args...)
#endif
#endif

File diff suppressed because it is too large Load Diff