pvcnt commented on code in PR #2039:
URL: https://github.com/apache/solr/pull/2039#discussion_r1422275525


##########
solr/solrj/src/java/org/apache/solr/common/cloud/ReplicaCount.java:
##########
@@ -18,31 +18,92 @@
 
 import java.util.Arrays;
 import java.util.EnumMap;
+import java.util.EnumSet;
 import java.util.Locale;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Set;
 import java.util.stream.Collectors;
 import org.apache.solr.common.SolrException;
+import org.apache.solr.common.params.CollectionAdminParams;
 
 /** Tracks the number of replicas per replica type. This class is mutable. */
 public final class ReplicaCount {
   private final EnumMap<Replica.Type, Integer> countByType;
 
-  public ReplicaCount(Integer nrtReplicas, Integer tlogReplicas, Integer 
pullReplicas) {
+  private ReplicaCount() {
     this.countByType = new EnumMap<>(Replica.Type.class);
-    put(Replica.Type.NRT, nrtReplicas);
-    put(Replica.Type.TLOG, tlogReplicas);
-    put(Replica.Type.PULL, pullReplicas);
   }
 
   public static ReplicaCount empty() {
-    return new ReplicaCount(null, null, null);
+    return new ReplicaCount();
   }
 
   public static ReplicaCount of(Replica.Type type, Integer count) {
-    ReplicaCount replicaCount = empty();
+    ReplicaCount replicaCount = new ReplicaCount();
     replicaCount.put(type, count);
     return replicaCount;
   }
 
+  public static ReplicaCount of(Integer nrtReplicas, Integer tlogReplicas, 
Integer pullReplicas) {
+    ReplicaCount replicaCount = new ReplicaCount();
+    replicaCount.put(Replica.Type.NRT, nrtReplicas);
+    replicaCount.put(Replica.Type.TLOG, tlogReplicas);
+    replicaCount.put(Replica.Type.PULL, pullReplicas);
+    return replicaCount;
+  }
+
+  public static ReplicaCount fromMessage(ZkNodeProps message) {
+    return fromMessage(message, null);
+  }
+
+  public static ReplicaCount fromMessage(ZkNodeProps message, DocCollection 
collection) {
+    return fromMessage(message, collection, null);
+  }
+
+  public static ReplicaCount fromMessage(

Review Comment:
   I forgot to answer this comment. I had a look at the suggestions and found 
out that:
   1. It would be supported but can not happen in practice. When a collection 
is passed to pull default values from, it will have a replication factor and 
number of replicas of each type. I don't see a use case where it would have 
only a replication factor and no number of replicas.
   2. This does not happen in fromMessage, but it handled by the caller (e.g., 
`CreateCollectionCmd#getNumReplicas`).



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@solr.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@solr.apache.org
For additional commands, e-mail: issues-h...@solr.apache.org

Reply via email to