public Map<String, Slice> getSlicesMap(String collection) { DocCollection coll = getCollectionOrNull(collection); if (coll == null) return null; return coll.getSlicesMap(); }
private String getRandomSlice() { Map<String,Slice> slices = zkStateReader.getClusterState().getCollection(collection).getSlicesMap(); List<String> sliceKeyList = new ArrayList<>(slices.size()); sliceKeyList.addAll(slices.keySet()); String sliceName = sliceKeyList.get(chaosRandom.nextInt(sliceKeyList.size())); return sliceName; }
throw new IllegalArgumentException("docCollection must not be null"); if (docCollection.getSlicesMap().size() != shards) { throw new IllegalArgumentException("Incompatible shards: + " + shards + " for docCollection: " + docCollection);
throw new IllegalArgumentException("docCollection must not be null"); if (docCollection.getSlicesMap().size() != shards) { throw new IllegalArgumentException("Incompatible shards: + " + shards + " for docCollection: " + docCollection);
public static String getUrlFromZk(ClusterState clusterState, String collection) { Map<String,Slice> slices = clusterState.getCollection(collection).getSlicesMap(); if (slices == null) { throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "Could not find collection:" + collection); } for (Map.Entry<String,Slice> entry : slices.entrySet()) { Slice slice = entry.getValue(); Map<String,Replica> shards = slice.getReplicasMap(); Set<Map.Entry<String,Replica>> shardEntries = shards.entrySet(); for (Map.Entry<String,Replica> shardEntry : shardEntries) { final ZkNodeProps node = shardEntry.getValue(); if (clusterState.liveNodesContain(node.getStr(ZkStateReader.NODE_NAME_PROP))) { return ZkCoreNodeProps.getCoreUrl(node.getStr(ZkStateReader.BASE_URL_PROP), collection); //new ZkCoreNodeProps(node).getCoreUrl(); } } } throw new RuntimeException("Could not find a live node for collection:" + collection); }
if (docCollection == null || docCollection.getSlicesMap() == null) { throw new ZooKeeperException(ErrorCode.BAD_REQUEST, "Could not find collection in zk: " + collection); Map<String,Slice> slices = docCollection.getSlicesMap(); Slice replicas = slices.get(shardId); if (replicas == null) {
zkStateReader.forceUpdateCollection(collection); final ClusterState clusterState = zkStateReader.getClusterState(); final Map<String, Slice> slices = clusterState.getCollection(collection).getSlicesMap(); Preconditions.checkNotNull(slices, "Could not find collection:" + collection);
Map<String,Slice> slices = clusterState.getCollection(collectionName).getSlicesMap();
final DocCollection docCollection = clusterState.getCollectionOrNull(collection); if (docCollection == null) throw new IllegalStateException("Could not find collection:" + collection); Map<String,Slice> slices = docCollection.getSlicesMap(); if (slices == null) throw new IllegalStateException("Could not find collection:" + collection); for (Map.Entry<String,Slice> entry : slices.entrySet()) {
final DocCollection docCollection = clusterState.getCollectionOrNull(collection); assertNotNull("Could not find collection:" + collection, docCollection); Map<String,Slice> slices = docCollection.getSlicesMap(); assertNotNull("Could not find collection:" + collection, slices); for (Map.Entry<String,Slice> entry : slices.entrySet()) {
protected static void assertAllActive(String collection, ZkStateReader zkStateReader) throws KeeperException, InterruptedException { zkStateReader.forceUpdateCollection(collection); ClusterState clusterState = zkStateReader.getClusterState(); final DocCollection docCollection = clusterState.getCollectionOrNull(collection); if (docCollection == null || docCollection.getSlices() == null) { throw new IllegalArgumentException("Cannot find collection:" + collection); } Map<String,Slice> slices = docCollection.getSlicesMap(); for (Map.Entry<String,Slice> entry : slices.entrySet()) { Slice slice = entry.getValue(); if (slice.getState() != Slice.State.ACTIVE) { fail("Not all shards are ACTIVE - found a shard " + slice.getName() + " that is: " + slice.getState()); } Map<String,Replica> shards = slice.getReplicasMap(); for (Map.Entry<String,Replica> shard : shards.entrySet()) { Replica replica = shard.getValue(); if (replica.getState() != Replica.State.ACTIVE) { fail("Not all replicas are ACTIVE - found a replica " + replica.getName() + " that is: " + replica.getState()); } } } }
clusterState = zk.getClusterState(); final DocCollection docCollection = clusterState.getCollectionOrNull(DEFAULT_COLLECTION); slices = (docCollection != null) ? docCollection.getSlicesMap() : null;