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