Example usage for org.apache.solr.common.cloud ZkNodeProps getStr

List of usage examples for org.apache.solr.common.cloud ZkNodeProps getStr

Introduction

In this page you can find the example usage for org.apache.solr.common.cloud ZkNodeProps getStr.

Prototype

public String getStr(String key) 

Source Link

Document

Get a string property value.

Usage

From source file:com.cloudera.cdk.morphline.solr.ZooKeeperDownloader.java

License:Apache License

/**
 * Returns config value given collection name
 * Borrowed heavily from Solr's ZKController.
 *//*from  ww  w  .  j  a  va2s  .c om*/
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;
}

From source file:org.vootoo.server.Vootoo.java

License:Apache License

public static SolrCore checkProps(CoreContainer cores, ZkNodeProps zkProps) {
    String corename;//w w  w  .  j a v a2  s .  c  o  m
    SolrCore core = null;
    if (cores.getZkController().getNodeName().equals(zkProps.getStr(ZkStateReader.NODE_NAME_PROP))) {
        corename = zkProps.getStr(ZkStateReader.CORE_NAME_PROP);
        core = cores.getCore(corename);
    }
    return core;
}

From source file:uk.bl.wa.apache.solr.hadoop.ZooKeeperInspector.java

License:Apache License

/**
 * Returns config value given collection name Borrowed heavily from Solr's
 * ZKController./*from   w  ww  .  ja  v a 2 s .co  m*/
 */
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;
}