anoopsjohn commented on a change in pull request #633: HBASE-22890 Verify the 
file integrity in persistent IOEngine
URL: https://github.com/apache/hbase/pull/633#discussion_r325766107
 
 

 ##########
 File path: 
hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/bucket/FileIOEngine.java
 ##########
 @@ -59,6 +65,30 @@ public FileIOEngine(long capacity, String... filePaths) 
throws IOException {
     this.fileChannels = new FileChannel[filePaths.length];
     this.rafs = new RandomAccessFile[filePaths.length];
     this.channelLocks = new ReentrantLock[filePaths.length];
+    init();
+  }
+
+  @Override
+  public boolean verifyFileIntegrity(byte[] persistentChecksum, String 
algorithm)
+    throws IOException {
+    try {
+      byte[] calculateChecksum = calculateChecksum(algorithm);
+      if (!Bytes.equals(persistentChecksum, calculateChecksum)) {
+        throw new IOException("The persistent checksum is " + 
Bytes.toString(persistentChecksum) +
+          ", but the calculate checksum is " + 
Bytes.toString(calculateChecksum));
+      }
+      return true;
+    } catch (IOException ioex) {
+      LOG.error("File verification failed because of ", ioex);
+      reinit();
 
 Review comment:
   Why this reinit only in this case?   In case of checksum mismatch no such 
thing happening no?

----------------------------------------------------------------
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

Reply via email to