def retrieveNginxCnf(self): clusterUUID = getClusterUUID() resultValue = {} path = self.rootPath + "/" + clusterUUID + "/nginxcnf" if self.zk.exists(path): resultValue = self.DEFAULT_RETRY_POLICY(self.zk.get, path) return resultValue
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
def existCluster(self, uuid=None): self.zk.ensure_path(self.rootPath) cluster_uuids = self.zk.get_children(self.rootPath) if uuid is None: local_uuid = getClusterUUID() else: local_uuid = uuid if local_uuid in cluster_uuids: return True return False
def __lock_base_action(self, lock_name): clusterUUID = getClusterUUID() path = "%s/%s/lock/%s" % (self.rootPath, clusterUUID, lock_name) lock = self.zk.Lock(path, threading.current_thread()) isLock = lock.acquire(True, 1) return (isLock, lock)
def writeNginxCnf(self, NginxCnfPropsFullText): clusterUUID = getClusterUUID() path = self.rootPath + "/" + clusterUUID + "/nginxcnf" self.zk.ensure_path(path) self.DEFAULT_RETRY_POLICY( self.zk.set, path, NginxCnfPropsFullText) #version need to write
def retrieve_started_nodes(self): clusterUUID = getClusterUUID() path = self.rootPath + "/" + clusterUUID + "/monitor_status/node/started" started_nodes = self.__return_children_to_list(path) return started_nodes
def remove_started_node(self, container_node_name): clusterUUID = getClusterUUID() path = self.rootPath + "/" + clusterUUID + "/monitor_status/node/started/" + container_node_name if self.zk.exists(path): self.DEFAULT_RETRY_POLICY(self.zk.delete, path)
def write_started_node(self, container_node_name): clusterUUID = getClusterUUID() path = self.rootPath + "/" + clusterUUID + "/monitor_status/node/started/" + container_node_name self.zk.ensure_path(path)
def retrieve_nginx_node_info(self, container_node_name): clusterUUID = getClusterUUID() path = self.rootPath + "/" + clusterUUID + "/dataNode/" + container_node_name ip_dict = self.__retrieve_special_path_prop(path) return ip_dict
def retrieve_nginx_node_list(self): clusterUUID = getClusterUUID() path = self.rootPath + "/" + clusterUUID + "/dataNode" container_node_name_list = self.__return_children_to_list(path) return container_node_name_list
def _get_base_path(self): return self.root_path + '/' + get_cluster_name( ) + '/' + getClusterUUID()