cpoerschke commented on a change in pull request #325:
URL: https://github.com/apache/solr/pull/325#discussion_r720699450
##########
File path: solr/core/src/java/org/apache/solr/cloud/api/collections/Assign.java
##########
@@ -201,20 +201,20 @@ private static int defaultCounterValue(DocCollection
collection, boolean newColl
return defaultValue;
}
- public static String buildSolrCoreName(DistribStateManager stateManager,
DocCollection collection, String shard, Replica.Type type, boolean
newCollection) {
- Slice slice = collection.getSlice(shard);
+ public static String buildSolrCoreName(DistribStateManager stateManager,
String collectionName, DocCollection collection, String shard, Replica.Type
type, boolean newCollection) {
+
int defaultValue = defaultCounterValue(collection, newCollection, shard);
- int replicaNum = incAndGetId(stateManager, collection.getName(),
defaultValue);
- String coreName = buildSolrCoreName(collection.getName(), shard, type,
replicaNum);
- while (existCoreName(coreName, slice)) {
- replicaNum = incAndGetId(stateManager, collection.getName(),
defaultValue);
- coreName = buildSolrCoreName(collection.getName(), shard, type,
replicaNum);
+ int replicaNum = incAndGetId(stateManager, collectionName, defaultValue);
+ String coreName = buildSolrCoreName(collectionName, shard, type,
replicaNum);
+ while (collection != null && existCoreName(coreName,
collection.getSlice(shard))) {
+ replicaNum = incAndGetId(stateManager, collectionName, defaultValue);
+ coreName = buildSolrCoreName(collectionName, shard, type, replicaNum);
}
return coreName;
}
public static String buildSolrCoreName(DistribStateManager stateManager,
DocCollection collection, String shard, Replica.Type type) {
Review comment:
Whilst following the caller chain here I noticed that
https://github.com/apache/lucene-solr/blob/releases/lucene-solr/8.10.0/solr/core/src/java/org/apache/solr/cloud/api/collections/MoveReplicaCmd.java#L95-L97
(and other places) needlessly check null-ness after the
`ClusterState.getCollection(collection)` call. Out of scope for this pull
request that is though.
##########
File path: solr/core/src/java/org/apache/solr/cloud/api/collections/Assign.java
##########
@@ -180,7 +180,7 @@ private static int defaultCounterValue(DocCollection
collection, boolean newColl
if (newCollection) return 0;
int defaultValue;
- if (collection.getSlice(shard) != null &&
collection.getSlice(shard).getReplicas().isEmpty()) {
+ if (collection == null || collection.getSlice(shard) != null &&
collection.getSlice(shard).getReplicas().isEmpty()) {
Review comment:
```suggestion
if (collection == null || (collection.getSlice(shard) != null &&
collection.getSlice(shard).getReplicas().isEmpty())) {
```
or doing `if (newCollection || collection == null) return 0;` at line 180
above might be slightly easier to comprehend.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]