goiri commented on a change in pull request #1010: HDFS-13694. Making md5
computing being in parallel with image loading.
URL: https://github.com/apache/hadoop/pull/1010#discussion_r298269662
##########
File path:
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSImageFormatProtobuf.java
##########
@@ -172,13 +172,72 @@ public LoaderContext getLoaderContext() {
return ctx;
}
+ private static class DigestThread extends Thread {
+
+ /**
+ * Exception thrown when computing the digest if it cannot be calculated.
+ */
+ private volatile IOException ioe = null;
+
+ /**
+ * Calculated digest if there are no error.
+ */
+ private volatile MD5Hash digest = null;
+
+ /**
+ * FsImage file computed MD5
+ */
+ private final File file;
+
+ public DigestThread(File inFile) {
+ file = inFile;
+ }
+
+ public MD5Hash getDigest() {
+ return digest;
+ }
+
+ public IOException getException() {
+ return ioe;
+ }
+
+ @Override
+ public void run() {
+ try {
+ digest = MD5FileUtils.computeMd5ForFile(file);
+ } catch (IOException e) {
+ ioe = e;
+ } catch (Throwable t) {
+ ioe = new IOException(t);
+ }
+ }
+
+ @Override
+ public String toString() {
+ return "DigestThread{" + "ThreadName=" + getName() + ", digest="
+ + digest + ", file=" + file + '}';
+ }
+ }
+
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");
Review comment:
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.)
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]