OM支持在XMl中配置FIRST同步备机方式
This commit is contained in:
@ -19,6 +19,8 @@
|
||||
#############################################################################
|
||||
import os
|
||||
import sys
|
||||
import re
|
||||
import socket
|
||||
|
||||
sys.path.append(sys.path[0] + "/../../")
|
||||
from gspylib.common.GaussLog import GaussLog
|
||||
@ -90,7 +92,8 @@ class InstallImpl:
|
||||
# check timeout time.
|
||||
# Notice: time_out is not supported under TP branch
|
||||
self.checkTimeout()
|
||||
|
||||
# check syncNode is whether correct
|
||||
self.checkSyncNode()
|
||||
# check if have done preinstall for this user on every node
|
||||
self.checkGaussenvFlag()
|
||||
# check the clueter status
|
||||
@ -109,6 +112,54 @@ class InstallImpl:
|
||||
self.context.logger.closeLog()
|
||||
except Exception as e:
|
||||
GaussLog.exitWithError(str(e))
|
||||
|
||||
def checkSyncNode(self):
|
||||
"""
|
||||
function: check syncNode
|
||||
"""
|
||||
|
||||
hostname = socket.gethostname()
|
||||
clusterInfo = dbClusterInfo()
|
||||
clusterInfo.initFromXml(self.context.xmlFile)
|
||||
dbNodes = clusterInfo.dbNodes
|
||||
|
||||
dn = dict()
|
||||
for dbinfo in dbNodes:
|
||||
if dbinfo is None:
|
||||
self.context.logger.debug("the number of DN is zero")
|
||||
break
|
||||
datanodes = dbinfo.datanodes
|
||||
if datanodes[0].hostname == hostname:
|
||||
syncNumFirst = datanodes[0].syncNumFirst
|
||||
syncNum = datanodes[0].syncNum
|
||||
for datainfo in datanodes:
|
||||
dn[datainfo.hostname] = datainfo.instanceId
|
||||
self.context.logger.debug(dn)
|
||||
if syncNumFirst and syncNum != -1:
|
||||
raise Exception(ErrorCode.GAUSS_530["GAUSS_53011"] % "syncNode_hostname and dataNode1 cannot be exist at the same time")
|
||||
if syncNumFirst and syncNum == -1:
|
||||
syncNumFirstRe = re.sub('[,\s]', '', syncNumFirst)
|
||||
if re.match('(ANY[0-8](.*){1,8})', syncNumFirstRe) or re.match('(FIRST[0-8](.*){1,8})',syncNumFirstRe):
|
||||
self.context.logger.debug("Successfully. matching is correct")
|
||||
else:
|
||||
raise Exception(ErrorCode.GAUSS_530["GAUSS_53011"] % "syncNode_hostname, the match of syncNode_hostname is wrong.")
|
||||
for sync in dn.keys():
|
||||
if syncNumFirst.count(sync) > 1:
|
||||
raise Exception(ErrorCode.GAUSS_530["GAUSS_53011"] % "syncNode_hostname, the node in syncNode_hostname is must be the unique.")
|
||||
elif syncNumFirst.count(sync) == 0:
|
||||
if sync == hostname:
|
||||
self.context.logger.debug("syncNode_hostname, the syncNode_hostname does not including own hostname.")
|
||||
else:
|
||||
self.context.logger.debug("syncNode_hostname is including non-host nodes.")
|
||||
elif syncNumFirst.count(sync) == 1:
|
||||
if sync == hostname:
|
||||
raise Exception(ErrorCode.GAUSS_530["GAUSS_53011"] % "syncNode_hostname, the syncNode_hostname is including own hostname.")
|
||||
elif syncNumFirst.count("ANY") and syncNumFirst.count("FIRST"):
|
||||
raise Exception(ErrorCode.GAUSS_530["GAUSS_53011"] % "syncNode_hostname, it can be only one of 'ANY' or 'FIRST'.")
|
||||
else:
|
||||
syncNumFirst = syncNumFirst.replace(sync,'dn_%s' % (dn[sync]))
|
||||
self.context.logger.debug("Check syncNode_hostname is correct.")
|
||||
self.context.logger.debug(syncNumFirst)
|
||||
|
||||
def checkTimeout(self):
|
||||
"""
|
||||
|
Reference in New Issue
Block a user