yandrey321 commented on code in PR #10651: URL: https://github.com/apache/ozone/pull/10651#discussion_r3571472592
########## hadoop-ozone/freon/src/main/java/org/apache/hadoop/ozone/freon/HadoopFsReadWriteValidator.java: ########## @@ -0,0 +1,229 @@ +/* + * 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.ozone.freon; + +import com.codahale.metrics.Timer; +import java.io.IOException; +import java.nio.ByteBuffer; +import java.security.DigestOutputStream; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.Callable; +import java.util.concurrent.ThreadLocalRandom; +import org.apache.hadoop.fs.FSDataInputStream; +import org.apache.hadoop.fs.FileSystem; +import org.apache.hadoop.fs.Path; +import org.apache.hadoop.hdds.cli.HddsVersionProvider; +import org.apache.hadoop.hdds.conf.StorageSize; +import org.apache.hadoop.hdds.utils.IOUtils; +import org.kohsuke.MetaInfServices; +import picocli.CommandLine.Command; +import picocli.CommandLine.Option; + +/** + * Freon generator that writes files and reads them back with data validation. + * <p> + * Each worker thread writes files and gives every write a distinct content + * marker, so re-reading a path validates against its most recent write. The + * thread keeps the latest hash of every path it wrote, then reads back a random + * one and verifies the hash still matches. This detects both data corruption + * and stale reads (an overwritten path returning older bytes) under concurrent + * load, including in time-based (--duration) runs where paths are reused. + */ +@Command(name = "dfsrw", + aliases = "dfs-read-write-validator", + description = "Write files and read them back with data validation on any " + + "dfs compatible file system.", + versionProvider = HddsVersionProvider.class, + mixinStandardHelpOptions = true, + showDefaultValues = true) +@MetaInfServices(FreonSubcommand.class) +public class HadoopFsReadWriteValidator extends HadoopBaseFreonGenerator Review Comment: I'd change the logic to allow pre-create a small population of files before attempting to read random path. We might also need a variation of this test that read every file after completing the write to verify write correctness -- 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. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
