-
Notifications
You must be signed in to change notification settings - Fork 2.3k
FS stats for warm nodes based on addressable space #18767
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
Merged
Merged
Changes from 2 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
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 hidden or 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 hidden or 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 hidden or 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
57 changes: 57 additions & 0 deletions
57
server/src/main/java/org/opensearch/monitor/fs/FsServiceProvider.java
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| /* | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| * | ||
| * The OpenSearch Contributors require contributions made to | ||
| * this file be licensed under the Apache-2.0 license or a | ||
| * compatible open source license. | ||
| */ | ||
|
|
||
| package org.opensearch.monitor.fs; | ||
|
|
||
| import org.opensearch.cluster.node.DiscoveryNode; | ||
| import org.opensearch.common.settings.ClusterSettings; | ||
| import org.opensearch.common.settings.Settings; | ||
| import org.opensearch.env.NodeEnvironment; | ||
| import org.opensearch.index.store.remote.filecache.FileCache; | ||
| import org.opensearch.index.store.remote.filecache.FileCacheSettings; | ||
| import org.opensearch.indices.IndicesService; | ||
|
|
||
| /** | ||
| * Factory for creating appropriate FsService implementations based on node type. | ||
| * | ||
| * @opensearch.internal | ||
| */ | ||
| public class FsServiceProvider { | ||
|
|
||
| private final Settings settings; | ||
| private final NodeEnvironment nodeEnvironment; | ||
| private final FileCache fileCache; | ||
| private final FileCacheSettings fileCacheSettings; | ||
| private final IndicesService indicesService; | ||
|
|
||
| public FsServiceProvider( | ||
| Settings settings, | ||
| NodeEnvironment nodeEnvironment, | ||
| FileCache fileCache, | ||
| ClusterSettings clusterSettings, | ||
| IndicesService indicesService | ||
| ) { | ||
| this.settings = settings; | ||
| this.nodeEnvironment = nodeEnvironment; | ||
| this.fileCache = fileCache; | ||
| this.fileCacheSettings = new FileCacheSettings(settings, clusterSettings); | ||
| this.indicesService = indicesService; | ||
| } | ||
|
|
||
| /** | ||
| * Creates the appropriate FsService implementation based on node type. | ||
| * | ||
| * @return FsService instance | ||
| */ | ||
| public FsService createFsService() { | ||
| if (DiscoveryNode.isWarmNode(settings)) { | ||
| return new WarmFsService(settings, nodeEnvironment, fileCacheSettings, indicesService, fileCache); | ||
| } | ||
| return new FsService(settings, nodeEnvironment, fileCache); | ||
| } | ||
| } |
90 changes: 90 additions & 0 deletions
90
server/src/main/java/org/opensearch/monitor/fs/WarmFsService.java
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| /* | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| * | ||
| * The OpenSearch Contributors require contributions made to | ||
| * this file be licensed under the Apache-2.0 license or a | ||
| * compatible open source license. | ||
| */ | ||
|
|
||
| package org.opensearch.monitor.fs; | ||
|
|
||
| import org.apache.logging.log4j.LogManager; | ||
| import org.apache.logging.log4j.Logger; | ||
| import org.opensearch.common.settings.Settings; | ||
| import org.opensearch.env.NodeEnvironment; | ||
| import org.opensearch.index.IndexService; | ||
| import org.opensearch.index.shard.IndexShard; | ||
| import org.opensearch.index.store.remote.filecache.FileCache; | ||
| import org.opensearch.index.store.remote.filecache.FileCacheSettings; | ||
| import org.opensearch.indices.IndicesService; | ||
|
|
||
| import static org.opensearch.monitor.fs.FsProbe.adjustForHugeFilesystems; | ||
|
|
||
| /** | ||
| * FileSystem service implementation for warm nodes that calculates disk usage | ||
| * based on file cache size and remote data ratio instead of actual physical disk usage. | ||
| * | ||
| * @opensearch.internal | ||
| */ | ||
| public class WarmFsService extends FsService { | ||
|
|
||
| private static final Logger logger = LogManager.getLogger(WarmFsService.class); | ||
|
|
||
| private final FileCacheSettings fileCacheSettings; | ||
| private final IndicesService indicesService; | ||
| private final FileCache fileCache; | ||
|
|
||
| public WarmFsService( | ||
| Settings settings, | ||
| NodeEnvironment nodeEnvironment, | ||
| FileCacheSettings fileCacheSettings, | ||
| IndicesService indicesService, | ||
| FileCache fileCache | ||
| ) { | ||
| super(settings, nodeEnvironment, fileCache); | ||
| this.fileCacheSettings = fileCacheSettings; | ||
| this.indicesService = indicesService; | ||
| this.fileCache = fileCache; | ||
| } | ||
|
|
||
| @Override | ||
| public FsInfo stats() { | ||
| // Calculate total addressable space | ||
| final double dataToFileCacheSizeRatio = fileCacheSettings.getRemoteDataRatio(); | ||
| final long nodeCacheSize = fileCache != null ? fileCache.capacity() : 0; | ||
| final long totalBytes = (long) (dataToFileCacheSizeRatio * nodeCacheSize); | ||
|
|
||
| // Calculate used bytes from primary shards | ||
| long usedBytes = 0; | ||
| if (indicesService != null) { | ||
| for (IndexService indexService : indicesService) { | ||
| for (IndexShard shard : indexService) { | ||
| if (shard.routingEntry() != null && shard.routingEntry().primary() && shard.routingEntry().active()) { | ||
| try { | ||
| usedBytes += shard.store().stats(0).getSizeInBytes(); | ||
| } catch (Exception e) { | ||
| logger.error("Unable to get store size for shard {} with error: {}", shard.shardId(), e.getMessage()); | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| long freeBytes = Math.max(0, totalBytes - usedBytes); | ||
|
|
||
| FsInfo.Path warmPath = new FsInfo.Path(); | ||
| warmPath.path = "/warm"; | ||
| warmPath.mount = "warm"; | ||
| warmPath.type = "warm"; | ||
| warmPath.total = adjustForHugeFilesystems(totalBytes); | ||
| warmPath.free = adjustForHugeFilesystems(freeBytes); | ||
| warmPath.available = adjustForHugeFilesystems(freeBytes); | ||
| warmPath.fileCacheReserved = adjustForHugeFilesystems(fileCache.capacity()); | ||
| warmPath.fileCacheUtilized = adjustForHugeFilesystems(fileCache.usage()); | ||
|
|
||
| logger.trace("Warm node disk usage - total: {}, used: {}, free: {}", totalBytes, usedBytes, freeBytes); | ||
|
|
||
| FsInfo nodeFsInfo = super.stats(); | ||
| return new FsInfo(System.currentTimeMillis(), nodeFsInfo.getIoStats(), new FsInfo.Path[] { warmPath }); | ||
| } | ||
| } |
This file contains hidden or 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.
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.
Uh oh!
There was an error while loading. Please reload this page.