Skip to content

Commit

Permalink
V2.2.0 (#176)
Browse files Browse the repository at this point in the history
  • Loading branch information
frf12 authored Aug 2, 2023
1 parent 156416e commit d84e56c
Show file tree
Hide file tree
Showing 78 changed files with 4,896 additions and 1,031 deletions.
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,3 @@ A:You can use the `obd update` command to update OBD. When you are done with t
## Protocol

OBD complies with [GPL-3.0](/LICENSE).

## Sysbench benchmark

- [Run the Sysbench benchmark test in OceanBase Database (Paetica, VLDB 2023)](https://github.com/oceanbase/oceanbase-doc/blob/V4.1.0/en-US/7.reference/3.performance-tuning-guide/6.performance-whitepaper/3.run-the-sysbench-benchmark-test-in-oceanbase-database.md)
4 changes: 3 additions & 1 deletion _cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
OBD_HOME_PATH = os.path.join(os.environ.get(CONST_OBD_HOME, os.getenv('HOME')), '.obd')
OBDIAG_HOME_PATH = os.path.join(os.environ.get(CONST_OBD_HOME, os.getenv('HOME')), 'oceanbase-diagnostic-tool')
COMMAND_ENV.load(os.path.join(OBD_HOME_PATH, '.obd_environ'), ROOT_IO)
ROOT_IO.default_confirm = COMMAND_ENV.get(ENV.ENV_DEFAULT_CONFIRM, '0') == '1'


class OptionHelpFormatter(IndentedHelpFormatter):
Expand Down Expand Up @@ -871,10 +872,11 @@ class ClusterRedeployCommand(ClusterMirrorCommand):
def __init__(self):
super(ClusterRedeployCommand, self).__init__('redeploy', 'Redeploy a started cluster.')
self.parser.add_option('-f', '--force-kill', action='store_true', help="Force kill the running observer process in the working directory.")
self.parser.add_option('--confirm', action='store_true', help='Confirm to redeploy.')

def _do_command(self, obd):
if self.cmds:
res = obd.redeploy_cluster(self.cmds[0])
res = obd.redeploy_cluster(self.cmds[0], need_confirm=not getattr(self.opts, 'confirm', False))
self.background_telemetry_task(obd)
return res
else:
Expand Down
17 changes: 11 additions & 6 deletions _deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -820,15 +820,20 @@ def get_server_conf(self, server):
self._cache_server[server] = self._apply_temp_conf(self._get_unprocessed_server_conf(server))
return self._cache_server[server]

def get_original_global_conf(self):
return deepcopy(self._original_global_conf)
def get_original_global_conf(self, format_conf=False):
conf = deepcopy(self._original_global_conf)
format_conf and self._apply_temp_conf(conf)
return conf

def get_original_server_conf(self, server):
return self._server_conf.get(server)
def get_original_server_conf(self, server, format_conf=False):
conf = deepcopy(self._server_conf.get(server))
format_conf and self._apply_temp_conf(conf)
return conf

def get_original_server_conf_with_global(self, server):
config = self.get_original_global_conf()
def get_original_server_conf_with_global(self, server, format_conf=False):
config = deepcopy(self.get_original_global_conf())
config.update(self._server_conf.get(server, {}))
format_conf and self._apply_temp_conf(config)
return config


Expand Down
3 changes: 3 additions & 0 deletions _environ.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,6 @@

# telemetry log mode. 0 - disable, 1 - enable.
TELEMETRY_LOG_MODE = "TELEMETRY_LOG_MODE"

# ROOT IO DEFAULT CONFIRM. 0 - disable, 1 - enable.
ENV_DEFAULT_CONFIRM = "IO_DEFAULT_CONFIRM"
3 changes: 3 additions & 0 deletions _errno.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,9 @@ class InitDirFailedErrorMessage(object):
EC_OCP_EXPRESS_META_DB_NOT_ENOUGH_LOG_DISK = OBDErrorCodeTemplate(4305, 'There is not enough log disk for ocp meta tenant.')
EC_OCP_EXPRESS_META_DB_NOT_ENOUGH_MEM = OBDErrorCodeTemplate(4305, 'There is not enough memory for ocp meta tenant')
EC_OCP_EXPRESS_ADMIN_PASSWD_ERROR = OBDErrorCodeTemplate(4306, '({ip}) ocp-express admin_passwd invalid.(Current :{current})')

# 4350-4399 had been used by ocp

# sql
EC_SQL_EXECUTE_FAILED = OBDErrorCodeTemplate(5000, "{sql} execute failed")

Expand Down
6 changes: 3 additions & 3 deletions _mirror.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,9 +271,9 @@ def __init__(self, mirror_path, meta_data, stdio=None):
self._load_repo_age()
if self.enabled:
repo_age = ConfigUtil.get_value_from_dict(meta_data, 'repo_age', 0, int)
if repo_age > self.repo_age or int(time.time()) - 86400 > self.repo_age:
self.repo_age = repo_age
self.update_mirror()
if (repo_age > self.repo_age or int(time.time()) - 86400 > self.repo_age) and self.available:
if self.update_mirror():
self.repo_age = repo_age

@property
def available(self):
Expand Down
242 changes: 14 additions & 228 deletions _plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
from _rpm import Version
from ssh import ConcurrentExecutor
from tool import ConfigUtil, DynamicLoading, YamlLoader, FileUtil
from _types import *


yaml = YamlLoader()
Expand Down Expand Up @@ -360,225 +361,9 @@ class Null(object):
def __init__(self):
pass


class ParamPlugin(Plugin):


class ConfigItemType(object):

TYPE_STR = None
NULL = Null()

def __init__(self, s):
try:
self._origin = s
self._value = 0
self.value = self.NULL
self._format()
if self.value == self.NULL:
self.value = self._origin
except:
raise Exception("'%s' is not %s" % (self._origin, self._type_str))

@property
def _type_str(self):
if self.TYPE_STR is None:
self.TYPE_STR = str(self.__class__.__name__).split('.')[-1]
return self.TYPE_STR

def _format(self):
raise NotImplementedError

def __str__(self):
return str(self._origin)

def __hash__(self):
return self._origin.__hash__()

@property
def __cmp_value__(self):
return self._value

def __eq__(self, value):
if value is None:
return False
return self.__cmp_value__ == value.__cmp_value__

def __gt__(self, value):
if value is None:
return True
return self.__cmp_value__ > value.__cmp_value__

def __ge__(self, value):
if value is None:
return True
return self.__eq__(value) or self.__gt__(value)

def __lt__(self, value):
if value is None:
return False
return self.__cmp_value__ < value.__cmp_value__

def __le__(self, value):
if value is None:
return False
return self.__eq__(value) or self.__lt__(value)


class Moment(ConfigItemType):

def _format(self):
if self._origin:
if self._origin.upper() == 'DISABLE':
self._value = 0
else:
r = re.match('^(\d{1,2}):(\d{1,2})$', self._origin)
h, m = r.groups()
h, m = int(h), int(m)
if 0 <= h <= 23 and 0 <= m <= 60:
self._value = h * 60 + m
else:
raise Exception('Invalid Value')
else:
self._value = 0

class Time(ConfigItemType):

UNITS = {
'ns': 0.000000001,
'us': 0.000001,
'ms': 0.001,
's': 1,
'm': 60,
'h': 3600,
'd': 86400
}

def _format(self):
if self._origin:
self._origin = str(self._origin).strip()
if self._origin.isdigit():
n = self._origin
unit = self.UNITS['s']
else:
r = re.match('^(\d+)(\w+)$', self._origin.lower())
n, u = r.groups()
unit = self.UNITS.get(u.lower())
if unit:
self._value = int(n) * unit
else:
raise Exception('Invalid Value')
else:
self._value = 0

class Capacity(ConfigItemType):

UNITS = {"B": 1, "K": 1<<10, "M": 1<<20, "G": 1<<30, "T": 1<<40, 'P': 1 << 50}

def _format(self):
if self._origin:
self._origin = str(self._origin).strip()
if self._origin.isdigit():
n = self._origin
unit = self.UNITS['M']
else:
r = re.match('^(\d+)(\w)B?$', self._origin.upper())
n, u = r.groups()
unit = self.UNITS.get(u.upper())
if unit:
self._value = int(n) * unit
else:
raise Exception('Invalid Value')
else:
self._value = 0

class StringList(ConfigItemType):

def _format(self):
if self._origin:
self._origin = str(self._origin).strip()
self._value = self._origin.split(';')
else:
self._value = []

class Dict(ConfigItemType):

def _format(self):
if self._origin:
if not isinstance(self._origin, dict):
raise Exception("Invalid Value")
self._value = self._origin
else:
self._value = self.value = {}

class List(ConfigItemType):

def _format(self):
if self._origin:
if not isinstance(self._origin, list):
raise Exception("Invalid value: {} is not a list.".format(self._origin))
self._value = self._origin
else:
self._value = self.value = []

class StringOrKvList(ConfigItemType):

def _format(self):
if self._origin:
if not isinstance(self._origin, list):
raise Exception("Invalid value: {} is not a list.".format(self._origin))
for item in self._origin:
if not item:
continue
if not isinstance(item, (str, dict)):
raise Exception("Invalid value: {} should be string or key-value format.".format(item))
if isinstance(item, dict):
if len(item.keys()) != 1:
raise Exception("Invalid value: {} should be single key-value format".format(item))
self._value = self._origin
else:
self._value = self.value = []

class Double(ConfigItemType):

def _format(self):
self.value = self._value = float(self._origin) if self._origin else 0

class Boolean(ConfigItemType):

def _format(self):
if isinstance(self._origin, bool):
self._value = self._origin
else:
_origin = str(self._origin).lower()
if _origin == 'true':
self._value = True
elif _origin == 'false':
self._value = False
elif _origin.isdigit():
self._value = bool(self._origin)
else:
raise Exception('%s is not Boolean' % _origin)
self.value = self._value

class Integer(ConfigItemType):

def _format(self):
if self._origin is None:
self._value = 0
self._origin = 0
else:
_origin = str(self._origin)
try:
self.value = self._value = int(_origin)
except:
raise Exception('%s is not Integer' % _origin)

class String(ConfigItemType):

def _format(self):
self.value = self._value = str(self._origin) if self._origin else ''

class ConfigItem(object):

def __init__(
Expand Down Expand Up @@ -667,17 +452,18 @@ def params(self):
if self._src_data is None:
try:
TYPES = {
'DOUBLE': ParamPlugin.Double,
'BOOL': ParamPlugin.Boolean,
'INT': ParamPlugin.Integer,
'STRING': ParamPlugin.String,
'MOMENT': ParamPlugin.Moment,
'TIME': ParamPlugin.Time,
'CAPACITY': ParamPlugin.Capacity,
'STRING_LIST': ParamPlugin.StringList,
'DICT': ParamPlugin.Dict,
'LIST': ParamPlugin.List,
'PARAM_LIST': ParamPlugin.StringOrKvList
'DOUBLE': Double,
'BOOL': Boolean,
'INT': Integer,
'STRING': String,
'MOMENT': Moment,
'TIME': Time,
'CAPACITY': Capacity,
'CAPACITY_MB': CapacityMB,
'STRING_LIST': StringList,
'DICT': Dict,
'LIST': List,
'PARAM_LIST': StringOrKvList
}
self._src_data = {}
with open(self.def_param_yaml_path, 'rb') as f:
Expand All @@ -688,7 +474,7 @@ def params(self):
if param_type in TYPES:
param_type = TYPES[param_type]
else:
param_type = ParamPlugin.String
param_type = String

self._src_data[conf['name']] = ParamPlugin.ConfigItem(
name=conf['name'],
Expand Down
2 changes: 1 addition & 1 deletion _repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ def _paraller(self):
pool.close()
pool = None
except:
self.stdio and getattr(self.stdio, 'exception', print)()
self.stdio and getattr(self.stdio, 'exception', print)('')
finally:
pool and pool.close()
return False
Expand Down
Loading

0 comments on commit d84e56c

Please sign in to comment.