-
Notifications
You must be signed in to change notification settings - Fork 25k
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
Small cleanups to Allocation Performance #89378
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 |
---|---|---|
|
@@ -26,7 +26,6 @@ | |
import org.elasticsearch.snapshots.RestoreService.RestoreInProgressUpdater; | ||
import org.elasticsearch.snapshots.SnapshotShardSizeInfo; | ||
|
||
import java.util.Collections; | ||
import java.util.HashMap; | ||
import java.util.HashSet; | ||
import java.util.Map; | ||
|
@@ -73,6 +72,11 @@ public class RoutingAllocation { | |
|
||
private final Map<String, SingleNodeShutdownMetadata> nodeReplacementTargets; | ||
|
||
private final Map<String, SingleNodeShutdownMetadata> nodeShutdowns; | ||
|
||
@Nullable | ||
private final DesiredNodes desiredNodes; | ||
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. Do we need above to make it inline? 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. This isn't really about inlining. This is just faster outright because we don't have to lookup from the customs map for every shard. |
||
|
||
public RoutingAllocation( | ||
AllocationDeciders deciders, | ||
ClusterState clusterState, | ||
|
@@ -106,13 +110,15 @@ public RoutingAllocation( | |
this.clusterInfo = clusterInfo; | ||
this.shardSizeInfo = shardSizeInfo; | ||
this.currentNanoTime = currentNanoTime; | ||
this.nodeShutdowns = clusterState.metadata().nodeShutdowns(); | ||
Map<String, SingleNodeShutdownMetadata> targetNameToShutdown = new HashMap<>(); | ||
for (SingleNodeShutdownMetadata shutdown : clusterState.metadata().nodeShutdowns().values()) { | ||
for (SingleNodeShutdownMetadata shutdown : nodeShutdowns.values()) { | ||
if (shutdown.getType() == SingleNodeShutdownMetadata.Type.REPLACE) { | ||
targetNameToShutdown.put(shutdown.getTargetNodeName(), shutdown); | ||
} | ||
} | ||
this.nodeReplacementTargets = Collections.unmodifiableMap(targetNameToShutdown); | ||
this.nodeReplacementTargets = Map.copyOf(targetNameToShutdown); | ||
this.desiredNodes = DesiredNodes.latestFromClusterState(clusterState); | ||
} | ||
|
||
/** returns the nano time captured at the beginning of the allocation. used to make sure all time based decisions are aligned */ | ||
|
@@ -173,14 +179,14 @@ public SnapshotShardSizeInfo snapshotShardSizeInfo() { | |
|
||
@Nullable | ||
public DesiredNodes desiredNodes() { | ||
return DesiredNodes.latestFromClusterState(clusterState); | ||
return desiredNodes; | ||
} | ||
|
||
/** | ||
* Returns the map of node id to shutdown metadata currently in the cluster | ||
*/ | ||
public Map<String, SingleNodeShutdownMetadata> nodeShutdowns() { | ||
return metadata().nodeShutdowns(); | ||
return nodeShutdowns; | ||
} | ||
|
||
/** | ||
|
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.
This is way simpler 👍