-
Notifications
You must be signed in to change notification settings - Fork 588
HDDS-6705 Add metrics for volume statistics including disk capacity, usage, Reserved #3430
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 all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
27654e8
New changes added
ArafatKhan2198 d43917f
HDDS-6687. Add metrics for volume statistics including disk capacity,…
ArafatKhan2198 38aecf1
Corrected a mistake made earlier
ArafatKhan2198 2cc4d4b
Made changes for the code review
ArafatKhan2198 b33f5f7
New Changes
ArafatKhan2198 6bbdcf2
Made new changes
ArafatKhan2198 fc5ea52
Added more changes to the Metrics
ArafatKhan2198 3af2e4c
Added two new metrics
ArafatKhan2198 ec43ddc
Merge branch 'apache:master' into HDDS-6687
ArafatKhan2198 af73ec3
Fixed a few styling issues
70efecc
Fixed a few styling issues
9573b7c
Fixed a few styling issues
3b6e80a
Renamed VolumeInfoStats to VolumeInfoMetrics
45bad46
Fixed styling issues
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
137 changes: 137 additions & 0 deletions
137
...vice/src/main/java/org/apache/hadoop/ozone/container/common/volume/VolumeInfoMetrics.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,137 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package org.apache.hadoop.ozone.container.common.volume; | ||
|
|
||
| import org.apache.hadoop.metrics2.MetricsSystem; | ||
| import org.apache.hadoop.metrics2.annotation.Metric; | ||
| import org.apache.hadoop.metrics2.annotation.Metrics; | ||
| import org.apache.hadoop.metrics2.lib.DefaultMetricsSystem; | ||
| import org.apache.hadoop.ozone.OzoneConsts; | ||
|
|
||
| /** | ||
| * This class is used to track Volume Info stats for each HDDS Volume. | ||
| */ | ||
| @Metrics(about = "Ozone Volume Information Metrics", | ||
| context = OzoneConsts.OZONE) | ||
| public class VolumeInfoMetrics { | ||
|
|
||
| private String metricsSourceName = VolumeInfoMetrics.class.getSimpleName(); | ||
| private String volumeRootStr; | ||
| private HddsVolume volume; | ||
|
|
||
| /** | ||
| * @param identifier Typically, path to volume root. e.g. /data/hdds | ||
| */ | ||
| public VolumeInfoMetrics(String identifier, HddsVolume ref) { | ||
| this.metricsSourceName += '-' + identifier; | ||
| this.volumeRootStr = identifier; | ||
| this.volume = ref; | ||
| init(); | ||
| } | ||
|
|
||
| public void init() { | ||
| MetricsSystem ms = DefaultMetricsSystem.instance(); | ||
| ms.register(metricsSourceName, "Volume Info Statistics", this); | ||
| } | ||
|
|
||
| public void unregister() { | ||
| MetricsSystem ms = DefaultMetricsSystem.instance(); | ||
| ms.unregisterSource(metricsSourceName); | ||
| } | ||
|
|
||
| @Metric("Metric to return the Storage Type") | ||
| public String getStorageType() { | ||
| return volume.getStorageType().toString(); | ||
| } | ||
|
|
||
| @Metric("Returns the Directory name for the volume") | ||
| public String getStorageDirectory() { | ||
| return volume.getStorageDir().toString(); | ||
| } | ||
|
|
||
| @Metric("Return the DataNode UID for the respective volume") | ||
| public String getDatanodeUuid() { | ||
| return volume.getDatanodeUuid(); | ||
| } | ||
|
|
||
| @Metric("Return the Layout Version for the volume") | ||
| public int getLayoutVersion() { | ||
| return volume.getLayoutVersion(); | ||
| } | ||
|
|
||
| @Metric("Returns the Volume Type") | ||
| public String getVolumeType() { | ||
| return volume.getType().name(); | ||
| } | ||
|
|
||
| public String getMetricsSourceName() { | ||
| return metricsSourceName; | ||
| } | ||
|
|
||
| /** | ||
| * Test conservative avail space. | ||
| * |----used----| (avail) |++++++++reserved++++++++| | ||
| * |<------- capacity ------->| | ||
| * |<------------------- Total capacity -------------->| | ||
| * A) avail = capacity - used | ||
| * B) capacity = used + avail | ||
| * C) Total capacity = used + avail + reserved | ||
| */ | ||
|
|
||
| /** | ||
| * Return the Storage type for the Volume. | ||
| */ | ||
| @Metric("Returns the Used space") | ||
| public long getUsed() { | ||
| return volume.getVolumeInfo().getScmUsed(); | ||
| } | ||
|
|
||
| /** | ||
| * Return the Total Available capacity of the Volume. | ||
| */ | ||
| @Metric("Returns the Available space") | ||
| public long getAvailable() { | ||
| return volume.getVolumeInfo().getAvailable(); | ||
| } | ||
|
|
||
| /** | ||
| * Return the Total Reserved of the Volume. | ||
| */ | ||
| @Metric("Fetches the Reserved Space") | ||
| public long getReserved() { | ||
| return volume.getVolumeInfo().getReservedInBytes(); | ||
| } | ||
|
|
||
| /** | ||
| * Return the Total capacity of the Volume. | ||
| */ | ||
| @Metric("Returns the Capacity of the Volume") | ||
| public long getCapacity() { | ||
| return getUsed() + getAvailable(); | ||
| } | ||
|
|
||
| /** | ||
| * Return the Total capacity of the Volume. | ||
| */ | ||
| @Metric("Returns the Total Capacity of the Volume") | ||
| public long getTotalCapacity() { | ||
| return (getUsed() + getAvailable() + getReserved()); | ||
| } | ||
|
|
||
| } |
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.