当前位置: 首页>>代码示例>>Java>>正文


Java ZkNodeProps.getStr方法代码示例

本文整理汇总了Java中org.apache.solr.common.cloud.ZkNodeProps.getStr方法的典型用法代码示例。如果您正苦于以下问题:Java ZkNodeProps.getStr方法的具体用法?Java ZkNodeProps.getStr怎么用?Java ZkNodeProps.getStr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.solr.common.cloud.ZkNodeProps的用法示例。


在下文中一共展示了ZkNodeProps.getStr方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: queryAndCompareReplicas

import org.apache.solr.common.cloud.ZkNodeProps; //导入方法依赖的package包/类
/**
 * Executes a query against each live and active replica of the specified shard 
 * and aserts that the results are identical.
 *
 * @see #queryAndCompare
 */
public QueryResponse queryAndCompareReplicas(SolrParams params, String shard) 
  throws Exception {

  ArrayList<SolrServer> shardClients = new ArrayList<>(7);

  updateMappingsFromZk(jettys, clients);
  ZkStateReader zkStateReader = cloudClient.getZkStateReader();
  List<CloudJettyRunner> solrJetties = shardToJetty.get(shard);
  assertNotNull("no jetties found for shard: " + shard, solrJetties);


  for (CloudJettyRunner cjetty : solrJetties) {
    ZkNodeProps props = cjetty.info;
    String nodeName = props.getStr(ZkStateReader.NODE_NAME_PROP);
    boolean active = props.getStr(ZkStateReader.STATE_PROP).equals(ZkStateReader.ACTIVE);
    boolean live = zkStateReader.getClusterState().liveNodesContain(nodeName);
    if (active && live) {
      shardClients.add(cjetty.client.solrClient);
    }
  }
  return queryAndCompare(params, shardClients);
}
 
开发者ID:europeana,项目名称:search,代码行数:29,代码来源:AbstractFullDistribZkTestBase.java

示例2: handleProp

import org.apache.solr.common.cloud.ZkNodeProps; //导入方法依赖的package包/类
private void handleProp(ZkNodeProps message)  {
  String name = message.getStr("name");
  String val = message.getStr("val");
  Map m =  reader.getClusterProps();
  if(val ==null) m.remove(name);
  else m.put(name,val);

  try {
    if(reader.getZkClient().exists(ZkStateReader.CLUSTER_PROPS,true))
      reader.getZkClient().setData(ZkStateReader.CLUSTER_PROPS,ZkStateReader.toJSON(m),true);
    else
      reader.getZkClient().create(ZkStateReader.CLUSTER_PROPS, ZkStateReader.toJSON(m),CreateMode.PERSISTENT, true);
    clusterProps = reader.getClusterProps();
  } catch (Exception e) {
    log.error("Unable to set cluster property", e);

  }
}
 
开发者ID:europeana,项目名称:search,代码行数:19,代码来源:Overseer.java

示例3: createReplica

import org.apache.solr.common.cloud.ZkNodeProps; //导入方法依赖的package包/类
private ClusterState createReplica(ClusterState clusterState, ZkNodeProps message) {
  log.info("createReplica() {} ", message);
  String coll = message.getStr(ZkStateReader.COLLECTION_PROP);
  if (!checkCollectionKeyExistence(message)) return clusterState;
  String slice = message.getStr(ZkStateReader.SHARD_ID_PROP);
  Slice sl = clusterState.getSlice(coll, slice);
  if(sl == null){
    log.error("Invalid Collection/Slice {}/{} ",coll,slice);
    return clusterState;
  }

  String coreNodeName = Assign.assignNode(coll, clusterState);
  Replica replica = new Replica(coreNodeName,
      makeMap(
      ZkStateReader.CORE_NAME_PROP, message.getStr(ZkStateReader.CORE_NAME_PROP),
      ZkStateReader.BASE_URL_PROP,message.getStr(ZkStateReader.BASE_URL_PROP),
      ZkStateReader.STATE_PROP,message.getStr(ZkStateReader.STATE_PROP)));
  sl.getReplicasMap().put(coreNodeName, replica);
  return clusterState;
}
 
开发者ID:europeana,项目名称:search,代码行数:21,代码来源:Overseer.java

示例4: getConfigName

import org.apache.solr.common.cloud.ZkNodeProps; //导入方法依赖的package包/类
private String getConfigName(String coll, ZkNodeProps message) throws KeeperException, InterruptedException {
  String configName = message.getStr(OverseerCollectionProcessor.COLL_CONF);
  
  if(configName == null) {
    // if there is only one conf, use that
    List<String> configNames = null;
    try {
      configNames = zkStateReader.getZkClient().getChildren(ZkController.CONFIGS_ZKNODE, null, true);
      if (configNames != null && configNames.size() == 1) {
        configName = configNames.get(0);
        // no config set named, but there is only 1 - use it
        log.info("Only one config set found in zk - using it:" + configName);
      }
    } catch (KeeperException.NoNodeException e) {

    }
  }
  return configName;
}
 
开发者ID:europeana,项目名称:search,代码行数:20,代码来源:OverseerCollectionProcessor.java

示例5: updateShardState

import org.apache.solr.common.cloud.ZkNodeProps; //导入方法依赖的package包/类
private ClusterState updateShardState(ClusterState clusterState, ZkNodeProps message) {
  String collection = message.getStr(ZkStateReader.COLLECTION_PROP);
  if (!checkCollectionKeyExistence(message)) return clusterState;
  log.info("Update shard state invoked for collection: " + collection + " with message: " + message);
  for (String key : message.keySet()) {
    if (ZkStateReader.COLLECTION_PROP.equals(key)) continue;
    if (QUEUE_OPERATION.equals(key)) continue;

    Slice slice = clusterState.getSlice(collection, key);
    if (slice == null)  {
      throw new RuntimeException("Overseer.updateShardState unknown collection: " + collection + " slice: " + key);
    }
    log.info("Update shard state " + key + " to " + message.getStr(key));
    Map<String, Object> props = slice.shallowCopy();
    if (Slice.RECOVERY.equals(props.get(Slice.STATE)) && Slice.ACTIVE.equals(message.getStr(key))) {
      props.remove(Slice.PARENT);
    }
    props.put(Slice.STATE, message.getStr(key));
    Slice newSlice = new Slice(slice.getName(), slice.getReplicasCopy(), props);
    clusterState = updateSlice(clusterState, collection, newSlice);
  }

  return clusterState;
}
 
开发者ID:europeana,项目名称:search,代码行数:25,代码来源:Overseer.java

示例6: removeRoutingRule

import org.apache.solr.common.cloud.ZkNodeProps; //导入方法依赖的package包/类
private ClusterState removeRoutingRule(ClusterState clusterState, ZkNodeProps message) {
  String collection = message.getStr(ZkStateReader.COLLECTION_PROP);
  if (!checkCollectionKeyExistence(message)) return clusterState;
  String shard = message.getStr(ZkStateReader.SHARD_ID_PROP);
  String routeKeyStr = message.getStr("routeKey");

  log.info("Overseer.removeRoutingRule invoked for collection: " + collection
      + " shard: " + shard + " routeKey: " + routeKeyStr);

  Slice slice = clusterState.getSlice(collection, shard);
  if (slice == null)  {
    log.warn("Unknown collection: " + collection + " shard: " + shard);
    return clusterState;
  }
  Map<String, RoutingRule> routingRules = slice.getRoutingRules();
  if (routingRules != null) {
    routingRules.remove(routeKeyStr); // no rules left
    Map<String, Object> props = slice.shallowCopy();
    props.put("routingRules", routingRules);
    Slice newSlice = new Slice(slice.getName(), slice.getReplicasCopy(), props);
    clusterState = updateSlice(clusterState, collection, newSlice);
  }

  return clusterState;
}
 
开发者ID:europeana,项目名称:search,代码行数:26,代码来源:Overseer.java

示例7: checkExclusivity

import org.apache.solr.common.cloud.ZkNodeProps; //导入方法依赖的package包/类
private boolean checkExclusivity(ZkNodeProps message, String id) throws KeeperException, InterruptedException {
  String collectionName = message.containsKey(COLLECTION_PROP) ?
      message.getStr(COLLECTION_PROP) : message.getStr("name");

  if(collectionName == null)
    return true;

  // CLUSTERSTATUS is always mutually exclusive
  if(CLUSTERSTATUS.isEqual(message.getStr(Overseer.QUEUE_OPERATION)))
    return true;

  if(collectionWip.contains(collectionName))
    return false;

  if(runningZKTasks.contains(id))
    return false;

  return true;
}
 
开发者ID:europeana,项目名称:search,代码行数:20,代码来源:OverseerCollectionProcessor.java

示例8: readConfigName

import org.apache.solr.common.cloud.ZkNodeProps; //导入方法依赖的package包/类
/**
 * Returns config value
 */
public String readConfigName(String collection) throws KeeperException,
    InterruptedException {

  String configName = null;

  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(CONFIGNAME_PROP);
  }
  
  if (configName != null && !zkClient.exists(CONFIGS_ZKNODE + "/" + configName, true)) {
    log.error("Specified config does not exist in ZooKeeper:" + configName);
    throw new ZooKeeperException(SolrException.ErrorCode.SERVER_ERROR,
        "Specified config does not exist in ZooKeeper:" + configName);
  }

  return configName;
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:28,代码来源:ZkController.java

示例9: processMessage

import org.apache.solr.common.cloud.ZkNodeProps; //导入方法依赖的package包/类
private ClusterState processMessage(ClusterState clusterState,
    final ZkNodeProps message, final String operation) {
  if ("state".equals(operation)) {
    clusterState = updateState(clusterState, message);
  } else if (DELETECORE.equals(operation)) {
    clusterState = removeCore(clusterState, message);
  } else if (ZkStateReader.LEADER_PROP.equals(operation)) {

    StringBuilder sb = new StringBuilder();
    String baseUrl = message.getStr(ZkStateReader.BASE_URL_PROP);
    String coreName = message.getStr(ZkStateReader.CORE_NAME_PROP);
    sb.append(baseUrl);
    if (baseUrl != null && !baseUrl.endsWith("/")) sb.append("/");
    sb.append(coreName == null ? "" : coreName);
    if (!(sb.substring(sb.length() - 1).equals("/"))) sb.append("/");
    clusterState = setShardLeader(clusterState,
        message.getStr(ZkStateReader.COLLECTION_PROP),
        message.getStr(ZkStateReader.SHARD_ID_PROP),
        sb.length() > 0 ? sb.toString() : null);

  } else {
    throw new RuntimeException("unknown operation:" + operation
        + " contents:" + message.getProperties());
  }
  return clusterState;
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:27,代码来源:Overseer.java

示例10: buildCollection

import org.apache.solr.common.cloud.ZkNodeProps; //导入方法依赖的package包/类
private ClusterState buildCollection(ClusterState clusterState, ZkNodeProps message) {
  String collection = message.getStr("name");
  log.info("building a new collection: " + collection);
  if(clusterState.hasCollection(collection) ){
    log.warn("Collection {} already exists. exit" ,collection);
    return clusterState;
  }

  ArrayList<String> shardNames = new ArrayList<>();

  if(ImplicitDocRouter.NAME.equals( message.getStr("router.name",DocRouter.DEFAULT_NAME))){
    getShardNames(shardNames,message.getStr("shards",DocRouter.DEFAULT_NAME));
  } else {
    int numShards = message.getInt(ZkStateReader.NUM_SHARDS_PROP, -1);
    if(numShards<1) throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,"numShards is a required parameter for 'compositeId' router");
    getShardNames(numShards, shardNames);
  }

  return createCollection(clusterState,collection,shardNames,message);
}
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:21,代码来源:Overseer.java

示例11: buildCollection

import org.apache.solr.common.cloud.ZkNodeProps; //导入方法依赖的package包/类
private ClusterState buildCollection(ClusterState clusterState, ZkNodeProps message) {
  String collection = message.getStr("name");
  log.info("building a new collection: " + collection);
  if(clusterState.hasCollection(collection) ){
    log.warn("Collection {} already exists. exit" ,collection);
    return clusterState;
  }

  ArrayList<String> shardNames = new ArrayList<String>();

  if(ImplicitDocRouter.NAME.equals( message.getStr("router.name",DocRouter.DEFAULT_NAME))){
    getShardNames(shardNames,message.getStr("shards",DocRouter.DEFAULT_NAME));
  } else {
    int numShards = message.getInt(ZkStateReader.NUM_SHARDS_PROP, -1);
    if(numShards<1) throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,"numShards is a required parameter for 'compositeId' router");
    getShardNames(numShards, shardNames);
  }

  return createCollection(clusterState,collection,shardNames,message);
}
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:21,代码来源:Overseer.java

示例12: collectionCmd

import org.apache.solr.common.cloud.ZkNodeProps; //导入方法依赖的package包/类
private void collectionCmd(ClusterState clusterState, ZkNodeProps message, ModifiableSolrParams params, NamedList results, String stateMatcher) {
  log.info("Executing Collection Cmd : " + params);
  String collectionName = message.getStr("name");
  
  DocCollection coll = clusterState.getCollection(collectionName);
  
  for (Map.Entry<String,Slice> entry : coll.getSlicesMap().entrySet()) {
    Slice slice = entry.getValue();
    sliceCmd(clusterState, params, stateMatcher, slice);
  }
  
  ShardResponse srsp;
  do {
    srsp = shardHandler.takeCompletedOrError();
    if (srsp != null) {
      processResponse(results, srsp);
    }
  } while (srsp != null);

}
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:21,代码来源:OverseerCollectionProcessor.java

示例13: handleCrateCollMessage

import org.apache.solr.common.cloud.ZkNodeProps; //导入方法依赖的package包/类
private void handleCrateCollMessage(byte[] bytes) {
  try {
    ZkNodeProps props = ZkNodeProps.load(bytes);
    if("createcollection".equals(props.getStr("operation"))){
      String collName = props.getStr("name") ;
      if(collName != null) collectionsSet.add(collName);
    }
  } catch (Exception e) { }
}
 
开发者ID:europeana,项目名称:search,代码行数:10,代码来源:OverseerCollectionProcessorTest.java

示例14: readConfigName

import org.apache.solr.common.cloud.ZkNodeProps; //导入方法依赖的package包/类
/**
 * 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;
}
 
开发者ID:europeana,项目名称:search,代码行数:43,代码来源:ZooKeeperDownloader.java

示例15: checkProps

import org.apache.solr.common.cloud.ZkNodeProps; //导入方法依赖的package包/类
private SolrCore checkProps(CoreContainer cores, String path,
    ZkNodeProps zkProps) {
  String corename;
  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;
}
 
开发者ID:europeana,项目名称:search,代码行数:11,代码来源:SolrDispatchFilter.java


注:本文中的org.apache.solr.common.cloud.ZkNodeProps.getStr方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。