def getResourcesInCluster(self, clusterName): """ Returns List<String> Parameters: clusterName: String @Override """ return _zkClient.getChildren(HelixUtil.getIdealStatePath(clusterName))
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)
idealState.setNumPartitions(partitions) idealState.setStateModelDefRef(stateModelRef) idealState.setIdealStateMode(mode.toString()) idealState.setReplicas("" + 0) idealState.setStateModelFactoryName(HelixConstants.DEFAULT_STATE_MODEL_FACTORY) if bucketSize > 0: idealState.setBucketSize(bucketSize) # String stateModelDefPath = PropertyPathConfig.getPath(PropertyType.STATEMODELDEFS, clusterName, stateModelRef) if not _zkClient.exists(stateModelDefPath): raise HelixException("State model " + stateModelRef + " not found in the cluster STATEMODELDEFS path") # String idealStatePath = HelixUtil.getIdealStatePath(clusterName) # String dbIdealStatePath = idealStatePath + "/" + resourceName if _zkClient.exists(dbIdealStatePath): raise HelixException("Skip the operation. DB ideal state directory exists:" + dbIdealStatePath) ZKUtil.createChildren(_zkClient, idealStatePath, idealState.getRecord()) def getClusters(self): """ Returns List<String> @Override