master/slaves => leader/followers

This commit is contained in:
2019-02-23 19:06:23 +01:00
parent b9ae1ec656
commit c3f968dbde
35 changed files with 923 additions and 1031 deletions

View File

@ -26,7 +26,7 @@ from ..i18n import _
from ..setting import ConfigBag, OptionBag, groups, undefined, owners, Undefined
from .baseoption import BaseOption
from .option import ALLOWED_CONST_LIST
from .syndynoptiondescription import SynDynOptionDescription, SynDynMasterSlaves
from .syndynoptiondescription import SynDynOptionDescription, SynDynLeadership
from ..error import ConfigError, ConflictError
@ -80,9 +80,9 @@ class CacheOptionDescription(BaseOption):
properties = option.impl_getproperties()
if 'force_store_value' in properties:
if __debug__:
if option.impl_is_master_slaves('slave'):
if option.impl_is_follower():
# problem with index
raise ConfigError(_('the slave "{0}" cannot have '
raise ConfigError(_('the follower "{0}" cannot have '
'"force_store_value" property').format(
option.impl_get_display_name()))
if option.issubdyn():
@ -92,28 +92,28 @@ class CacheOptionDescription(BaseOption):
force_store_values.append((subpath, option))
if __debug__ and 'force_default_on_freeze' in properties and \
'frozen' not in properties and \
option.impl_is_master_slaves('master'):
raise ConfigError(_('a master ({0}) cannot have '
option.impl_is_leader():
raise ConfigError(_('a leader ({0}) cannot have '
'"force_default_on_freeze" property without "frozen"'
'').format(subpath))
for cons_id, func, all_cons_opts, params in option.get_consistencies():
option._valid_consistencies(all_cons_opts[1:], init=False)
if func not in ALLOWED_CONST_LIST and is_multi:
if __debug__ and not option.impl_is_master_slaves():
if __debug__ and not option.impl_get_leadership():
raise ConfigError(_('malformed consistency option "{0}" '
'must be a masterslaves').format(
'must be a leadership').format(
option.impl_getname()))
masterslaves = option.impl_get_master_slaves()
leadership = option.impl_get_leadership()
for weak_opt in all_cons_opts:
opt = weak_opt()
if __debug__ and func not in ALLOWED_CONST_LIST and is_multi:
if not opt.impl_is_master_slaves():
if not opt.impl_get_leadership():
raise ConfigError(_('malformed consistency option "{0}" '
'must not be a multi for "{1}"').format(
option.impl_getname(), opt.impl_getname()))
elif masterslaves != opt.impl_get_master_slaves():
elif leadership != opt.impl_get_leadership():
raise ConfigError(_('malformed consistency option "{0}" '
'must be in same masterslaves as "{1}"').format(
'must be in same leadership as "{1}"').format(
option.impl_getname(), opt.impl_getname()))
_consistencies.setdefault(weak_opt,
[]).append((_consistencies_id,
@ -126,25 +126,25 @@ class CacheOptionDescription(BaseOption):
self._add_dependency(option)
if __debug__:
is_slave = None
is_follower = None
if is_multi:
all_requires = option.impl_getrequires()
for requires in all_requires:
for require in requires:
#if option in require is a multi:
# * option in require must be a master or a slave
# * current option must be a slave (and only a slave)
# * option in require and current option must be in same masterslaves
# * option in require must be a leader or a follower
# * current option must be a follower (and only a follower)
# * option in require and current option must be in same leadership
for require_opt, values in require[0]:
if require_opt.impl_is_multi():
if is_slave is None:
is_slave = option.impl_is_master_slaves('slave')
if is_slave:
masterslaves = option.impl_get_master_slaves()
if is_slave and require_opt.impl_is_master_slaves():
if masterslaves != require_opt.impl_get_master_slaves():
if is_follower is None:
is_follower = option.impl_is_follower()
if is_follower:
leadership = option.impl_get_leadership()
if is_follower and require_opt.impl_get_leadership():
if leadership != require_opt.impl_get_leadership():
raise ValueError(_('malformed requirements option "{0}" '
'must be in same masterslaves for "{1}"').format(
'must be in same leadership for "{1}"').format(
require_opt.impl_getname(), option.impl_getname()))
else:
raise ValueError(_('malformed requirements option "{0}" '
@ -311,7 +311,7 @@ class OptionDescription(OptionDescriptionWalk):
def impl_is_dynoptiondescription(self) -> bool:
return False
def impl_is_master_slaves(self) -> bool:
def impl_is_leadership(self) -> bool:
return False
# ____________________________________________________________
@ -319,7 +319,7 @@ class OptionDescription(OptionDescriptionWalk):
group_type: groups.GroupType) -> None:
"""sets a given group object to an OptionDescription
:param group_type: an instance of `GroupType` or `MasterGroupType`
:param group_type: an instance of `GroupType` or `LeadershipGroupType`
that lives in `setting.groups`
"""
if self._group_type != groups.default:
@ -329,8 +329,8 @@ class OptionDescription(OptionDescriptionWalk):
if not isinstance(group_type, groups.GroupType):
raise ValueError(_('group_type: {0}'
' not allowed').format(group_type))
if isinstance(group_type, groups.MasterGroupType):
raise ConfigError('please use MasterSlaves object instead of OptionDescription')
if isinstance(group_type, groups.LeadershipGroupType):
raise ConfigError('please use Leadership object instead of OptionDescription')
self._group_type = group_type
def impl_get_group_type(self) -> groups.GroupType: