def buildTransitionMessageCommand(transitionData, dir, port): dbData = transitionData["dbsByPort"][int(port)] targetMode = dbData["targetMode"] argsArr = [] argsArr.append(targetMode) if targetMode == 'mirror' or targetMode == 'primary': mode = dbData["mode"] if mode == 'r' and dbData["fullResyncFlag"]: # full resync requested, convert 'r' to 'f' argsArr.append( 'f' ) else: # otherwise, pass the mode through argsArr.append( dbData["mode"]) argsArr.append( dbData["hostName"]) argsArr.append( "%d" % dbData["hostPort"]) argsArr.append( dbData["peerName"]) argsArr.append( "%d" % dbData["peerPort"]) argsArr.append( "%d" % dbData["peerPMPort"]) # # write arguments to input file. We will leave this file around. It can be useful for debugging # inputFile = os.path.join( dir, "gp_pmtransition_args" ) writeLinesToFile(inputFile, argsArr) return SendFilerepTransitionMessage("Changing seg at dir %s" % dir, inputFile, port=port, dataDir=dir)
def buildTransitionMessageCommand(transitionData, dir, port): dbData = transitionData["dbsByPort"][int(port)] targetMode = dbData["targetMode"] argsArr = [] argsArr.append(targetMode) if targetMode == 'mirror' or targetMode == 'primary': mode = dbData["mode"] if mode == 'r' and dbData["fullResyncFlag"]: # full resync requested, convert 'r' to 'f' argsArr.append('f') else: # otherwise, pass the mode through argsArr.append(dbData["mode"]) argsArr.append(dbData["hostName"]) argsArr.append("%d" % dbData["hostPort"]) argsArr.append(dbData["peerName"]) argsArr.append("%d" % dbData["peerPort"]) argsArr.append("%d" % dbData["peerPMPort"]) # # write arguments to input file. We will leave this file around. It can be useful for debugging # inputFile = os.path.join(dir, "gp_pmtransition_args") writeLinesToFile(inputFile, argsArr) return SendFilerepTransitionMessage("Changing seg at dir %s" % dir, inputFile, port=port, dataDir=dir)
def __outputToFile(self, mirrorBuilder, file, gpArray): """ """ lines = [] # # now a line for each mirror # for i, toBuild in enumerate(mirrorBuilder.getMirrorsToBuild()): mirror = toBuild.getFailoverSegment() line = '%d|%s|%d|%s' % \ (mirror.getSegmentContentId(), \ canonicalize_address(mirror.getSegmentAddress()), \ mirror.getSegmentPort(), \ mirror.getSegmentDataDirectory()) lines.append(line) writeLinesToFile(self.__options.outputSampleConfigFile, lines)
def outputToFile(self, mirrorBuilder, gpArray, fileName): lines = [] # one entry for each failure for mirror in mirrorBuilder.getMirrorsToBuild(): output_str = "" seg = mirror.getFailedSegment() addr = canonicalize_address(seg.getSegmentAddress()) output_str += ('%s|%d|%s' % (addr, seg.getSegmentPort(), seg.getSegmentDataDirectory())) seg = mirror.getFailoverSegment() if seg is not None: output_str += ' ' addr = canonicalize_address(seg.getSegmentAddress()) output_str += ('%s|%d|%s' % ( addr, seg.getSegmentPort(), seg.getSegmentDataDirectory())) lines.append(output_str) writeLinesToFile(fileName, lines)
def outputToFile(self, mirrorBuilder, gpArray, fileName): lines = [] # one entry for each failure for mirror in mirrorBuilder.getMirrorsToBuild(): output_str = "" seg = mirror.getFailedSegment() addr = canonicalize_address(seg.getSegmentAddress()) output_str += ('%s:%d:%s' % (addr, seg.getSegmentPort(), seg.getSegmentDataDirectory())) seg = mirror.getFailoverSegment() if seg is not None: output_str += ' ' addr = canonicalize_address(seg.getSegmentAddress()) output_str += ('%s:%d:%s' % ( addr, seg.getSegmentPort(), seg.getSegmentDataDirectory())) lines.append(output_str) writeLinesToFile(fileName, lines)
def __outputToFile(self, mirrorBuilder, file, gpArray): """ """ lines = [] # # first line is always the filespace order # filespaceArr = [fs for fs in gpArray.getFilespaces(False)] lines.append("filespaceOrder=" + (":".join([fs.getName() for fs in filespaceArr]))) # # now a line for each mirror # for i, toBuild in enumerate(mirrorBuilder.getMirrorsToBuild()): mirror = toBuild.getFailoverSegment() primary = toBuild.getLiveSegment() # # build up :path1:path2 for the mirror segment's filespace paths # mirrorFilespaces = mirror.getSegmentFilespaces() filespaceValues = [] for fs in filespaceArr: path = mirrorFilespaces.get(fs.getOid()) assert path is not None # checking consistency should have been done earlier, but doublecheck here filespaceValues.append(":" + path) line = 'mirror%d=%d:%s:%d:%d:%d:%s%s' % \ (i, \ mirror.getSegmentContentId(), \ canonicalize_address( mirror.getSegmentAddress() ), \ mirror.getSegmentPort(), \ mirror.getSegmentReplicationPort(), \ primary.getSegmentReplicationPort(), \ mirror.getSegmentDataDirectory(), "".join(filespaceValues)) lines.append(line) writeLinesToFile(self.__options.outputSampleConfigFile, lines)
def __outputToFile(self, mirrorBuilder, file, gpArray): """ """ lines = [] # # first line is always the filespace order # filespaceArr = [fs for fs in gpArray.getFilespaces(False)] lines.append("filespaceOrder=" + (":".join([fs.getName() for fs in filespaceArr]))) # # now a line for each mirror # for i, toBuild in enumerate(mirrorBuilder.getMirrorsToBuild()): mirror = toBuild.getFailoverSegment() primary = toBuild.getLiveSegment() # # build up :path1:path2 for the mirror segment's filespace paths # mirrorFilespaces = mirror.getSegmentFilespaces() filespaceValues = [] for fs in filespaceArr: path = mirrorFilespaces.get(fs.getOid()) assert path is not None # checking consistency should have been done earlier, but doublecheck here filespaceValues.append(":" + path) line = "mirror%d=%d:%s:%d:%d:%d:%s%s" % ( i, mirror.getSegmentContentId(), canonicalize_address(mirror.getSegmentAddress()), mirror.getSegmentPort(), mirror.getSegmentReplicationPort(), primary.getSegmentReplicationPort(), mirror.getSegmentDataDirectory(), "".join(filespaceValues), ) lines.append(line) writeLinesToFile(self.__options.outputSampleConfigFile, lines)
def __outputToFile(self, mirrorBuilder, file, gpArray): """ """ lines = [] # # now a line for each mirror # for i, toBuild in enumerate(mirrorBuilder.getMirrorsToBuild()): mirror = toBuild.getFailoverSegment() primary = toBuild.getLiveSegment() line = 'mirror%d=%d:%s:%d:%s' % \ (i, \ mirror.getSegmentContentId(), \ canonicalize_address(mirror.getSegmentAddress()), \ mirror.getSegmentPort(), \ mirror.getSegmentDataDirectory()) lines.append(line) writeLinesToFile(self.__options.outputSampleConfigFile, lines)