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_r325501278
########## File path: hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/bucket/FileIOEngine.java ########## @@ -267,6 +339,75 @@ void refreshFileConnection(int accessFileNum, IOException ioe) throws IOExceptio } } + /** + * Delete bucketcache files + */ + private void deleteCacheDataFile() { + if (filePaths == null) { + return; + } + for (String file : filePaths) { + new File(file).delete(); + } + } + + @Override + public byte[] calculateChecksum() + throws IOException, NoSuchAlgorithmException { + if (filePaths == null) { + return null; + } + StringBuilder sb = new StringBuilder(); + for (String filePath : filePaths){ + File file = new File(filePath); + if (file.exists()){ + sb.append(filePath); + sb.append(getFileSize(filePath)); + sb.append(file.lastModified()); + } else { + throw new IOException("Cache file: " + filePath + " is not exists."); + } + } + MessageDigest messageDigest = MessageDigest.getInstance(algorithmName); + messageDigest.update(Bytes.toBytes(sb.toString())); + return messageDigest.digest(); + } + + @Override + public boolean isOldVersion() { Review comment: I see now this is been used. So my point was like read the checksum in BucketCache only. And let IT decide whether to do the checksum verify or not based on PBMagic. ---------------------------------------------------------------- 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: us...@infra.apache.org With regards, Apache Git Services