本文整理汇总了Python中mpp.lib.config.GPDBConfig.get_segments_count_per_host方法的典型用法代码示例。如果您正苦于以下问题:Python GPDBConfig.get_segments_count_per_host方法的具体用法?Python GPDBConfig.get_segments_count_per_host怎么用?Python GPDBConfig.get_segments_count_per_host使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mpp.lib.config.GPDBConfig
的用法示例。
在下文中一共展示了GPDBConfig.get_segments_count_per_host方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _generate_gpexpand_input_files
# 需要导入模块: from mpp.lib.config import GPDBConfig [as 别名]
# 或者: from mpp.lib.config.GPDBConfig import get_segments_count_per_host [as 别名]
def _generate_gpexpand_input_files(self):
config = GPDBConfig()
# use the last segment as a template
# TODO: This logic needs fixing when we enable mirror tests
seg = (sorted(config.record, lambda a, b: b.content - a.content)).pop(0)
# Find max db id for generating gpexpand input file
max_db_id = max([r.dbid for r in config.record])
self.assertNotEqual(seg.content, -1)
def next_datadir(datadir, i=1):
# /path/to/foo/seg12 -> /path/to/foo/seg13
lefthand = datadir.rstrip('0123456789')
segnum = int(datadir[len(lefthand):])
return lefthand + str(segnum + i)
with open(self.testcase_gpexpand_file, 'w') as f:
# For existing hosts, add self.number_of_expansion_segments
# For new hosts add existing number of segments + number_of_expansion_segments
# Existing hosts
existing_hosts = config.get_hosts(segments=True)
existing_number_of_segments = 0
cnt = 1
for host in existing_hosts:
# Find the existing number of segments in the existing hosts
existing_number_of_segments = config.get_segments_count_per_host()[host]
for i in range(self.number_of_expansion_segments):
f.write(
"{host}:{addr}:{port}:{datadir}:{dbid}:{content}:{role}\n".format(
host=host,
addr=host,
port= int(seg.port) + cnt,
datadir=next_datadir(seg.datadir, cnt),
dbid=int(max_db_id) + cnt,
content= int(seg.content) + cnt,
role='p'
))
cnt += 1
# New hosts
if self.number_of_expansion_hosts > 0:
new_expansion_hosts = list(set(self.hosts) - existing_hosts)
if not new_expansion_hosts:
raise GPExpandTestCaseException("No new hosts available for expansion based on the environment variable GPEXPAND_HOSTS: %s" %os.environ.get("GPEXPAND_HOSTS"))
for host in new_expansion_hosts[0:self.number_of_expansion_hosts]:
for i in range(existing_number_of_segments + self.number_of_expansion_segments):
f.write(
"{host}:{addr}:{port}:{datadir}:{dbid}:{content}:{role}\n".format(
host=host,
addr=host,
port= int(seg.port) + cnt,
datadir=next_datadir(seg.datadir, cnt),
dbid=int(seg.dbid) + cnt,
content= int(seg.content) + cnt,
role='p'
))
cnt += 1