def getInstancesInCluster(self, clusterName): """ Returns List<String> Parameters: clusterName: String @Override """ # String memberInstancesPath = HelixUtil.getMemberInstancesPath(clusterName) return _zkClient.getChildren(memberInstancesPath)
def addCluster(self, clusterName, overwritePrevRecord): """ Returns void Parameters: clusterName: StringoverwritePrevRecord: boolean @Override """ # String root = "/" + clusterName # String path = None if _zkClient.exists(root): logger.warn("Root directory exists.Cleaning the root directory:" + root + " overwritePrevRecord: " + overwritePrevRecord) if overwritePrevRecord: _zkClient.deleteRecursive(root) else: raise HelixException("Cluster " + clusterName + " already exists") _zkClient.createPersistent(root) _zkClient.createPersistent(HelixUtil.getIdealStatePath(clusterName)) path = PropertyPathConfig.getPath(PropertyType.CONFIGS, clusterName, ConfigScopeProperty.CLUSTER.toString(), clusterName) _zkClient.createPersistent(path, True) _zkClient.writeData(path, ZNRecord(clusterName)) path = PropertyPathConfig.getPath(PropertyType.CONFIGS, clusterName, ConfigScopeProperty.PARTICIPANT.toString()) _zkClient.createPersistent(path) path = PropertyPathConfig.getPath(PropertyType.CONFIGS, clusterName, ConfigScopeProperty.RESOURCE.toString()) _zkClient.createPersistent(path) path = PropertyPathConfig.getPath(PropertyType.PROPERTYSTORE, clusterName) _zkClient.createPersistent(path) _zkClient.createPersistent(HelixUtil.getLiveInstancesPath(clusterName)) _zkClient.createPersistent(HelixUtil.getMemberInstancesPath(clusterName)) _zkClient.createPersistent(HelixUtil.getExternalViewPath(clusterName)) _zkClient.createPersistent(HelixUtil.getStateModelDefinitionPath(clusterName)) _zkClient.createPersistent(HelixUtil.getControllerPath(clusterName)) path = PropertyPathConfig.getPath(PropertyType.HISTORY, clusterName) # ZNRecord emptyHistory = ZNRecord(PropertyType.HISTORY.toString()) # List<String> emptyList = ArrayList<String>() emptyHistory.setListField(clusterName, emptyList) _zkClient.createPersistent(path, emptyHistory) path = PropertyPathConfig.getPath(PropertyType.MESSAGES_CONTROLLER, clusterName) _zkClient.createPersistent(path) path = PropertyPathConfig.getPath(PropertyType.STATUSUPDATES_CONTROLLER, clusterName) _zkClient.createPersistent(path) path = PropertyPathConfig.getPath(PropertyType.ERRORS_CONTROLLER, clusterName) _zkClient.createPersistent(path)