-
Notifications
You must be signed in to change notification settings - Fork 857
SOLR-18382: remove DocCollection.getReplicas(), migrate 60 call sites #4760
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
7f8a46f
acdd050
91fdcf5
803ed76
a133f29
02818cb
0b39c99
5c2fc0c
ffb38a3
a71a0ef
827b9d7
ed22c64
293d6ca
afa2b44
64a7341
aee88ea
d1d242c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| # See https://github.com/apache/solr/blob/main/dev-docs/changelog.adoc | ||
| title: Remove the deprecated DocCollection.getReplicas() method, which allocated a new list on every call. DocCollection is Iterable<Slice>, so iterate its slices and call Slice.getReplicas(), or use getSlices().stream().flatMap(slice -> slice.getReplicas().stream()). | ||
| type: removed | ||
| authors: | ||
| - name: Serhiy Bzhezytskyy | ||
| links: | ||
| - name: SOLR-18382 | ||
| url: https://issues.apache.org/jira/browse/SOLR-18382 | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -73,15 +73,15 @@ public void testAddMultipleReplicas() throws Exception { | |
|
|
||
| DocCollection docCollection = cloudClient.getClusterState().getCollectionOrNull(collection); | ||
| assertNotNull(docCollection); | ||
| assertEquals(4, docCollection.getReplicas().size()); | ||
| assertEquals(4, docCollection.replicaStream().count()); | ||
| assertEquals(2, getReplicas(docCollection, EnumSet.of(Replica.Type.NRT)).size()); | ||
| assertEquals(1, getReplicas(docCollection, EnumSet.of(Replica.Type.TLOG)).size()); | ||
| assertEquals(1, getReplicas(docCollection, EnumSet.of(Replica.Type.PULL)).size()); | ||
|
|
||
| docCollection = cloudClient.getClusterState().getCollectionOrNull(collection); | ||
| assertNotNull(docCollection); | ||
| // sanity check that everything is as before | ||
| assertEquals(4, docCollection.getReplicas().size()); | ||
| assertEquals(4, docCollection.replicaStream().count()); | ||
| assertEquals(2, getReplicas(docCollection, EnumSet.of(Replica.Type.NRT)).size()); | ||
| assertEquals(1, getReplicas(docCollection, EnumSet.of(Replica.Type.TLOG)).size()); | ||
| assertEquals(1, getReplicas(docCollection, EnumSet.of(Replica.Type.PULL)).size()); | ||
|
|
@@ -106,7 +106,7 @@ public void testAddMultipleReplicas() throws Exception { | |
| docCollection = cloudClient.getClusterState().getCollectionOrNull(collection); | ||
| assertNotNull(docCollection); | ||
| // sanity check that everything is as before | ||
| assertEquals(9, docCollection.getReplicas().size()); | ||
| assertEquals(9, docCollection.replicaStream().count()); | ||
| assertEquals(5, getReplicas(docCollection, EnumSet.of(Replica.Type.NRT)).size()); | ||
| assertEquals(2, getReplicas(docCollection, EnumSet.of(Replica.Type.TLOG)).size()); | ||
| assertEquals(2, getReplicas(docCollection, EnumSet.of(Replica.Type.PULL)).size()); | ||
|
|
@@ -211,7 +211,13 @@ public void testAddReplicaWithUserDefinedProperties() throws Exception { | |
| // Verify that the new core was created with user-defined properties coming from the request | ||
| // and inherited from the collection (the former taking precedence over the latter). | ||
| Replica replica = | ||
| cloudClient.getClusterState().getCollection(collectionName).getReplicas().get(1); | ||
| cloudClient | ||
| .getClusterState() | ||
| .getCollection(collectionName) | ||
| .replicaStream() | ||
| .skip(1) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We know we want to skip 1?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes -- AI-assisted (Claude Sonnet 5) |
||
| .findFirst() | ||
| .orElseThrow(); | ||
| CoreDescriptor coreDescriptor = | ||
| cluster | ||
| .getReplicaJetty(replica) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -285,39 +285,41 @@ private Map<String, ReplicaData> getTestDataForAllReplicas() | |
| DocCollection collectionState = | ||
| cluster.getSolrClient().getClusterState().getCollection(COLLECTION); | ||
|
|
||
| for (Replica replica : collectionState.getReplicas()) { | ||
|
|
||
| String coreName = replica.getCoreName(); | ||
| try (SolrClient client = getHttpSolrClient(replica)) { | ||
|
|
||
| ModifiableSolrParams params = new ModifiableSolrParams(); | ||
| params.set("command", "indexversion"); | ||
| params.set("_trace", "getIndexVersion"); | ||
| QueryRequest req = setAuthIfNeeded(new QueryRequest(ReplicationHandler.PATH, params)); | ||
|
|
||
| NamedList<Object> res = client.request(req); | ||
| assertNotNull("null response from server: " + coreName, res); | ||
|
|
||
| Object version = res.get("indexversion"); | ||
| assertNotNull("null version from server: " + coreName, version); | ||
| assertTrue("version isn't a long: " + coreName, version instanceof Long); | ||
|
|
||
| long numDocs = | ||
| setAuthIfNeeded( | ||
| new QueryRequest( | ||
| params( | ||
| "q", "*:*", | ||
| "distrib", "false", | ||
| "rows", "0", | ||
| "_trace", "counting_docs"))) | ||
| .process(client) | ||
| .getResults() | ||
| .getNumFound(); | ||
|
|
||
| final ReplicaData data = | ||
| new ReplicaData(replica.getShard(), coreName, (Long) version, numDocs); | ||
| log.info("{}", data); | ||
| results.put(coreName, data); | ||
| for (Slice slice : collectionState) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder if using a more sonsistent variable name like
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done as a separate commit -- renamed the 4 outlier AI-assisted (Claude Sonnet 5) |
||
| for (Replica replica : slice.getReplicas()) { | ||
|
|
||
| String coreName = replica.getCoreName(); | ||
| try (SolrClient client = getHttpSolrClient(replica)) { | ||
|
|
||
| ModifiableSolrParams params = new ModifiableSolrParams(); | ||
| params.set("command", "indexversion"); | ||
| params.set("_trace", "getIndexVersion"); | ||
| QueryRequest req = setAuthIfNeeded(new QueryRequest(ReplicationHandler.PATH, params)); | ||
|
|
||
| NamedList<Object> res = client.request(req); | ||
| assertNotNull("null response from server: " + coreName, res); | ||
|
|
||
| Object version = res.get("indexversion"); | ||
| assertNotNull("null version from server: " + coreName, version); | ||
| assertTrue("version isn't a long: " + coreName, version instanceof Long); | ||
|
|
||
| long numDocs = | ||
| setAuthIfNeeded( | ||
| new QueryRequest( | ||
| params( | ||
| "q", "*:*", | ||
| "distrib", "false", | ||
| "rows", "0", | ||
| "_trace", "counting_docs"))) | ||
| .process(client) | ||
| .getResults() | ||
| .getNumFound(); | ||
|
|
||
| final ReplicaData data = | ||
| new ReplicaData(replica.getShard(), coreName, (Long) version, numDocs); | ||
| log.info("{}", data); | ||
| results.put(coreName, data); | ||
| } | ||
| } | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's be brief on internal matters where even a changelog is debatable.
As I read this... gosh, we're wasting time with such a changelog. That's the thing -- ask yourself, will a user of Solr care? Honestly, no.