本文整理汇总了Java中org.apache.solr.common.cloud.ZkStateReader.COLLECTIONS_ZKNODE属性的典型用法代码示例。如果您正苦于以下问题:Java ZkStateReader.COLLECTIONS_ZKNODE属性的具体用法?Java ZkStateReader.COLLECTIONS_ZKNODE怎么用?Java ZkStateReader.COLLECTIONS_ZKNODE使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.apache.solr.common.cloud.ZkStateReader
的用法示例。
在下文中一共展示了ZkStateReader.COLLECTIONS_ZKNODE属性的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: readConfigName
/**
* Returns config value given collection name
* Borrowed heavily from Solr's ZKController.
*/
public String readConfigName(SolrZkClient zkClient, String collection)
throws KeeperException, InterruptedException {
if (collection == null) {
throw new IllegalArgumentException("collection must not be null");
}
String configName = null;
// first check for alias
byte[] aliasData = zkClient.getData(ZkStateReader.ALIASES, null, null, true);
Aliases aliases = ClusterState.load(aliasData);
String alias = aliases.getCollectionAlias(collection);
if (alias != null) {
List<String> aliasList = StrUtils.splitSmart(alias, ",", true);
if (aliasList.size() > 1) {
throw new IllegalArgumentException("collection cannot be an alias that maps to multiple collections");
}
collection = aliasList.get(0);
}
String path = ZkStateReader.COLLECTIONS_ZKNODE + "/" + collection;
if (LOG.isInfoEnabled()) {
LOG.info("Load collection config from:" + path);
}
byte[] data = zkClient.getData(path, null, null, true);
if(data != null) {
ZkNodeProps props = ZkNodeProps.load(data);
configName = props.getStr(ZkController.CONFIGNAME_PROP);
}
if (configName != null && !zkClient.exists(ZkController.CONFIGS_ZKNODE + "/" + configName, true)) {
LOG.error("Specified config does not exist in ZooKeeper:" + configName);
throw new IllegalArgumentException("Specified config does not exist in ZooKeeper:"
+ configName);
}
return configName;
}
示例2: readConfigName
/**
* Returns config value given collection name
* Borrowed heavily from Solr's ZKController.
*/
public String readConfigName(SolrZkClient zkClient, String collection)
throws KeeperException, InterruptedException {
if (collection == null) {
throw new IllegalArgumentException("collection must not be null");
}
String configName = null;
// first check for alias
collection = checkForAlias(zkClient, collection);
String path = ZkStateReader.COLLECTIONS_ZKNODE + "/" + collection;
if (LOG.isInfoEnabled()) {
LOG.info("Load collection config from:" + path);
}
byte[] data = zkClient.getData(path, null, null, true);
if(data != null) {
ZkNodeProps props = ZkNodeProps.load(data);
configName = props.getStr(ZkController.CONFIGNAME_PROP);
}
if (configName != null && !zkClient.exists(ZkController.CONFIGS_ZKNODE + "/" + configName, true)) {
LOG.error("Specified config does not exist in ZooKeeper:" + configName);
throw new IllegalArgumentException("Specified config does not exist in ZooKeeper:"
+ configName);
}
return configName;
}