@Override public Collection<Slice> getSearchSlicesSingle(String shardKey, SolrParams params, DocCollection collection) { if (shardKey == null) { // search across whole collection // TODO: this may need modification in the future when shard splitting could cause an overlap return collection.getActiveSlices(); } // use the shardKey as an id for plain hashing Slice slice = getTargetSlice(shardKey, null, null, params, collection); return slice == null ? Collections.<Slice>emptyList() : Collections.singletonList(slice); } }
@Override public Collection<Slice> getSearchSlicesSingle(String shardKey, SolrParams params, DocCollection collection) { if (shardKey == null) { // search across whole collection // TODO: this may need modification in the future when shard splitting could cause an overlap return collection.getActiveSlices(); } String id = shardKey; if (shardKey.indexOf(SEPARATOR) < 0) { // shardKey is a simple id, so don't do a range return Collections.singletonList(hashToSlice(Hash.murmurhash3_x86_32(id, 0, id.length(), 0), collection)); } Range completeRange = new KeyParser(id).getRange(); List<Slice> targetSlices = new ArrayList<>(1); for (Slice slice : collection.getActiveSlicesArr()) { Range range = slice.getRange(); if (range != null && range.overlaps(completeRange)) { targetSlices.add(slice); } } return targetSlices; }
public Collection<Slice> getActiveSlices(String collection) { DocCollection coll = getCollectionOrNull(collection); if (coll == null) return null; return coll.getActiveSlices(); }
@Override public Collection<Slice> getSearchSlicesSingle(String shardKey, SolrParams params, DocCollection collection) { if (shardKey == null) { // search across whole collection // TODO: this may need modification in the future when shard splitting could cause an overlap return collection.getActiveSlices(); } // use the shardKey as an id for plain hashing Slice slice = getTargetSlice(shardKey, null, null, params, collection); return slice == null ? Collections.<Slice>emptyList() : Collections.singletonList(slice); } }
/** * Return a {@link CollectionStatePredicate} that returns true if a collection has the expected * number of active shards and active replicas */ public static CollectionStatePredicate activeClusterShape(int expectedShards, int expectedReplicas) { return (liveNodes, collectionState) -> { if (collectionState == null) return false; if (collectionState.getActiveSlices().size() != expectedShards) return false; if (compareActiveReplicaCountsForShards(expectedReplicas, liveNodes, collectionState)) return false; return true; }; }
/** * Get a (reproducibly) random shard from a {@link DocCollection} */ protected static Slice getRandomShard(DocCollection collection) { List<Slice> shards = new ArrayList<>(collection.getActiveSlices()); if (shards.size() == 0) fail("Couldn't get random shard for collection as it has no shards!\n" + collection.toString()); Collections.shuffle(shards, random()); return shards.get(0); }
@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 Slice hashToSlice(int hash, DocCollection collection) { for (Slice slice : collection.getActiveSlices()) { Range range = slice.getRange(); if (range != null && range.includes(hash)) return slice; } throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "No active slice servicing hash code " + Integer.toHexString(hash) + " in " + collection); }
@Override public Collection<Slice> getSearchSlicesSingle(String shardKey, SolrParams params, DocCollection collection) { if (shardKey == null) { // search across whole collection // TODO: this may need modification in the future when shard splitting could cause an overlap return collection.getActiveSlices(); } String id = shardKey; if (shardKey.indexOf(SEPARATOR) < 0) { // shardKey is a simple id, so don't do a range return Collections.singletonList(hashToSlice(Hash.murmurhash3_x86_32(id, 0, id.length(), 0), collection)); } Range completeRange = new KeyParser(id).getRange(); List<Slice> targetSlices = new ArrayList<>(1); for (Slice slice : collection.getActiveSlices()) { Range range = slice.getRange(); if (range != null && range.overlaps(completeRange)) { targetSlices.add(slice); } } return targetSlices; }
private Map<String,List<String>> buildUrlMap(DocCollection col) { Map<String, List<String>> urlMap = new HashMap<>(); Collection<Slice> slices = col.getActiveSlices(); Iterator<Slice> sliceIterator = slices.iterator(); while (sliceIterator.hasNext()) {
allCollections.add(col); Collection<Slice> slices = docs.getActiveSlices();
Collection<Slice> slices = cs.getCollection(testCollectionName).getActiveSlices(); assertTrue(slices.size() == shards); boolean allReplicasUp = false;