-
Notifications
You must be signed in to change notification settings - Fork 9.1k
HDFS-13694. Making md5 computing being in parallel with image loading. #1010
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. |
💔 -1 overall
This message was automatically generated. |
💔 -1 overall
This message was automatically generated. |
void load(File file) throws IOException { | ||
long start = Time.monotonicNow(); | ||
imgDigest = MD5FileUtils.computeMd5ForFile(file); | ||
FSImageFormatProtobuf.Loader.DigestThread dt = |
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.
Can you just use DigestThread? Instead of the full declaration.
.../hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSImageFormatProtobuf.java
Show resolved
Hide resolved
@@ -172,13 +172,55 @@ public LoaderContext getLoaderContext() { | |||
return ctx; | |||
} | |||
|
|||
private class DigestThread extends Thread { |
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 think the common approach is to define this as static.
@@ -172,13 +172,55 @@ public LoaderContext getLoaderContext() { | |||
return ctx; | |||
} | |||
|
|||
private class DigestThread extends Thread { |
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.
Javadoc mentioning that this a thread for parallel MD5 computing to increase performance when loading.
.../hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSImageFormatProtobuf.java
Outdated
Show resolved
Hide resolved
if (t instanceof IOException) { | ||
ioe = (IOException) t; | ||
} else { | ||
ioe = new IOException(t); |
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.
Do we have unit tests throwing these exceptions?
💔 -1 overall
This message was automatically generated. |
@goiri I have updated this patch as your comments. The exists unit test is coverage in this area.Could you have time to help review this patch? Thank you. |
💔 -1 overall
This message was automatically generated. |
* a thread for parallel MD5 computing to increase performance when loading | ||
*/ | ||
private static class DigestThread extends Thread { | ||
volatile private IOException ioe = null; |
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.
Javadocs of the style:
/** Exception thrown when computing the diggest if it cannot be calculated. /
private volatile IOException ioe = null;
/* Calculated digest if there are no error. */
private volatile MD5Hash digest = null;
Note that I think the style says "private volatile"
private static class DigestThread extends Thread { | ||
volatile private IOException ioe = null; | ||
volatile private MD5Hash digest = null; | ||
private File file; |
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.
final and add javadoc.
.../hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSImageFormatProtobuf.java
Show resolved
Hide resolved
.../hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSImageFormatProtobuf.java
Show resolved
Hide resolved
.../hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSImageFormatProtobuf.java
Show resolved
Hide resolved
.../hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSImageFormatProtobuf.java
Show resolved
Hide resolved
3ac739c
to
db3ca99
Compare
@goiri I have updated this patch. Could you continue to help review this patch? Thank you. |
💔 -1 overall
This message was automatically generated. |
💔 -1 overall
This message was automatically generated. |
.../hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSImageFormatProtobuf.java
Show resolved
Hide resolved
.../hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSImageFormatProtobuf.java
Show resolved
Hide resolved
.../hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSImageFormatProtobuf.java
Show resolved
Hide resolved
|
||
@Override | ||
public String toString() { | ||
return "DigestThread{" + "ThreadName=" + getName() + ", digest=" |
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.
No need for the first +
void load(File file) throws IOException { | ||
long start = Time.monotonicNow(); | ||
imgDigest = MD5FileUtils.computeMd5ForFile(file); | ||
DigestThread dt = new DigestThread(file); | ||
dt.setName(file.getName() + " computed MD5 Thread"); |
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.
You can do this setter and the daemon one in the constructor of the class.
The text should be something like "file.getName() + " MD5 compute"
(No need for the word Thread specifically.)
@goiri Thanks for your comments. I update this patch. Could you continue to review it? Thank you. |
💔 -1 overall
This message was automatically generated. |
.../hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSImageFormatProtobuf.java
Show resolved
Hide resolved
@goiri I have added Javadoc explaining the overall idea and updated patch.Could you help review this patch? Thank you again. |
💔 -1 overall
This message was automatically generated. |
Can we fix the checkstyle warnings? |
Signed-off-by: sunlisheng <sunlisheng@xiaomi.com>
💔 -1 overall
This message was automatically generated. |
Thank @goiri for your suggestion. I have fixed the checkstyle warnings. Could you have time to review this patch ? Thank you. |
LGTM |
Hi @goiri, If you think this patch no problem, could you help merge it to trunk ? Thank you. |
Merged and updated the JIRA. |
… from the coordinator stream. (apache#1010)
Signed-off-by: sunlisheng sunlisheng@xiaomi.com