This is an automated email from the ASF dual-hosted git repository.

dsmiley pushed a commit to branch branch_9x
in repository https://gitbox.apache.org/repos/asf/solr.git

commit e732aa84dc519a2f8238ee5af78e11fce4bc8221
Author: David Smiley <dsmi...@salesforce.com>
AuthorDate: Tue Dec 10 10:57:40 2024 -0500

    SOLR-17561: Deprecations in ClusterState, DocCollection, Replica (#2898)
    
    Non-essential methods that will go away in Solr 10.  Might add additional 
methods later to address some conveniences these offer.
    
    (cherry picked from commit 2d3a8d9954a45c0eb1bbaa77b29f51ce314c1849)
---
 .../java/org/apache/solr/common/cloud/ClusterState.java    | 14 +++++++++++++-
 .../java/org/apache/solr/common/cloud/DocCollection.java   | 12 +++++++++++-
 .../src/java/org/apache/solr/common/cloud/Replica.java     |  1 +
 3 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/solr/solrj/src/java/org/apache/solr/common/cloud/ClusterState.java 
b/solr/solrj/src/java/org/apache/solr/common/cloud/ClusterState.java
index 20a22fe7261..34eff2a653b 100644
--- a/solr/solrj/src/java/org/apache/solr/common/cloud/ClusterState.java
+++ b/solr/solrj/src/java/org/apache/solr/common/cloud/ClusterState.java
@@ -96,6 +96,7 @@ public class ClusterState implements MapWriter {
    * @param collectionName the name of the modified (or deleted) collection
    * @param collection the collection object. A null value deletes the 
collection from the state
    * @return the updated cluster state which preserves the current live nodes
+   * @lucene.internal
    */
   public ClusterState copyWith(String collectionName, DocCollection 
collection) {
     LinkedHashMap<String, CollectionRef> collections = new 
LinkedHashMap<>(collectionStates);
@@ -223,6 +224,7 @@ public class ClusterState implements MapWriter {
     return null;
   }
 
+  @Deprecated
   public Map<String, List<Replica>> getReplicaNamesPerCollectionOnNode(final 
String nodeName) {
     Map<String, List<Replica>> replicaNamesPerCollectionOnNode = new 
HashMap<>();
     collectionStates.values().stream()
@@ -264,6 +266,7 @@ public class ClusterState implements MapWriter {
    *     {@link ClusterState}
    * @return the ClusterState
    */
+  @Deprecated
   public static ClusterState createFromJson(
       int version,
       byte[] bytes,
@@ -284,6 +287,7 @@ public class ClusterState implements MapWriter {
     return createFromJson(version, bytes, liveNodes, Instant.EPOCH, null);
   }
 
+  @Deprecated
   public static ClusterState createFromCollectionMap(
       int version,
       Map<String, Object> stateMap,
@@ -313,6 +317,9 @@ public class ClusterState implements MapWriter {
     return createFromCollectionMap(version, stateMap, liveNodes, 
Instant.EPOCH, null);
   }
 
+  /**
+   * @lucene.internal
+   */
   // TODO move to static DocCollection.loadFromMap
   public static DocCollection collectionFromObjects(
       String name,
@@ -385,7 +392,9 @@ public class ClusterState implements MapWriter {
     } else return liveNodes.equals(other.liveNodes);
   }
 
-  /** Internal API used only by ZkStateReader */
+  /**
+   * @lucene.internal used only by ZkStateReader
+   */
   void setLiveNodes(Set<String> liveNodes) {
     this.liveNodes = Set.copyOf(liveNodes);
   }
@@ -474,6 +483,9 @@ public class ClusterState implements MapWriter {
   private static volatile Function<JSONParser, ObjectBuilder> 
STR_INTERNER_OBJ_BUILDER =
       STANDARDOBJBUILDER;
 
+  /**
+   * @lucene.internal
+   */
   public static void setStrInternerParser(Function<JSONParser, ObjectBuilder> 
fun) {
     if (fun == null) return;
     STR_INTERNER_OBJ_BUILDER = fun;
diff --git 
a/solr/solrj/src/java/org/apache/solr/common/cloud/DocCollection.java 
b/solr/solrj/src/java/org/apache/solr/common/cloud/DocCollection.java
index 5c6db6b8da8..3f29088d2fc 100644
--- a/solr/solrj/src/java/org/apache/solr/common/cloud/DocCollection.java
+++ b/solr/solrj/src/java/org/apache/solr/common/cloud/DocCollection.java
@@ -236,6 +236,8 @@ public class DocCollection extends ZkNodeProps implements 
Iterable<Slice> {
    * that holds the same AtomicReference will see the same update
    *
    * <p>This does not create a new DocCollection.
+   *
+   * @lucene.internal
    */
   public final DocCollection setPerReplicaStates(PerReplicaStates 
newPerReplicaStates) {
     if (this.perReplicaStatesRef != null) {
@@ -264,11 +266,14 @@ public class DocCollection extends ZkNodeProps implements 
Iterable<Slice> {
     }
   }
 
+  /**
+   * @lucene.internal
+   */
   public static Object verifyProp(Map<String, Object> props, String propName) {
     return verifyProp(props, propName, null);
   }
 
-  public static Object verifyProp(Map<String, Object> props, String propName, 
Object def) {
+  private static Object verifyProp(Map<String, Object> props, String propName, 
Object def) {
     Object o = props.get(propName);
     if (o == null) return def;
     switch (propName) {
@@ -335,6 +340,7 @@ public class DocCollection extends ZkNodeProps implements 
Iterable<Slice> {
   }
 
   /** Return array of active slices for this collection (performance 
optimization). */
+  @Deprecated
   public Slice[] getActiveSlicesArr() {
     return activeSlicesArr;
   }
@@ -355,6 +361,7 @@ public class DocCollection extends ZkNodeProps implements 
Iterable<Slice> {
   }
 
   /** Get the list of all leaders hosted on the given node or 
<code>null</code> if none. */
+  @Deprecated
   public List<Replica> getLeaderReplicas(String nodeName) {
     return nodeNameLeaderReplicas.get(nodeName);
   }
@@ -467,6 +474,7 @@ public class DocCollection extends ZkNodeProps implements 
Iterable<Slice> {
     return slices.values().iterator();
   }
 
+  @Deprecated // low usage and builds an ArrayList (surprising)
   public List<Replica> getReplicas() {
     List<Replica> replicas = new ArrayList<>();
     for (Slice slice : this) {
@@ -479,6 +487,7 @@ public class DocCollection extends ZkNodeProps implements 
Iterable<Slice> {
    * @param predicate test against shardName vs. replica
    * @return the first replica that matches the predicate
    */
+  @Deprecated // just one test; move it
   public Replica getReplica(BiPredicate<String, Replica> predicate) {
     final Replica[] result = new Replica[1];
     forEachReplica(
@@ -491,6 +500,7 @@ public class DocCollection extends ZkNodeProps implements 
Iterable<Slice> {
     return result[0];
   }
 
+  @Deprecated // just tests, so move out or make package-protected
   public List<Replica> getReplicas(EnumSet<Replica.Type> s) {
     List<Replica> replicas = new ArrayList<>();
     for (Slice slice : this) {
diff --git a/solr/solrj/src/java/org/apache/solr/common/cloud/Replica.java 
b/solr/solrj/src/java/org/apache/solr/common/cloud/Replica.java
index e041e42f225..d09d5049947 100644
--- a/solr/solrj/src/java/org/apache/solr/common/cloud/Replica.java
+++ b/solr/solrj/src/java/org/apache/solr/common/cloud/Replica.java
@@ -304,6 +304,7 @@ public class Replica extends ZkNodeProps implements 
MapWriter {
     return state;
   }
 
+  @Deprecated
   public void setState(State state) {
     this.state = state;
     propMap.put(ReplicaStateProps.STATE, this.state.toString());

Reply via email to