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_r319349611
##########
File path:
hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/bucket/FileIOEngine.java
##########
@@ -59,6 +61,43 @@ 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();
+ }
+
+ public FileIOEngine(String algorithmName, String persistencePath,
+ long capacity, String... filePaths) throws IOException {
+ this.sizePerFile = capacity / filePaths.length;
+ this.capacity = this.sizePerFile * filePaths.length;
+ this.filePaths = filePaths;
+ this.fileChannels = new FileChannel[filePaths.length];
+ this.rafs = new RandomAccessFile[filePaths.length];
+ this.channelLocks = new ReentrantLock[filePaths.length];
+ if (persistencePath != null){
+ try {
+ String preFilesKey = FileIOEngineUtils.getPreFilesKey(persistencePath);
+ String filesKey = FileIOEngineUtils.getFilesKey(filePaths,
algorithmName);
+ LOG.info("preFilesKey: "+ preFilesKey + " filesKey: " + filesKey);
+ if (preFilesKey == null || !preFilesKey.equals(filesKey)){
+ throw new IOException("File verification failed! Can't restore from
file.");
+ }
+ } catch (IOException ioex) {
+ LOG.error("Can't restore from file because of", ioex);
+ // delete cache files and backingMap persistence file.
+ FileIOEngineUtils.deleteCacheDataFile(filePaths);
+ File persistenceFile = new File(persistencePath);
+ persistenceFile.delete();
+ } catch (NoSuchAlgorithmException nsae) {
+ LOG.error("No such algorithm " + algorithmName, nsae);
+ throw new RuntimeException(nsae);
+ }
+ } else {
+ // not configure persistencePath
+ FileIOEngineUtils.deleteCacheDataFile(filePaths);
+ }
+ init();
+ }
+
+ public void init() throws IOException {
Review comment:
this method should be private?
----------------------------------------------------------------
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