/**Use this to make an exact copy of DocCollection with a new set of Slices and every other property as is * @param slices the new set of Slices * @return the resulting DocCollection */ public DocCollection copyWithSlices(Map<String, Slice> slices){ return new DocCollection(getName(), slices, propMap, router, znodeVersion,znode); }
/**Use this to make an exact copy of DocCollection with a new set of Slices and every other property as is * @param slices the new set of Slices * @return the resulting DocCollection */ public DocCollection copyWithSlices(Map<String, Slice> slices){ return new DocCollection(getName(), slices, propMap, router, znodeVersion,znode); }
@Override public void write(JSONWriter jsonWriter) { LinkedHashMap<String , DocCollection> map = new LinkedHashMap<>(); for (Entry<String, CollectionRef> e : collectionStates.entrySet()) { // using this class check to avoid fetching from ZK in case of lazily loaded collection if (e.getValue().getClass() == CollectionRef.class) { // check if it is a lazily loaded collection outside of clusterstate.json DocCollection coll = e.getValue().get(); if (coll.getStateFormat() == 1) { map.put(coll.getName(),coll); } } } jsonWriter.write(map); }
@Override public void write(JSONWriter jsonWriter) { LinkedHashMap<String , DocCollection> map = new LinkedHashMap<>(); for (Entry<String, CollectionRef> e : collectionStates.entrySet()) { // using this class check to avoid fetching from ZK in case of lazily loaded collection if (e.getValue().getClass() == CollectionRef.class) { // check if it is a lazily loaded collection outside of clusterstate.json DocCollection coll = e.getValue().get(); if (coll.getStateFormat() == 1) { map.put(coll.getName(),coll); } } } jsonWriter.write(map); }
@Override public Collection<Slice> getSearchSlicesSingle(String shardKey, SolrParams params, DocCollection collection) { if (shardKey == null) { return collection.getActiveSlices(); } // assume the shardKey is just a slice name Slice slice = collection.getSlice(shardKey); if (slice == null) { throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "implicit router can't find shard " + shardKey + " in collection " + collection.getName()); } return Collections.singleton(slice); }
@Override public Collection<Slice> getSearchSlicesSingle(String shardKey, SolrParams params, DocCollection collection) { if (shardKey == null) { return collection.getActiveSlices(); } // assume the shardKey is just a slice name Slice slice = collection.getSlice(shardKey); if (slice == null) { throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "implicit router can't find shard " + shardKey + " in collection " + collection.getName()); } return Collections.singleton(slice); }
protected void readReplicaDetails() throws IOException { ClusterStateProvider clusterStateProvider = getClusterStateProvider(); ClusterState clusterState = clusterStateProvider.getClusterState(); if (clusterState == null) { // zkStateReader still initializing return; } Map<String, ClusterState.CollectionRef> all = clusterStateProvider.getClusterState().getCollectionStates(); all.forEach((collName, ref) -> { DocCollection coll = ref.get(); if (coll == null) return; if (coll.getProperties().get(CollectionAdminParams.WITH_COLLECTION) != null) { withCollectionsMap.put(coll.getName(), (String) coll.getProperties().get(CollectionAdminParams.WITH_COLLECTION)); } coll.forEachReplica((shard, replica) -> { Map<String, Map<String, List<ReplicaInfo>>> nodeData = nodeVsCollectionVsShardVsReplicaInfo.computeIfAbsent(replica.getNodeName(), k -> new HashMap<>()); Map<String, List<ReplicaInfo>> collData = nodeData.computeIfAbsent(collName, k -> new HashMap<>()); List<ReplicaInfo> replicas = collData.computeIfAbsent(shard, k -> new ArrayList<>()); replicas.add(new ReplicaInfo(collName, shard, replica, new HashMap<>(replica.getProperties()))); }); }); }
private static void addMissingReplicas(ReplicaCount count, DocCollection coll, String shard, Replica.Type type, Suggestion.Ctx ctx) { int delta = count.delta(coll.getExpectedReplicaCount(type, 0), type); for (; ; ) { if (delta >= 0) break; SolrRequest suggestion = ctx.addSuggestion( ctx.session.getSuggester(ADDREPLICA) .hint(Hint.REPLICATYPE, type) .hint(Hint.COLL_SHARD, new Pair(coll.getName(), shard)), "repair"); if (suggestion == null) return; delta++; } }
stateVerParamBuilder.append(coll.getName()).append(":").append(collVer); ExpiringCachedDocCollection cacheEntry = collectionStateCache.get(ext.getName()); if (cacheEntry == null) continue; cacheEntry.maybeStale = true; collectionStateCache.remove(ext.getName()); wasCommError) { for (DocCollection ext : requestedCollections) { DocCollection latestStateFromZk = getDocCollection(ext.getName(), null); if (latestStateFromZk.getZNodeVersion() != ext.getZNodeVersion()) { collectionStateCache.put(ext.getName(), new ExpiringCachedDocCollection(latestStateFromZk));
stateVerParamBuilder.append(coll.getName()).append(":").append(collVer); collectionStateCache.remove(ext.getName()); wasCommError) { for (DocCollection ext : requestedCollections) { DocCollection latestStateFromZk = getDocCollection(zkStateReader.getClusterState(), ext.getName(),null); if (latestStateFromZk.getZNodeVersion() != ext.getZNodeVersion()) { collectionStateCache.put(ext.getName(), new ExpiringCachedDocCollection(latestStateFromZk));