提交 a19f7327 编写于 作者: S Shoaib Lari

gppylib: refactor SegmentPair to not support multiple mirrors

Long ago, we thought we might need to support multiple mirrors. But we
don't, and don't forsee it coming soon. Simplify the code to only ever
have one mirror, but still allow for the possibility of no mirrors

Author: Shoaib Lari <slari@pivotal.io>
Author: C.J. Jameson <cjameson@pivotal.io>
上级 bbc47080
......@@ -742,13 +742,13 @@ class SegmentTemplate:
def _select_src_segment(self):
"""Gets a segment to use as a source for pg_hba.conf
and postgresql.conf files"""
seg = self.gparray.segmentPairs[0]
if seg.primaryDB.valid:
self.srcSegHostname = seg.primaryDB.getSegmentHostName()
self.srcSegDataDir = seg.primaryDB.getSegmentDataDirectory()
elif seg.mirrorDBs[0] is not None and seg.mirrorDBs[0].valid:
self.srcSegHostname = seg.mirrorDBs[0].getSegmentHostName()
self.srcSegDataDir = seg.mirrorDBs[0].getSegmentDataDirectory()
segPair = self.gparray.segmentPairs[0]
if segPair.primaryDB.valid:
self.srcSegHostname = segPair.primaryDB.getSegmentHostName()
self.srcSegDataDir = segPair.primaryDB.getSegmentDataDirectory()
elif segPair.mirrorDB and segPair.mirrorDB.valid:
self.srcSegHostname = segPair.mirrorDB.getSegmentHostName()
self.srcSegDataDir = segPair.mirrorDB.getSegmentDataDirectory()
else:
raise SegmentTemplateError("no valid segdb for content=0 to use as a template")
......
此差异已折叠。
......@@ -224,7 +224,7 @@ class GpArrayTestCase(GpTestCase):
lastport = 0
for seg in gparray.segmentPairs:
prim = seg.primaryDB
mir = seg.mirrorDBs[0]
mir = seg.mirrorDB
self.assertNotEqual(prim.hostname, mir.hostname)
if prim.port not in portdict:
portdict[prim.port] = 1
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册