yandrey321 commented on code in PR #10651:
URL: https://github.com/apache/ozone/pull/10651#discussion_r3571422167


##########
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
+    implements Callable<Void> {
+
+  /**
+   * Upper bound on the number of paths a thread tracks for read-back. It caps
+   * memory use for large runs; the untracked files still exist on the FS.
+   */
+  private static final int MAX_HISTORY_PER_THREAD = 1000;
+
+  /**
+   * Digest algorithm used for the write-side hash. Must match the algorithm
+   * used by {@link #getDigest} so the read-back validation compares equivalent
+   * digests.
+   */
+  private static final String DIGEST_ALGORITHM = "MD5";
+
+  @Option(names = {"-s", "--size"},
+      description = "Size of the generated files. " +
+          StorageSizeConverter.STORAGE_SIZE_DESCRIPTION,
+      defaultValue = "10KB",
+      converter = StorageSizeConverter.class)
+  private StorageSize fileSize;
+
+  @Option(names = {"--buffer"},
+      description = "Size of buffer used to generate the file content.",
+      defaultValue = "10240")
+  private int bufferSize;
+
+  @Option(names = {"--copy-buffer"},
+      description = "Size of bytes written to the output in one operation.",
+      defaultValue = "4096")

Review Comment:
   it should either match to the file size (for small files) or be like 1MB for 
files larger than 1MB. Otherwise the benchmark results would be affected by a 
number of a small memcopy.



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

Reply via email to