Skip to content

armgit / solr

Public Imported from GitHub
0

Apache Solr open-source search software

SOLR-17561: Deprecations in ClusterState, DocCollection, Replica (#2898)

David Smiley2d3a8d9954a4
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 22e1005ed8b..960729a3906 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,
@@ -384,7 +391,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);
}
@@ -473,6 +482,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 1bb0cd42d41..cbfd5e7be92 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
@@ -232,6 +232,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) {
@@ -260,11 +262,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;
@@ -337,6 +342,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;
}
@@ -357,6 +363,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);
}
@@ -469,6 +476,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) {
@@ -481,6 +489,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(
@@ -493,6 +502,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 bd526c4fda2..d50dc1a1da8 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
@@ -329,6 +329,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());