adoroszlai commented on a change in pull request #438: HDDS-2878. Refactor 
MiniOzoneLoadGenerator to add more load generators to chaos testing.
URL: https://github.com/apache/hadoop-ozone/pull/438#discussion_r394933743
 
 

 ##########
 File path: 
hadoop-ozone/fault-injection-test/mini-chaos-tests/src/test/java/org/apache/hadoop/ozone/loadgenerators/AgedLoadGenerator.java
 ##########
 @@ -0,0 +1,110 @@
+/**
+ * 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.loadgenerators;
+
+import org.apache.commons.lang3.RandomUtils;
+import org.apache.hadoop.ozone.MiniOzoneLoadGenerator;
+import org.apache.hadoop.ozone.utils.LoadBucket;
+import org.apache.hadoop.ozone.utils.TestProbability;
+import org.apache.hadoop.util.ExitUtil;
+import org.apache.hadoop.util.Time;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.nio.ByteBuffer;
+import java.util.Optional;
+import java.util.concurrent.atomic.AtomicInteger;
+
+/**
+ * Aged Load Generator for Ozone.
+ *
+ * This Load Generator reads and write key to an Ozone bucket.
+ *
+ * The default writes to read ratio is 10:90.
+ */
+public class AgedLoadGenerator implements LoadGenerator {
+
+  private static final Logger LOG =
+      LoggerFactory.getLogger(AgedLoadGenerator.class);
+  private static String agedSuffix = "aged";
+
+  private final AtomicInteger agedFileWrittenIndex;
+  private final AtomicInteger agedFileAllocationIndex;
+  private final LoadBucket agedLoadBucket;
+  private final TestProbability agedWriteProbability;
+  private final DataBuffer dataBuffer;
+
+  public AgedLoadGenerator(DataBuffer data, LoadBucket agedLoadBucket) {
+    this.dataBuffer = data;
+    this.agedFileWrittenIndex = new AtomicInteger(0);
+    this.agedFileAllocationIndex = new AtomicInteger(0);
+    this.agedLoadBucket = agedLoadBucket;
+    this.agedWriteProbability = TestProbability.valueOf(10);
+  }
+
+  public void startLoad(long runTimeMillis) {
+    long threadID = Thread.currentThread().getId();
+    LOG.info("AGED LOADGEN: Started Aged IO Thread:{}.", threadID);
+    long startTime = Time.monotonicNow();
+
+    while (Time.monotonicNow() < startTime + runTimeMillis) {
 
 Review comment:
   `System#nanoTime` says timestamps should be compared in the form: `t1 - t0 < 
...`, so I think this should be:
   
   ```suggestion
       while (Time.monotonicNow() - startTime < runTimeMillis) {
   ```

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

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to