Skip to content

Commit

Permalink
Deprecations in ClusterState/DocCollection/Replica
Browse files Browse the repository at this point in the history
  • Loading branch information
dsmiley committed Dec 9, 2024
1 parent 7547395 commit 69cb460
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ public ClusterState(Map<String, CollectionRef> collectionStates, Set<String> liv
* @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);
Expand Down Expand Up @@ -223,6 +224,7 @@ public String getShardId(String collectionName, String nodeName, String coreName
return null;
}

@Deprecated
public Map<String, List<Replica>> getReplicaNamesPerCollectionOnNode(final String nodeName) {
Map<String, List<Replica>> replicaNamesPerCollectionOnNode = new HashMap<>();
collectionStates.values().stream()
Expand Down Expand Up @@ -264,6 +266,7 @@ public String toString() {
* {@link ClusterState}
* @return the ClusterState
*/
@Deprecated
public static ClusterState createFromJson(
int version,
byte[] bytes,
Expand All @@ -284,6 +287,7 @@ public static ClusterState createFromJson(int version, byte[] bytes, Set<String>
return createFromJson(version, bytes, liveNodes, Instant.EPOCH, null);
}

@Deprecated
public static ClusterState createFromCollectionMap(
int version,
Map<String, Object> stateMap,
Expand Down Expand Up @@ -313,6 +317,9 @@ public static ClusterState createFromCollectionMap(
return createFromCollectionMap(version, stateMap, liveNodes, Instant.EPOCH, null);
}

/**
* @lucene.internal
*/
// TODO move to static DocCollection.loadFromMap
public static DocCollection collectionFromObjects(
String name,
Expand Down Expand Up @@ -384,7 +391,9 @@ public boolean equals(Object obj) {
} 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);
}
Expand Down Expand Up @@ -473,6 +482,9 @@ public int size() {
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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,8 @@ public static String getCollectionPathRoot(String coll) {
* 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) {
Expand Down Expand Up @@ -260,11 +262,14 @@ private void addNodeNameReplica(Replica replica) {
}
}

/**
* @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;
Expand Down Expand Up @@ -337,6 +342,7 @@ public Collection<Slice> getActiveSlices() {
}

/** Return array of active slices for this collection (performance optimization). */
@Deprecated
public Slice[] getActiveSlicesArr() {
return activeSlicesArr;
}
Expand All @@ -357,6 +363,7 @@ public List<Replica> getReplicas(String nodeName) {
}

/** 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);
}
Expand Down Expand Up @@ -469,6 +476,7 @@ public Iterator<Slice> iterator() {
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) {
Expand All @@ -481,6 +489,7 @@ public List<Replica> getReplicas() {
* @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(
Expand All @@ -493,6 +502,7 @@ public Replica getReplica(BiPredicate<String, Replica> predicate) {
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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,7 @@ public State getState() {
return state;
}

@Deprecated
public void setState(State state) {
this.state = state;
propMap.put(ReplicaStateProps.STATE, this.state.toString());
Expand Down

0 comments on commit 69cb460

Please sign in to comment.