/** * Gets the list of replicas that have a type present in s */ public List<Replica> getReplicas(EnumSet<Replica.Type> s) { return this.getReplicas(r->s.contains(r.getType())); }
public ReplicaInfo(String coll, String shard, Replica r, Map<String, Object> vals) { this.name = r.getName(); this.core = r.getCoreName(); this.collection = coll; this.shard = shard; this.type = r.getType(); boolean maybeLeader = r.getBool(LEADER_PROP, false); if (vals != null) { this.variables.putAll(vals); maybeLeader = "true".equals(String.valueOf(vals.getOrDefault(LEADER_PROP, maybeLeader))); } this.isLeader = maybeLeader; this.node = r.getNodeName(); }
private static void logCollectionStateSummary(String collectionName, ZkStateReader zkStateReader) { Pattern portPattern = Pattern.compile(".*:([0-9]*).*"); DocCollection docCollection = zkStateReader.getClusterState().getCollection(collectionName); if (docCollection == null) { monkeyLog("Could not find collection {}", collectionName); } StringBuilder builder = new StringBuilder(); builder.append("Collection status: {"); for (Slice slice:docCollection.getSlices()) { builder.append(slice.getName() + ": {"); for (Replica replica:slice.getReplicas()) { log.info(replica.toString()); java.util.regex.Matcher m = portPattern.matcher(replica.getBaseUrl()); m.find(); String jettyPort = m.group(1); builder.append(String.format(Locale.ROOT, "%s(%s): {state: %s, type: %s, leader: %s, Live: %s}, ", replica.getName(), jettyPort, replica.getState(), replica.getType(), (replica.get("leader")!= null), zkStateReader.getClusterState().liveNodesContain(replica.getNodeName()))); } if (slice.getReplicas().size() > 0) { builder.setLength(builder.length() - 2); } builder.append("}, "); } if (docCollection.getSlices().size() > 0) { builder.setLength(builder.length() - 2); } builder.append("}"); monkeyLog(builder.toString()); }
for (Entry<String,Replica> entry : shardMap.entrySet().stream().filter((e)->acceptReplicaType.contains(e.getValue().getType())).collect(Collectors.toList())) { ZkCoreNodeProps nodeProps = new ZkCoreNodeProps(entry.getValue());
for (Replica replica : slice.getReplicas( replica -> replica.isActive(getClusterStateProvider().getLiveNodes()) && replica.getType() == Replica.Type.NRT)) { leader = replica; break;
private static void addMissingReplicas(SolrCloudManager cloudManager, Suggestion.Ctx ctx) throws IOException { cloudManager.getClusterStateProvider().getClusterState().forEachCollection(coll -> coll.forEach(slice -> { ReplicaCount replicaCount = new ReplicaCount(); slice.forEach(replica -> { if (replica.getState() == Replica.State.ACTIVE || replica.getState() == Replica.State.RECOVERING) { replicaCount.increment(replica.getType()); } }); addMissingReplicas(replicaCount, coll, slice.getName(), Replica.Type.NRT, ctx); addMissingReplicas(replicaCount, coll, slice.getName(), Replica.Type.PULL, ctx); addMissingReplicas(replicaCount, coll, slice.getName(), Replica.Type.TLOG, ctx); } )); }