-
Notifications
You must be signed in to change notification settings - Fork 587
HDDS-11463. Add SCM RPC support for DataNode volume info reporting. #7266
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
Closed
Closed
Changes from all commits
Commits
Show all changes
3 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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,13 +20,15 @@ | |
| import static org.apache.hadoop.ozone.container.upgrade.UpgradeUtils.toLayoutVersionProto; | ||
|
|
||
| import com.google.common.annotations.VisibleForTesting; | ||
| import java.util.ArrayList; | ||
| import java.util.Collections; | ||
| import java.util.HashMap; | ||
| import java.util.List; | ||
| import java.util.Map; | ||
| import java.util.concurrent.locks.ReadWriteLock; | ||
| import java.util.concurrent.locks.ReentrantReadWriteLock; | ||
| import org.apache.hadoop.hdds.protocol.DatanodeDetails; | ||
| import org.apache.hadoop.hdds.protocol.proto.HddsProtos.VolumeInfoProto; | ||
| import org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.CommandQueueReportProto; | ||
| import org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.LayoutVersionProto; | ||
| import org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.MetadataStorageReportProto; | ||
|
|
@@ -49,7 +51,7 @@ public class DatanodeInfo extends DatanodeDetails { | |
| private volatile long lastHeartbeatTime; | ||
| private long lastStatsUpdatedTime; | ||
| private int failedVolumeCount; | ||
|
|
||
| private List<VolumeInfoProto> volumeInfos; | ||
| private List<StorageReportProto> storageReports; | ||
| private List<MetadataStorageReportProto> metadataStorageReports; | ||
| private LayoutVersionProto lastKnownLayoutVersion; | ||
|
|
@@ -72,6 +74,7 @@ public DatanodeInfo(DatanodeDetails datanodeDetails, NodeStatus nodeStatus, | |
| layoutInfo != null ? layoutInfo.getMetadataLayoutVersion() : 0, | ||
| layoutInfo != null ? layoutInfo.getSoftwareLayoutVersion() : 0); | ||
| this.storageReports = Collections.emptyList(); | ||
| this.volumeInfos = Collections.emptyList(); | ||
| this.nodeStatus = nodeStatus; | ||
| this.metadataStorageReports = Collections.emptyList(); | ||
| this.commandCounts = new HashMap<>(); | ||
|
|
@@ -155,16 +158,57 @@ public void updateStorageReports(List<StorageReportProto> reports) { | |
| .filter(e -> e.hasFailed() && e.getFailed()) | ||
| .count(); | ||
|
|
||
| // We choose to update the status of failed disks during the heartbeat, | ||
| // so we can directly retrieve it when querying. | ||
| List<VolumeInfoProto> volumeInfoLists = new ArrayList<>(); | ||
| for (StorageReportProto report : reports) { | ||
|
|
||
| String storageLocation = report.getStorageLocation(); | ||
| long capacity = report.getCapacity(); | ||
|
|
||
| String hostName = getHostName(); | ||
|
|
||
| boolean failed = false; | ||
| if (report.hasFailed() && report.getFailed()) { | ||
| failed = true; | ||
| } | ||
|
|
||
| VolumeInfoProto volumeFailure = | ||
| VolumeInfoProto.newBuilder(). | ||
| setDataNodeId(getID().toProto()). | ||
| setHostName(hostName). | ||
| setVolumeName(storageLocation). | ||
| setCapacity(capacity). | ||
| setFailed(failed). | ||
| build(); | ||
| volumeInfoLists.add(volumeFailure); | ||
| } | ||
|
|
||
|
Contributor
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. Please wrap |
||
| try { | ||
| lock.writeLock().lock(); | ||
| lastStatsUpdatedTime = Time.monotonicNow(); | ||
| failedVolumeCount = failedCount; | ||
| storageReports = reports; | ||
| volumeInfos = Collections.unmodifiableList(volumeInfoLists); | ||
| } finally { | ||
| lock.writeLock().unlock(); | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Get all volume information. | ||
| * | ||
| * @return VolumeInfo List. | ||
| */ | ||
| public List<VolumeInfoProto> getVolumeInfos() { | ||
| try { | ||
| lock.readLock().lock(); | ||
| return volumeInfos; | ||
| } finally { | ||
| lock.readLock().unlock(); | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Updates the datanode metadata storage reports. | ||
| * | ||
|
|
||
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
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.
volumeInfosis never assigned. I think the intention was to update this variable inupdateStorageReportsin the block holdingwriteLock.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.
Thank you for pointing out this issue! I hadn't noticed these details before.