org.apache.solr.common.cloud.ZkCoreNodeProps类的使用及代码示例

x33g5p2x  于2022-02-05 转载在 其他  
字(10.1k)|赞(0)|评价(0)|浏览(131)

本文整理了Java中org.apache.solr.common.cloud.ZkCoreNodeProps类的一些代码示例,展示了ZkCoreNodeProps类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZkCoreNodeProps类的具体详情如下:
包路径:org.apache.solr.common.cloud.ZkCoreNodeProps
类名称:ZkCoreNodeProps

ZkCoreNodeProps介绍

暂无

代码示例

代码示例来源:origin: org.apache.solr/solr-solrj

public String getLeaderUrl(String collection, String shard, int timeout) throws InterruptedException {
 ZkCoreNodeProps props = new ZkCoreNodeProps(getLeaderRetry(collection, shard, timeout));
 return props.getCoreUrl();
}

代码示例来源:origin: com.hynnet/solr-solrj

for (Slice slice : slices.values()) {
 for (ZkNodeProps nodeProps : slice.getReplicasMap().values()) {
  ZkCoreNodeProps coreNodeProps = new ZkCoreNodeProps(nodeProps);
  String node = coreNodeProps.getNodeName();
  if (!liveNodes.contains(coreNodeProps.getNodeName())
    || Replica.State.getState(coreNodeProps.getState()) != Replica.State.ACTIVE) continue;
  if (nodes.put(node, nodeProps) == null) {
   if (!sendToLeaders || coreNodeProps.isLeader()) {
    String url;
    if (reqParams.get(UpdateParams.COLLECTION) == null) {
     url = ZkCoreNodeProps.getCoreUrl(nodeProps.getStr(ZkStateReader.BASE_URL_PROP), collection);
    } else {
     url = coreNodeProps.getCoreUrl();
    String url;
    if (reqParams.get(UpdateParams.COLLECTION) == null) {
     url = ZkCoreNodeProps.getCoreUrl(nodeProps.getStr(ZkStateReader.BASE_URL_PROP), collection);
    } else {
     url = coreNodeProps.getCoreUrl();

代码示例来源:origin: org.apache.solr/solr-solrj

Replica leader = slice.getLeader();
if (leader != null) {
 ZkCoreNodeProps zkProps = new ZkCoreNodeProps(leader);
 String leaderUrl = zkProps.getBaseUrl() + "/" + zkProps.getCoreName();
 leaders.put(leaderUrl, slice.getName());
 String altLeaderUrl = zkProps.getBaseUrl() + "/" + collection;
 leaders.put(altLeaderUrl, slice.getName());

代码示例来源:origin: org.apache.solr/solr-solrj

List<ZkCoreNodeProps> nodes = new ArrayList<>(shardMap.size());
for (Entry<String,Replica> entry : shardMap.entrySet().stream().filter((e)->acceptReplicaType.contains(e.getValue().getType())).collect(Collectors.toList())) {
 ZkCoreNodeProps nodeProps = new ZkCoreNodeProps(entry.getValue());
 if (clusterState.liveNodesContain(nodeProps.getNodeName()) && !coreNodeName.equals(thisCoreNodeName)) {
  if (mustMatchStateFilter == null || mustMatchStateFilter == Replica.State.getState(nodeProps.getState())) {
   if (mustNotMatchStateFilter == null || mustNotMatchStateFilter != Replica.State.getState(nodeProps.getState())) {
    nodes.add(nodeProps);

代码示例来源:origin: org.apache.solr/solr-solrj

public String getCoreUrl() {
 return ZkCoreNodeProps.getCoreUrl(getStr(ZkStateReader.BASE_URL_PROP), getStr(ZkStateReader.CORE_NAME_PROP));
}
public String getBaseUrl(){

代码示例来源:origin: org.apache.solr/solr-test-framework

protected ZkCoreNodeProps getLeaderUrlFromZk(String collection, String slice) {
 ClusterState clusterState = getCommonCloudSolrClient().getZkStateReader().getClusterState();
 final DocCollection docCollection = clusterState.getCollectionOrNull(collection);
 if (docCollection != null && docCollection.getLeader(slice) != null) {
  return new ZkCoreNodeProps(docCollection.getLeader(slice));
 }
 throw new RuntimeException("Could not find leader:" + collection + " " + slice);
}

代码示例来源:origin: org.apache.solr/solr-solrj

for (Slice slice : slices.values()) {
 for (ZkNodeProps nodeProps : slice.getReplicasMap().values()) {
  ZkCoreNodeProps coreNodeProps = new ZkCoreNodeProps(nodeProps);
  String node = coreNodeProps.getNodeName();
  if (!liveNodes.contains(node) // Must be a live node to continue
    || Replica.State.getState(coreNodeProps.getState()) != Replica.State.ACTIVE) // Must be an ACTIVE replica to continue
   continue;
  if (seenNodes.add(node)) { // if we haven't yet collected a URL to this node...
   String url = ZkCoreNodeProps.getCoreUrl(nodeProps.getStr(ZkStateReader.BASE_URL_PROP), joinedInputCollections);
   if (sendToLeaders && coreNodeProps.isLeader()) {

代码示例来源:origin: com.hynnet/solr-solrj

Replica leader = slice.getLeader();
if (leader != null) {
 ZkCoreNodeProps zkProps = new ZkCoreNodeProps(leader);
 String leaderUrl = zkProps.getBaseUrl() + "/" + zkProps.getCoreName();
 leaders.put(leaderUrl, slice.getName());
 String altLeaderUrl = zkProps.getBaseUrl() + "/" + collection;
 leaders.put(altLeaderUrl, slice.getName());

代码示例来源:origin: com.hynnet/solr-solrj

List<ZkCoreNodeProps> nodes = new ArrayList<>(shardMap.size());
for (Entry<String,Replica> entry : shardMap.entrySet()) {
 ZkCoreNodeProps nodeProps = new ZkCoreNodeProps(entry.getValue());
 if (clusterState.liveNodesContain(nodeProps.getNodeName()) && !coreNodeName.equals(thisCoreNodeName)) {
  if (mustMatchStateFilter == null || mustMatchStateFilter == Replica.State.getState(nodeProps.getState())) {
   if (mustNotMatchStateFilter == null || mustNotMatchStateFilter != Replica.State.getState(nodeProps.getState())) {
    nodes.add(nodeProps);

代码示例来源:origin: org.apache.solr/solr-solrj

public String getCoreUrl() {
 return getCoreUrl(nodeProps.getStr(ZkStateReader.BASE_URL_PROP), nodeProps.getStr(ZkStateReader.CORE_NAME_PROP));
}

代码示例来源:origin: com.hynnet/solr-solrj

public String getLeaderUrl(String collection, String shard, int timeout)
  throws InterruptedException, KeeperException {
 ZkCoreNodeProps props = new ZkCoreNodeProps(getLeaderRetry(collection,
   shard, timeout));
 return props.getCoreUrl();
}

代码示例来源:origin: org.apache.solr/solr-test-framework

protected boolean reloadCollection(Replica replica, String testCollectionName) throws Exception {
 ZkCoreNodeProps coreProps = new ZkCoreNodeProps(replica);
 String coreName = coreProps.getCoreName();
 boolean reloadedOk = false;
 try (HttpSolrClient client = getHttpSolrClient(coreProps.getBaseUrl())) {
  CoreAdminResponse statusResp = CoreAdminRequest.getStatus(coreName, client);
  long leaderCoreStartTime = statusResp.getStartTime(coreName).getTime();

代码示例来源:origin: com.hynnet/solr-solrj

public String getCoreUrl() {
 return ZkCoreNodeProps.getCoreUrl(getStr(BASE_URL_PROP), getStr(CORE_NAME_PROP));
}

代码示例来源:origin: cloudera/search

public List<List<String>> extractShardUrls(String zkHost, String collection) {
 DocCollection docCollection = extractDocCollection(zkHost, collection);
 List<Slice> slices = getSortedSlices(docCollection.getSlices());
 List<List<String>> solrUrls = new ArrayList<List<String>>(slices.size());
 for (Slice slice : slices) {
  if (slice.getLeader() == null) {
   throw new IllegalArgumentException("Cannot find SolrCloud slice leader. " +
     "It looks like not all of your shards are registered in ZooKeeper yet");
  }
  Collection<Replica> replicas = slice.getReplicas();
  List<String> urls = new ArrayList<String>(replicas.size());
  for (Replica replica : replicas) {
   ZkCoreNodeProps props = new ZkCoreNodeProps(replica);
   urls.add(props.getCoreUrl());
  }
  solrUrls.add(urls);
 }
 return solrUrls;
}

代码示例来源:origin: org.apache.solr/solr-solrj

public static String getCoreUrl(ZkNodeProps nodeProps) {
 return getCoreUrl(nodeProps.getStr(ZkStateReader.BASE_URL_PROP), nodeProps.getStr(ZkStateReader.CORE_NAME_PROP));
}

代码示例来源:origin: com.cloudera.search/search-mr

public List<List<String>> extractShardUrls(String zkHost, String collection) {
 DocCollection docCollection = extractDocCollection(zkHost, collection);
 List<Slice> slices = getSortedSlices(docCollection.getSlices());
 List<List<String>> solrUrls = new ArrayList<List<String>>(slices.size());
 for (Slice slice : slices) {
  if (slice.getLeader() == null) {
   throw new IllegalArgumentException("Cannot find SolrCloud slice leader. " +
     "It looks like not all of your shards are registered in ZooKeeper yet");
  }
  Collection<Replica> replicas = slice.getReplicas();
  List<String> urls = new ArrayList<String>(replicas.size());
  for (Replica replica : replicas) {
   ZkCoreNodeProps props = new ZkCoreNodeProps(replica);
   if (replica.getStr(Slice.LEADER) == null) {
    urls.add(props.getCoreUrl()); // add followers at tail
   } else {
    urls.add(0, props.getCoreUrl()); // insert leader at head
   }
  }
  solrUrls.add(urls);
 }
 return solrUrls;
}

代码示例来源:origin: com.hynnet/solr-solrj

public String getCoreUrl() {
 return getCoreUrl(nodeProps.getStr(ZkStateReader.BASE_URL_PROP), nodeProps.getStr(ZkStateReader.CORE_NAME_PROP));
}

代码示例来源:origin: org.apache.solr/solr-test-framework

/**
 * Retrieve all requests recorded by this queue which were sent to given collection and shard
 *
 * @param zkStateReader  the {@link org.apache.solr.common.cloud.ZkStateReader} from which cluster state is read
 * @param collectionName the given collection name for which requests have to be extracted
 * @param shardId        the given shard name for which requests have to be extracted
 * @return a list of {@link org.apache.solr.handler.component.TrackingShardHandlerFactory.ShardRequestAndParams}
 * or empty list if none are found
 */
public List<ShardRequestAndParams> getShardRequests(ZkStateReader zkStateReader, String collectionName, String shardId) {
 DocCollection collection = zkStateReader.getClusterState().getCollection(collectionName);
 assert collection != null;
 Slice slice = collection.getSlice(shardId);
 assert slice != null;
 for (Map.Entry<String, List<ShardRequestAndParams>> entry : requests.entrySet()) {
  // multiple shard addresses may be present separated by '|'
  List<String> list = StrUtils.splitSmart(entry.getKey(), '|');
  for (Map.Entry<String, Replica> replica : slice.getReplicasMap().entrySet()) {
   String coreUrl = new ZkCoreNodeProps(replica.getValue()).getCoreUrl();
   if (list.contains(coreUrl)) {
    return new ArrayList<>(entry.getValue());
   }
  }
 }
 return Collections.emptyList();
}

代码示例来源:origin: com.hynnet/solr-solrj

public static String getCoreUrl(ZkNodeProps nodeProps) {
 return getCoreUrl(nodeProps.getStr(ZkStateReader.BASE_URL_PROP), nodeProps.getStr(ZkStateReader.CORE_NAME_PROP));
}

代码示例来源:origin: org.apache.solr/solr-solrj

protected List<String> getShardUrls() throws IOException {
 try {
  ZkStateReader zkStateReader = cloudSolrClient.getZkStateReader();
  Slice[] slices = CloudSolrStream.getSlices(this.collection, zkStateReader, false);
  ClusterState clusterState = zkStateReader.getClusterState();
  Set<String> liveNodes = clusterState.getLiveNodes();
  List<String> baseUrls = new ArrayList<>();
  for(Slice slice : slices) {
   Collection<Replica> replicas = slice.getReplicas();
   List<Replica> shuffler = new ArrayList<>();
   for(Replica replica : replicas) {
    if(replica.getState() == Replica.State.ACTIVE && liveNodes.contains(replica.getNodeName())) {
     shuffler.add(replica);
    }
   }
   Collections.shuffle(shuffler, new Random());
   Replica rep = shuffler.get(0);
   ZkCoreNodeProps zkProps = new ZkCoreNodeProps(rep);
   String url = zkProps.getCoreUrl();
   baseUrls.add(url);
  }
  return baseUrls;
 } catch (Exception e) {
  throw new IOException(e);
 }
}

相关文章