Skip to content

Commit 62f60fa

Browse files
committed
Deprecation: DocCollection.getNumNrtReplicas etc.
Why: needless convenience methods, and the Object return type is unfortunate 9x: ported: int getNumReplicas (cherry picked from commit 65ab398)
1 parent 31dd2e1 commit 62f60fa

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

solr/solrj/src/java/org/apache/solr/common/cloud/DocCollection.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -547,6 +547,7 @@ public int hashCode() {
547547
* @return the number of replicas of type {@link org.apache.solr.common.cloud.Replica.Type#NRT}
548548
* this collection was created with
549549
*/
550+
@Deprecated
550551
public Integer getNumNrtReplicas() {
551552
return numNrtReplicas;
552553
}
@@ -555,6 +556,7 @@ public Integer getNumNrtReplicas() {
555556
* @return the number of replicas of type {@link org.apache.solr.common.cloud.Replica.Type#TLOG}
556557
* this collection was created with
557558
*/
559+
@Deprecated
558560
public Integer getNumTlogReplicas() {
559561
return numTlogReplicas;
560562
}
@@ -563,10 +565,27 @@ public Integer getNumTlogReplicas() {
563565
* @return the number of replicas of type {@link org.apache.solr.common.cloud.Replica.Type#PULL}
564566
* this collection was created with
565567
*/
568+
@Deprecated
566569
public Integer getNumPullReplicas() {
567570
return numPullReplicas;
568571
}
569572

573+
/**
574+
* @return the number of replicas of a given type this collection was created with
575+
*/
576+
public int getNumReplicas(Replica.Type type) {
577+
switch (type) {
578+
case NRT:
579+
return numNrtReplicas == null ? 0 : numNrtReplicas;
580+
case TLOG:
581+
return numTlogReplicas == null ? 0 : numTlogReplicas;
582+
case PULL:
583+
return numPullReplicas == null ? 0 : numPullReplicas;
584+
default:
585+
throw new AssertionError("Unknown replica type: " + type);
586+
}
587+
}
588+
570589
public boolean isPerReplicaState() {
571590
return Boolean.TRUE.equals(perReplicaState);
572591
}

0 commit comments

Comments
 (0)