-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
[SnapshotV2] Add snapshot size to status response for shallow V2 snapshots #15573
Open
ltaragi
wants to merge
4
commits into
opensearch-project:main
Choose a base branch
from
ltaragi:primary-store-size
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
4bdc5f2
Add primary store size to snapshot status result for shallow V2 snap…
ltaragi ececc75
Fix build
ltaragi 77ccc5d
Add snapshot_size_in_bytes field to XContent of SnapshotInfo
ltaragi cefa0bc
Add version change todos and fix potential breaking changes
ltaragi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -115,6 +115,8 @@ public class InternalClusterInfoService implements ClusterInfoService, ClusterSt | |
private volatile Map<String, FileCacheStats> nodeFileCacheStats; | ||
private volatile IndicesStatsSummary indicesStatsSummary; | ||
// null if this node is not currently the cluster-manager | ||
|
||
private volatile long primaryStoreSize; | ||
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. Looks like we already have |
||
private final AtomicReference<RefreshAndRescheduleRunnable> refreshAndRescheduleRunnable = new AtomicReference<>(); | ||
private volatile boolean enabled; | ||
private volatile TimeValue fetchTimeout; | ||
|
@@ -127,6 +129,7 @@ public InternalClusterInfoService(Settings settings, ClusterService clusterServi | |
this.mostAvailableSpaceUsages = Map.of(); | ||
this.nodeFileCacheStats = Map.of(); | ||
this.indicesStatsSummary = IndicesStatsSummary.EMPTY; | ||
this.primaryStoreSize = 0L; | ||
this.threadPool = threadPool; | ||
this.client = client; | ||
this.updateFrequency = INTERNAL_CLUSTER_INFO_UPDATE_INTERVAL_SETTING.get(settings); | ||
|
@@ -213,7 +216,8 @@ public ClusterInfo getClusterInfo() { | |
indicesStatsSummary.shardSizes, | ||
indicesStatsSummary.shardRoutingToDataPath, | ||
indicesStatsSummary.reservedSpace, | ||
nodeFileCacheStats | ||
nodeFileCacheStats, | ||
primaryStoreSize | ||
); | ||
} | ||
|
||
|
@@ -305,8 +309,13 @@ public void onResponse(IndicesStatsResponse indicesStatsResponse) { | |
final Map<String, Long> shardSizeByIdentifierBuilder = new HashMap<>(); | ||
final Map<ShardRouting, String> dataPathByShardRoutingBuilder = new HashMap<>(); | ||
final Map<ClusterInfo.NodeAndPath, ClusterInfo.ReservedSpace.Builder> reservedSpaceBuilders = new HashMap<>(); | ||
buildShardLevelInfo(logger, stats, shardSizeByIdentifierBuilder, dataPathByShardRoutingBuilder, reservedSpaceBuilders); | ||
|
||
primaryStoreSize = buildShardLevelInfo( | ||
logger, | ||
stats, | ||
shardSizeByIdentifierBuilder, | ||
dataPathByShardRoutingBuilder, | ||
reservedSpaceBuilders | ||
); | ||
final Map<ClusterInfo.NodeAndPath, ClusterInfo.ReservedSpace> rsrvdSpace = new HashMap<>(); | ||
reservedSpaceBuilders.forEach((nodeAndPath, builder) -> rsrvdSpace.put(nodeAndPath, builder.build())); | ||
|
||
|
@@ -366,13 +375,14 @@ public void addListener(Consumer<ClusterInfo> clusterInfoConsumer) { | |
listeners.add(clusterInfoConsumer); | ||
} | ||
|
||
static void buildShardLevelInfo( | ||
static long buildShardLevelInfo( | ||
Logger logger, | ||
ShardStats[] stats, | ||
final Map<String, Long> shardSizes, | ||
final Map<ShardRouting, String> newShardRoutingToDataPath, | ||
final Map<ClusterInfo.NodeAndPath, ClusterInfo.ReservedSpace.Builder> reservedSpaceByShard | ||
) { | ||
long currentPrimaryStoreSize = 0L; | ||
for (ShardStats s : stats) { | ||
final ShardRouting shardRouting = s.getShardRouting(); | ||
newShardRoutingToDataPath.put(shardRouting, s.getDataPath()); | ||
|
@@ -382,6 +392,9 @@ static void buildShardLevelInfo( | |
continue; | ||
} | ||
final long size = storeStats.sizeInBytes(); | ||
if (shardRouting.primary()) { | ||
currentPrimaryStoreSize += size; | ||
} | ||
final long reserved = storeStats.getReservedSize().getBytes(); | ||
|
||
final String shardIdentifier = ClusterInfo.shardIdentifierFromRouting(shardRouting); | ||
|
@@ -396,6 +409,7 @@ static void buildShardLevelInfo( | |
reservedSpaceBuilder.add(shardRouting.shardId(), reserved); | ||
} | ||
} | ||
return currentPrimaryStoreSize; | ||
} | ||
|
||
static void fillDiskUsagePerNode( | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
While checking this in 'main', please could you help add a TODO comment with the specific version this needs to be replaced with in the follow-up PR? Applicable for all places we have added 'Version.CURRENT'