-
Notifications
You must be signed in to change notification settings - Fork 817
Small code fixes to Placement Plugins #4213
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
Changes from all commits
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 |
|---|---|---|
|
|
@@ -93,7 +93,7 @@ public List<PlacementPlan> computePlacements( | |
| } | ||
|
|
||
| List<WeightedNode> nodesForRequest = | ||
| weightedNodes.stream().filter(request::isTargetingNode).collect(Collectors.toList()); | ||
| weightedNodes.stream().filter(request::isTargetingNode).toList(); | ||
|
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'm not sure if the read-only contract is different between these two options, but good to check. Same down below.
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. humm, I'm hoping no differences because tests don't fail and IntelliJ recommended it! Let's see what copilot says!
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. Claude looked at it and explained about the mutability thing... It's interesting that nothing in the class speaks to mutablity which feels like a trap. I mean, do I really need to think about mutability? It's like asking me to think about memory management!!! What are we? C code? |
||
|
|
||
| SolrCollection solrCollection = request.getCollection(); | ||
| // Now place all replicas of all shards on available nodes | ||
|
|
@@ -241,7 +241,7 @@ public BalancePlan computeBalancing( | |
| List<Replica> availableReplicasToMove = | ||
| highestWeight.getAllReplicasOnNode().stream() | ||
| .sorted(Comparator.comparing(Replica::getReplicaName)) | ||
| .collect(Collectors.toList()); | ||
| .toList(); | ||
| int combinedNodeWeights = highestWeight.calcWeight() + lowestWeight.calcWeight(); | ||
| for (Replica r : availableReplicasToMove) { | ||
| // Only continue if the replica can be removed from the old node and moved to the new node | ||
|
|
@@ -284,7 +284,7 @@ public BalancePlan computeBalancing( | |
| break; | ||
| } | ||
| } | ||
| // For now we do not have any way to see if there are out-of-date notes in the middle of the | ||
| // For now, we do not have any way to see if there are out-of-date nodes in the middle of the | ||
| // TreeSet. Therefore, we need to re-sort this list after every selection. In the future, we | ||
| // should find a way to re-sort the out-of-date nodes without having to sort all nodes. | ||
| traversedHighNodes.addAll(orderedNodes); | ||
|
|
@@ -442,12 +442,6 @@ public Set<String> getShardsOnNode(String collection) { | |
| return replicas.getOrDefault(collection, Collections.emptyMap()).keySet(); | ||
| } | ||
|
|
||
| public boolean hasShardOnNode(Shard shard) { | ||
| return replicas | ||
| .getOrDefault(shard.getCollection().getName(), Collections.emptyMap()) | ||
| .containsKey(shard.getShardName()); | ||
| } | ||
|
|
||
| public Set<Replica> getReplicasForShardOnNode(Shard shard) { | ||
| return Optional.ofNullable(replicas.get(shard.getCollection().getName())) | ||
| .map(m -> m.get(shard.getShardName())) | ||
|
|
@@ -775,15 +769,6 @@ public void add(WeightedNode node) { | |
| } | ||
| } | ||
|
|
||
| /** | ||
| * Get the number of nodes in the heap. | ||
| * | ||
| * @return number of nodes | ||
| */ | ||
| public int size() { | ||
| return size; | ||
| } | ||
|
|
||
| /** | ||
| * Check if the heap is empty. | ||
| * | ||
|
|
||
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.
I hope this is a clearer comment...