ZhaoBQ commented on a change in pull request #626: HBASE-23017 Verify the file integrity in persistent IOEngine URL: https://github.com/apache/hbase/pull/626#discussion_r329143724
########## File path: hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/bucket/PersistentIOEngine.java ########## @@ -0,0 +1,119 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.hadoop.hbase.io.hfile.bucket; + +import java.io.File; +import java.io.IOException; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; + +import org.apache.hadoop.hbase.util.Bytes; +import org.apache.hadoop.util.Shell; +import org.apache.yetus.audience.InterfaceAudience; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * A class implementing PersistentIOEngine interface supports file integrity verification + * for {@link BucketCache} which use persistent IOEngine + */ [email protected] +public abstract class PersistentIOEngine implements IOEngine { + private static final Logger LOG = LoggerFactory.getLogger(PersistentIOEngine.class); + private static final DuFileCommand DU = new DuFileCommand(new String[] {"du", ""}); + protected final String[] filePaths; + + public PersistentIOEngine(String[] filePaths) { + this.filePaths = filePaths; + } + + /** + * Verify cache files's integrity + * @param algorithm the backingMap persistence path + */ + protected void verifyFileIntegrity(byte[] persistentChecksum, String algorithm) Review comment: In branch-1 the method verifyFileIntegrity() return boolean type to indicate whether the verification is successful. Here we throw IOE if verification failed. Because the method parsePB() use this way. ---------------------------------------------------------------- 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
