gpt4 book ai didi

org.apache.solr.common.cloud.ZkStateReader.getAliases()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-15 11:44:40 25 4
gpt4 key购买 nike

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

ZkStateReader.getAliases介绍

[英]Get an immutable copy of the present state of the aliases. References to this object should not be retained in any context where it will be important to know if aliases have changed.
[中]获取别名当前状态的不可变副本。对该对象的引用不应保留在任何上下文中,在这些上下文中,了解别名是否已更改很重要。

代码示例

代码示例来源:origin: BroadleafCommerce/BroadleafCommerce

protected void createAliasIfNotExist(CloudSolrClient client, String collectionName, String aliasName) {
  Aliases aliases = client.getZkStateReader().getAliases();
  Map<String, String> aliasCollectionMap = aliases.getCollectionAliasMap();
  if (!aliasCollectionMap.containsKey(aliasName)) {
    try {
      new CollectionAdminRequest.CreateAlias().setAliasName(aliasName)
          .setAliasedCollections(collectionName).process(client);
    } catch (SolrServerException e) {
      throw ExceptionHelper.refineException(e);
    } catch (IOException e) {
      throw ExceptionHelper.refineException(e);
    }
  }
}

代码示例来源:origin: BroadleafCommerce/BroadleafCommerce

try {
  primaryCloudClient.connect();
  Aliases aliases = primaryCloudClient.getZkStateReader().getAliases();
  Map<String, String> aliasCollectionMap = aliases.getCollectionAliasMap();
  if (aliasCollectionMap == null || !aliasCollectionMap.containsKey(primaryCloudClient.getDefaultCollection())

代码示例来源:origin: BroadleafCommerce/BroadleafCommerce

List<String> collectionNames = listResponse.get("collections") == null ? collectionNames = new ArrayList<>() : (List<String>) listResponse.get("collections");
Aliases aliases = primary.getZkStateReader().getAliases();
Map<String, String> aliasCollectionMap = aliases.getCollectionAliasMap();
aliases = primary.getZkStateReader().getAliases();
aliasCollectionMap = aliases.getCollectionAliasMap();

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

@Override
public List<String> resolveAlias(String alias) {
 return zkStateReader.getAliases().resolveAliases(alias); // if not an alias, returns itself
}

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

public static Slice[] getSlices(String collectionName, ZkStateReader zkStateReader, boolean checkAlias) throws IOException {
 ClusterState clusterState = zkStateReader.getClusterState();
 Map<String, DocCollection> collectionsMap = clusterState.getCollectionsMap();
 //TODO we should probably split collection by comma to query more than one
 //  which is something already supported in other parts of Solr
 // check for alias or collection
 List<String> collections = checkAlias
   ? zkStateReader.getAliases().resolveAliases(collectionName)  // if not an alias, returns collectionName
   : Collections.singletonList(collectionName);
 // Lookup all actives slices for these collections
 List<Slice> slices = collections.stream()
   .map(collectionsMap::get)
   .filter(Objects::nonNull)
   .flatMap(docCol -> Arrays.stream(docCol.getActiveSlicesArr()))
   .collect(Collectors.toList());
 if (!slices.isEmpty()) {
  return slices.toArray(new Slice[slices.size()]);
 }
 // Check collection case insensitive
 for(String collectionMapKey : collectionsMap.keySet()) {
  if(collectionMapKey.equalsIgnoreCase(collectionName)) {
   return collectionsMap.get(collectionMapKey).getActiveSlicesArr();
  }
 }
 throw new IOException("Slices not found for " + collectionName);
}

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

private Set<String> getCollectionNames(ClusterState clusterState,
                    String collection) {
 // Extract each comma separated collection name and store in a List.
 List<String> rawCollectionsList = StrUtils.splitSmart(collection, ",", true);
 Set<String> collectionNames = new HashSet<>();
 // validate collections
 for (String collectionName : rawCollectionsList) {
  if (!clusterState.getCollections().contains(collectionName)) {
   Aliases aliases = zkStateReader.getAliases();
   String alias = aliases.getCollectionAlias(collectionName);
   if (alias != null) {
    List<String> aliasList = StrUtils.splitSmart(alias, ",", true);
    collectionNames.addAll(aliasList);
    continue;
   }
    throw new SolrException(ErrorCode.BAD_REQUEST, "Collection not found: " + collectionName);
   }
  collectionNames.add(collectionName);
 }
 return collectionNames;
}

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

Aliases aliases = zkStateReader.getAliases();
if(aliases != null) {
 Map<String, String> collectionAliases = aliases.getCollectionAliasMap();

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com