Reidddddd commented on a change in pull request #528: HBASE-22890 Verify the 
files when RegionServer is starting and BucketCache is in file mode
URL: https://github.com/apache/hbase/pull/528#discussion_r324501589
 
 

 ##########
 File path: 
hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/bucket/FileIOEngine.java
 ##########
 @@ -267,6 +317,99 @@ void refreshFileConnection(int accessFileNum, IOException 
ioe) throws IOExceptio
     }
   }
 
+  /**
+   * Read the persistent checksum from persistent path
+   * @param persistentPath the backingMap persistent path
+   * @return the persistent checksum
+   */
+  private byte[] readPersistentChecksum(String persistentPath) {
+    try (ObjectInputStream ois = new ObjectInputStream(new 
FileInputStream(persistentPath))) {
+      byte[] PBMagic = new byte[ProtobufUtil.PB_MAGIC.length];
+      ois.read(PBMagic);
+      if (Bytes.equals(ProtobufUtil.PB_MAGIC, PBMagic)) {
+        int length = ois.readInt();
+        byte[] persistentChecksum = new byte[length];
+        ois.read(persistentChecksum);
+        return persistentChecksum;
+      } else {
+        // if the persistent file is not start with PB_MAGIC, it's an old 
version file
+        oldVersion = true;
+      }
+    } catch (IOException ioex) {
+      LOG.warn("Failed read persistent checksum, because of " + ioex);
+      return null;
+    }
+    return null;
+  }
+
+  @Override
+  public void deleteCacheDataFile() {
+    if (filePaths == null) {
+      return;
+    }
+    for (String file : filePaths) {
+      new File(file).delete();
+    }
+  }
+
+  @Override
+  public byte[] calculateChecksum()
+    throws IOException, NoSuchAlgorithmException {
+
 
 Review comment:
   Unnecessary empty line.

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