Esempio n. 1
0
    def create(self, params):
        if params == {} or params is None:
            raise UserVisiableException("please set the componentNode info!")

        dataNodeInternalPort = params.get('dataNodeInternalPort')
        if dataNodeInternalPort is not None:
            raise UserVisiableException(
                "no need to set the dataNodeInternalPort param!")

        zkOper = Common_ZkOpers()

        local_uuid = getClusterUUID()
        existCluster = zkOper.existCluster(local_uuid)
        if not existCluster:
            raise UserVisiableException(
                "sync componentCluster info error! please check if sync uuid is right!"
            )

        params.setdefault("dataNodeInternalPort", options.port)
        dataNodeExternalPort = params.get('dataNodeExternalPort')
        if dataNodeExternalPort is None or '' == dataNodeExternalPort:
            params.setdefault("dataNodeExternalPort", options.port)

        self.confOpers.setValue(options.data_node_property, params)
        dataNodeProprs = self.confOpers.getValue(options.data_node_property)
        zkOper.writeDataNodeInfo(local_uuid, dataNodeProprs)

        result = {}
        result.setdefault(
            "message",
            "Configuration on this componentNode has been done successfully")
        return result
Esempio n. 2
0
    def create(self, params):
        if params == {} or params is None:
            raise UserVisiableException("please set the componentNode info!")

        dataNodeInternalPort = params.get('dataNodeInternalPort')
        if dataNodeInternalPort:
            raise UserVisiableException(
                "no need to set the dataNodeInternalPort param!")

        zkOper = Common_ZkOpers()

        existCluster = zkOper.existCluster()

        if existCluster:
            raise UserVisiableException(
                "server has belong to a componentCluster,should be not create new componentCluster!"
            )

        clusterUUID = str(uuid.uuid1())
        params.setdefault("clusterUUID", clusterUUID)

        params.setdefault("dataNodeInternalPort", options.port)
        dataNodeExternalPort = params.get('dataNodeExternalPort')
        if dataNodeExternalPort is None or '' == dataNodeExternalPort:
            params.setdefault("dataNodeExternalPort", options.port)

        self.confOpers.setValue(options.cluster_property, params)
        self.confOpers.setValue(options.data_node_property, params)

        clusterProps = self.confOpers.getValue(options.cluster_property)
        dataNodeProprs = self.confOpers.getValue(options.data_node_property)

        zkOper.writeClusterInfo(clusterUUID, clusterProps)
        zkOper.writeDataNodeInfo(clusterUUID, dataNodeProprs)

        return clusterUUID