-
Notifications
You must be signed in to change notification settings - Fork 25.5k
Expose node heap size in cluster info #134436
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
d83e803
7464f8c
6c6f927
899ef80
44dcc78
bb25030
75f7cd0
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 |
---|---|---|
|
@@ -63,9 +63,11 @@ public class ClusterInfo implements ChunkedToXContent, Writeable { | |
final Map<String, EstimatedHeapUsage> estimatedHeapUsages; | ||
final Map<String, NodeUsageStatsForThreadPools> nodeUsageStatsForThreadPools; | ||
final Map<ShardId, Double> shardWriteLoads; | ||
// max heap size per node ID | ||
final Map<String, ByteSizeValue> maxHeapSizePerNode; | ||
|
||
protected ClusterInfo() { | ||
this(Map.of(), Map.of(), Map.of(), Map.of(), Map.of(), Map.of(), Map.of(), Map.of(), Map.of()); | ||
this(Map.of(), Map.of(), Map.of(), Map.of(), Map.of(), Map.of(), Map.of(), Map.of(), Map.of(), Map.of()); | ||
} | ||
|
||
/** | ||
|
@@ -80,6 +82,7 @@ protected ClusterInfo() { | |
* @param estimatedHeapUsages estimated heap usage broken down by node | ||
* @param nodeUsageStatsForThreadPools node-level usage stats (operational load) broken down by node | ||
* @see #shardIdentifierFromRouting | ||
* @param maxHeapSizePerNode node id to max heap size | ||
*/ | ||
public ClusterInfo( | ||
Map<String, DiskUsage> leastAvailableSpaceUsage, | ||
|
@@ -90,7 +93,8 @@ public ClusterInfo( | |
Map<NodeAndPath, ReservedSpace> reservedSpace, | ||
Map<String, EstimatedHeapUsage> estimatedHeapUsages, | ||
Map<String, NodeUsageStatsForThreadPools> nodeUsageStatsForThreadPools, | ||
Map<ShardId, Double> shardWriteLoads | ||
Map<ShardId, Double> shardWriteLoads, | ||
Map<String, ByteSizeValue> maxHeapSizePerNode | ||
) { | ||
this.leastAvailableSpaceUsage = Map.copyOf(leastAvailableSpaceUsage); | ||
this.mostAvailableSpaceUsage = Map.copyOf(mostAvailableSpaceUsage); | ||
|
@@ -101,6 +105,7 @@ public ClusterInfo( | |
this.estimatedHeapUsages = Map.copyOf(estimatedHeapUsages); | ||
this.nodeUsageStatsForThreadPools = Map.copyOf(nodeUsageStatsForThreadPools); | ||
this.shardWriteLoads = Map.copyOf(shardWriteLoads); | ||
this.maxHeapSizePerNode = Map.copyOf(maxHeapSizePerNode); | ||
} | ||
|
||
public ClusterInfo(StreamInput in) throws IOException { | ||
|
@@ -125,6 +130,11 @@ public ClusterInfo(StreamInput in) throws IOException { | |
} else { | ||
this.shardWriteLoads = Map.of(); | ||
} | ||
if (in.getTransportVersion().onOrAfter(TransportVersions.MAX_HEAP_SIZE_PER_NODE_IN_CLUSTER_INFO)) { | ||
this.maxHeapSizePerNode = in.readImmutableMap(ByteSizeValue::readFrom); | ||
} else { | ||
this.maxHeapSizePerNode = Map.of(); | ||
} | ||
} | ||
|
||
@Override | ||
|
@@ -144,6 +154,9 @@ public void writeTo(StreamOutput out) throws IOException { | |
if (out.getTransportVersion().supports(SHARD_WRITE_LOAD_IN_CLUSTER_INFO)) { | ||
out.writeMap(this.shardWriteLoads, StreamOutput::writeWriteable, StreamOutput::writeDouble); | ||
} | ||
if (out.getTransportVersion().onOrAfter(TransportVersions.MAX_HEAP_SIZE_PER_NODE_IN_CLUSTER_INFO)) { | ||
out.writeMap(this.maxHeapSizePerNode, StreamOutput::writeWriteable); | ||
} | ||
} | ||
|
||
/** | ||
|
@@ -224,8 +237,8 @@ public Iterator<? extends ToXContent> toXContentChunked(ToXContent.Params params | |
return builder.endObject(); // NodeAndPath | ||
}), | ||
endArray() // end "reserved_sizes" | ||
// NOTE: We don't serialize estimatedHeapUsages/nodeUsageStatsForThreadPools/shardWriteLoads at this stage, to avoid | ||
// committing to API payloads until the features are settled | ||
// NOTE: We don't serialize estimatedHeapUsages/nodeUsageStatsForThreadPools/shardWriteLoads/maxHeapSizePerNode at this stage, | ||
// to avoid committing to API payloads until the features are settled | ||
); | ||
} | ||
|
||
|
@@ -326,6 +339,10 @@ public ReservedSpace getReservedSpace(String nodeId, String dataPath) { | |
return result == null ? ReservedSpace.EMPTY : result; | ||
} | ||
|
||
public Map<String, ByteSizeValue> getMaxHeapSizePerNode() { | ||
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. Can we add a test similar to 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. added test in 44dcc78 |
||
return this.maxHeapSizePerNode; | ||
} | ||
|
||
/** | ||
* Method that incorporates the ShardId for the shard into a string that | ||
* includes a 'p' or 'r' depending on whether the shard is a primary. | ||
|
@@ -351,7 +368,8 @@ public boolean equals(Object o) { | |
&& reservedSpace.equals(that.reservedSpace) | ||
&& estimatedHeapUsages.equals(that.estimatedHeapUsages) | ||
&& nodeUsageStatsForThreadPools.equals(that.nodeUsageStatsForThreadPools) | ||
&& shardWriteLoads.equals(that.shardWriteLoads); | ||
&& shardWriteLoads.equals(that.shardWriteLoads) | ||
&& maxHeapSizePerNode.equals(that.maxHeapSizePerNode); | ||
} | ||
|
||
@Override | ||
|
@@ -365,7 +383,8 @@ public int hashCode() { | |
reservedSpace, | ||
estimatedHeapUsages, | ||
nodeUsageStatsForThreadPools, | ||
shardWriteLoads | ||
shardWriteLoads, | ||
maxHeapSizePerNode | ||
); | ||
} | ||
|
||
|
@@ -489,6 +508,7 @@ public static class Builder { | |
private Map<String, EstimatedHeapUsage> estimatedHeapUsages = Map.of(); | ||
private Map<String, NodeUsageStatsForThreadPools> nodeUsageStatsForThreadPools = Map.of(); | ||
private Map<ShardId, Double> shardWriteLoads = Map.of(); | ||
private Map<String, ByteSizeValue> maxHeapSizePerNode = Map.of(); | ||
|
||
public ClusterInfo build() { | ||
return new ClusterInfo( | ||
|
@@ -500,7 +520,8 @@ public ClusterInfo build() { | |
reservedSpace, | ||
estimatedHeapUsages, | ||
nodeUsageStatsForThreadPools, | ||
shardWriteLoads | ||
shardWriteLoads, | ||
maxHeapSizePerNode | ||
); | ||
} | ||
|
||
|
@@ -548,5 +569,10 @@ public Builder shardWriteLoads(Map<ShardId, Double> shardWriteLoads) { | |
this.shardWriteLoads = shardWriteLoads; | ||
return this; | ||
} | ||
|
||
public Builder maxHeapSizePerNode(Map<String, ByteSizeValue> maxHeapSizePerNode) { | ||
this.maxHeapSizePerNode = maxHeapSizePerNode; | ||
return this; | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -210,7 +210,7 @@ public Decision canForceAllocateDuringReplace(ShardRouting shardRouting, Routing | |
* | ||
* This method returns the corresponding initializing shard that would be allocated to this node. | ||
*/ | ||
private static ShardRouting initializingShard(ShardRouting shardRouting, String currentNodeId) { | ||
public static ShardRouting initializingShard(ShardRouting shardRouting, String currentNodeId) { | ||
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 is needed to do the same assertion that is done in this decider, but in the stateless decider. |
||
final ShardRouting initializingShard; | ||
if (shardRouting.unassigned()) { | ||
initializingShard = shardRouting.initialize(currentNodeId, null, ShardRouting.UNAVAILABLE_EXPECTED_SHARD_SIZE); | ||
|
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.
nit: not really a problem introduced here but it'd be nice to indicate what the opaque
String
keys are -- presumably persistent node IDs?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.
added comment in 44dcc78