-
Notifications
You must be signed in to change notification settings - Fork 9.1k
HDFS-16352. return the real datanode numBlocks in #getDatanodeStorage… #3714
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
Conversation
💔 -1 overall
This message was automatically generated. |
@liubingxing Any chance we can add a test? |
1299cc2
to
bed5ed4
Compare
@virajjasani I add UT |
💔 -1 overall
This message was automatically generated. |
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.
+1 (non-binding), pending QA. thanks @liubingxing
Sorry somehow I missed QA result from Jenkins. @liubingxing could you take care of checkstyle warning? |
bed5ed4
to
81d01ff
Compare
@virajjasani Thanks for your review. I have fixed the checkstyle warning and updated the PR. |
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.
Thanks @liubingxing for your PR. Leave one comment inline. Thanks.
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.
new DatanodeInfoBuilder().setFrom(d).build()
has set numBlocks
. Any difference to set it again here? Any other reason?
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.
@Hexiaoqiao new DatanodeInfoBuilder().setFrom(d).build()
set the DatanodeInfo
from DatanodeDescriptor
which from final List<DatanodeDescriptor> datanodes = getDatanodeListForReport(type);
. But DatanodeDescriptor
does not set the actual numBlocks of datanode.
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.
I believe we should remove this.numBlocks = from.getNumBlocks()
from DatanodeInfoBuilder#setFrom(DatanodeInfo)
method because even FSNamesystem#datanodeReport
is also explicitly setting numBlocks:
arr[i] = new DatanodeInfoBuilder().setFrom(results.get(i))
.build();
arr[i].setNumBlocks(results.get(i).numBlocks());
And we can also add a comment in setFrom(DatanodeInfo) method stating that: use setNumBlocks
specifically to set numBlocks as this method won't set it correctly.
How about this diff?
diff --git a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/protocol/DatanodeInfo.java b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/protocol/DatanodeInfo.java
index bba90a05794..fbe6bcc4629 100644
--- a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/protocol/DatanodeInfo.java
+++ b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/protocol/DatanodeInfo.java
@@ -698,9 +698,10 @@ public void setSoftwareVersion(String softwareVersion) {
private long nonDfsUsed = 0L;
private long lastBlockReportTime = 0L;
private long lastBlockReportMonotonic = 0L;
- private int numBlocks;
-
+ private int numBlocks = 0;
+ // Please use setNumBlocks explicitly to set numBlocks as this method doesn't have
+ // sufficient info about numBlocks
public DatanodeInfoBuilder setFrom(DatanodeInfo from) {
this.capacity = from.getCapacity();
this.dfsUsed = from.getDfsUsed();
@@ -717,7 +718,6 @@ public DatanodeInfoBuilder setFrom(DatanodeInfo from) {
this.upgradeDomain = from.getUpgradeDomain();
this.lastBlockReportTime = from.getLastBlockReportTime();
this.lastBlockReportMonotonic = from.getLastBlockReportMonotonic();
- this.numBlocks = from.getNumBlocks();
setNodeID(from);
return this;
}
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/DatanodeManager.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/DatanodeManager.java
index ef51c6ca074..cfb1d83ec5b 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/DatanodeManager.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/DatanodeManager.java
@@ -2182,7 +2182,8 @@ public String getSlowDisksReport() {
for (int i = 0; i < reports.length; i++) {
final DatanodeDescriptor d = datanodes.get(i);
reports[i] = new DatanodeStorageReport(
- new DatanodeInfoBuilder().setFrom(d).build(), d.getStorageReports());
+ new DatanodeInfoBuilder().setFrom(d).setNumBlocks(d.numBlocks()).build(),
+ d.getStorageReports());
}
return reports;
}
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.
Thanks @liubingxing for your replay. It makes sense to me.
🎊 +1 overall
This message was automatically generated. |
81d01ff
to
450a62a
Compare
🎊 +1 overall
This message was automatically generated. |
@virajjasani Thank you for your advice. I update the PR, please take a look. |
@Hexiaoqiao Please take a look. |
LGTM. +1 from my side. I would like to commit this improvement if no more other comments. |
+1 (non-binding) from my side, thanks @liubingxing and @Hexiaoqiao |
Thanks for the review @virajjasani @Hexiaoqiao |
…Report (apache#3714). Contributed by liubingxing. Signed-off-by: He Xiaoqiao <hexiaoqiao@apache.org>
…Report (apache#3714). Contributed by liubingxing. Signed-off-by: He Xiaoqiao <hexiaoqiao@apache.org> (cherry picked from commit d8dea6f)
…Report (apache#3714). Contributed by liubingxing. Signed-off-by: He Xiaoqiao <hexiaoqiao@apache.org>
JIRA: HDFS-16352
#getDatanodeStorageReport will return the array of DatanodeStorageReport which contains the DatanodeInfo in each DatanodeStorageReport, but the numBlocks in DatanodeInfo is always zero, which is confusing
Or we can return the real numBlocks in DatanodeInfo when we call #getDatanodeStorageReport