You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by GitBox <gi...@apache.org> on 2022/05/05 12:41:55 UTC

[GitHub] [ozone] tanvipenumudy opened a new pull request, #3383: HDDS-6619. Add freon command to run r/w mix workload using ObjectStore APIs

tanvipenumudy opened a new pull request, #3383:
URL: https://github.com/apache/ozone/pull/3383

   ## What changes were proposed in this pull request?
   
   To develop a new Ozone Freon command tool where one can generate a synthetic read and write operation mix workload using `OBJECT_STORE ("OBS")` APIs.
   
   **Step-1:** Create `keyCountForRead` (defaultValue = 100) keys under path/readPath
   **Step-2:** Start `readThreadCount` (defaultValue = 90) concurrent read threads
           &emsp;each new Thread (() ->{
               &emsp;&emsp;for(1...`numOfReadOperations` (defaultValue = 50))
                   &emsp;&emsp;&emsp;bucket.listKeys(_path/readPath_)
           &emsp;}
   **Step-3:** Start `writeThreadCount` (defaultValue = 10) concurrent write threads
           &emsp;each new Thread (() -> {
               &emsp;&emsp;for(1...`numOfWriteOperations` (defaultValue = 10))
                   &emsp;&emsp;&emsp;bucket.createKey(_path/writePath/file-random-keypath_)
           &emsp;}
   
   ## What is the link to the Apache JIRA
   
   https://issues.apache.org/jira/browse/HDDS-6619
   
   ## How was this patch tested?
   
   Added integration tests.
   


-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


[GitHub] [ozone] tanvipenumudy commented on a diff in pull request #3383: HDDS-6619. Add freon command to run r/w mix workload using ObjectStore APIs

Posted by GitBox <gi...@apache.org>.
tanvipenumudy commented on code in PR #3383:
URL: https://github.com/apache/ozone/pull/3383#discussion_r869860688


##########
hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/freon/TestOmBucketReadWriteKeyOps.java:
##########
@@ -0,0 +1,304 @@
+/**
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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 org.apache.commons.io.FileUtils;
+import org.apache.hadoop.hdds.conf.OzoneConfiguration;
+import org.apache.hadoop.ozone.MiniOzoneCluster;
+
+import org.apache.hadoop.ozone.client.ObjectStore;
+import org.apache.hadoop.ozone.client.OzoneBucket;
+import org.apache.hadoop.ozone.client.OzoneClientFactory;
+import org.apache.hadoop.ozone.client.OzoneVolume;
+import org.apache.hadoop.ozone.client.OzoneKey;
+import org.apache.hadoop.ozone.om.OMConfigKeys;
+import org.apache.hadoop.ozone.om.helpers.BucketLayout;
+import org.apache.hadoop.ozone.om.lock.OMLockMetrics;
+import org.apache.ozone.test.GenericTestUtils;
+import org.apache.ratis.server.RaftServer;
+import org.apache.ratis.server.raftlog.RaftLog;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.slf4j.event.Level;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.Iterator;
+
+/**
+ * Test for OmBucketReadWriteKeyOps.
+ */
+public class TestOmBucketReadWriteKeyOps {
+
+  private String path;
+  private OzoneConfiguration conf = null;
+  private MiniOzoneCluster cluster = null;
+  private ObjectStore store = null;
+  private static final Logger LOG =
+      LoggerFactory.getLogger(TestOmBucketReadWriteKeyOps.class);
+
+  @Before
+  public void setup() {
+    path = GenericTestUtils
+        .getTempPath(TestHadoopDirTreeGenerator.class.getSimpleName());
+    GenericTestUtils.setLogLevel(RaftLog.LOG, Level.DEBUG);
+    GenericTestUtils.setLogLevel(RaftServer.LOG, Level.DEBUG);
+    File baseDir = new File(path);
+    baseDir.mkdirs();
+  }
+
+  /**
+   * Shutdown MiniDFSCluster.
+   */
+  private void shutdown() {
+    if (cluster != null) {
+      cluster.shutdown();
+    }
+  }
+
+  /**
+   * Create a MiniDFSCluster for testing.
+   *
+   * @throws IOException
+   */
+  private void startCluster() throws Exception {
+    conf = getOzoneConfiguration();
+    conf.set(OMConfigKeys.OZONE_DEFAULT_BUCKET_LAYOUT,
+        BucketLayout.OBJECT_STORE.name());
+    cluster = MiniOzoneCluster.newBuilder(conf).setNumDatanodes(5).build();
+    cluster.waitForClusterToBeReady();
+    cluster.waitTobeOutOfSafeMode();
+
+    store = OzoneClientFactory.getRpcClient(conf).getObjectStore();
+  }
+
+  protected OzoneConfiguration getOzoneConfiguration() {

Review Comment:
   Thank you for pointing this out, I have changed the access modifier to _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.

To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


[GitHub] [ozone] tanvipenumudy commented on a diff in pull request #3383: HDDS-6619. Add freon command to run r/w mix workload using ObjectStore APIs

Posted by GitBox <gi...@apache.org>.
tanvipenumudy commented on code in PR #3383:
URL: https://github.com/apache/ozone/pull/3383#discussion_r869861482


##########
hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/freon/AbstractOmBucketReadWriteOps.java:
##########
@@ -0,0 +1,35 @@
+package org.apache.hadoop.ozone.freon;

Review Comment:
   Added the _ASF_ License header, thank you!



-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


[GitHub] [ozone] tanvipenumudy commented on a diff in pull request #3383: HDDS-6619. Add freon command to run r/w mix workload using ObjectStore APIs

Posted by GitBox <gi...@apache.org>.
tanvipenumudy commented on code in PR #3383:
URL: https://github.com/apache/ozone/pull/3383#discussion_r869861092


##########
hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/freon/TestOmBucketReadWriteKeyOps.java:
##########
@@ -0,0 +1,304 @@
+/**
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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 org.apache.commons.io.FileUtils;
+import org.apache.hadoop.hdds.conf.OzoneConfiguration;
+import org.apache.hadoop.ozone.MiniOzoneCluster;
+
+import org.apache.hadoop.ozone.client.ObjectStore;
+import org.apache.hadoop.ozone.client.OzoneBucket;
+import org.apache.hadoop.ozone.client.OzoneClientFactory;
+import org.apache.hadoop.ozone.client.OzoneVolume;
+import org.apache.hadoop.ozone.client.OzoneKey;
+import org.apache.hadoop.ozone.om.OMConfigKeys;
+import org.apache.hadoop.ozone.om.helpers.BucketLayout;
+import org.apache.hadoop.ozone.om.lock.OMLockMetrics;
+import org.apache.ozone.test.GenericTestUtils;
+import org.apache.ratis.server.RaftServer;
+import org.apache.ratis.server.raftlog.RaftLog;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.slf4j.event.Level;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.Iterator;
+
+/**
+ * Test for OmBucketReadWriteKeyOps.
+ */
+public class TestOmBucketReadWriteKeyOps {
+
+  private String path;
+  private OzoneConfiguration conf = null;
+  private MiniOzoneCluster cluster = null;
+  private ObjectStore store = null;
+  private static final Logger LOG =
+      LoggerFactory.getLogger(TestOmBucketReadWriteKeyOps.class);
+
+  @Before
+  public void setup() {
+    path = GenericTestUtils
+        .getTempPath(TestHadoopDirTreeGenerator.class.getSimpleName());
+    GenericTestUtils.setLogLevel(RaftLog.LOG, Level.DEBUG);
+    GenericTestUtils.setLogLevel(RaftServer.LOG, Level.DEBUG);
+    File baseDir = new File(path);
+    baseDir.mkdirs();
+  }
+
+  /**
+   * Shutdown MiniDFSCluster.
+   */
+  private void shutdown() {
+    if (cluster != null) {
+      cluster.shutdown();
+    }
+  }
+
+  /**
+   * Create a MiniDFSCluster for testing.
+   *
+   * @throws IOException
+   */
+  private void startCluster() throws Exception {
+    conf = getOzoneConfiguration();
+    conf.set(OMConfigKeys.OZONE_DEFAULT_BUCKET_LAYOUT,
+        BucketLayout.OBJECT_STORE.name());
+    cluster = MiniOzoneCluster.newBuilder(conf).setNumDatanodes(5).build();
+    cluster.waitForClusterToBeReady();
+    cluster.waitTobeOutOfSafeMode();
+
+    store = OzoneClientFactory.getRpcClient(conf).getObjectStore();
+  }
+
+  protected OzoneConfiguration getOzoneConfiguration() {
+    return new OzoneConfiguration();
+  }
+
+  @Test
+  public void testOmBucketReadWriteKeyOps() throws Exception {
+    try {
+      startCluster();
+      FileOutputStream out = FileUtils.openOutputStream(new File(path,
+          "conf"));
+      cluster.getConf().writeXml(out);
+      out.getFD().sync();
+      out.close();
+
+      verifyFreonCommand(new ParameterBuilder().setTotalThreadCount(10)
+          .setNumOfReadOperations(10).setNumOfWriteOperations(5)
+          .setKeyCountForRead(10).setKeyCountForWrite(5));
+      verifyFreonCommand(
+          new ParameterBuilder().setVolumeName("vol2").setBucketName("bucket1")
+              .setTotalThreadCount(10).setNumOfReadOperations(10)
+              .setNumOfWriteOperations(5).setKeyCountForRead(10)
+              .setKeyCountForWrite(5));
+      verifyFreonCommand(
+          new ParameterBuilder().setVolumeName("vol3").setBucketName("bucket1")
+              .setTotalThreadCount(15).setNumOfReadOperations(5)
+              .setNumOfWriteOperations(3).setKeyCountForRead(5)
+              .setKeyCountForWrite(3));
+      verifyFreonCommand(
+          new ParameterBuilder().setVolumeName("vol4").setBucketName("bucket1")
+              .setTotalThreadCount(10).setNumOfReadOperations(5)
+              .setNumOfWriteOperations(3).setKeyCountForRead(5)
+              .setKeyCountForWrite(3).setKeySizeInBytes(64)
+              .setBufferSize(16));
+      verifyFreonCommand(
+          new ParameterBuilder().setVolumeName("vol5").setBucketName("bucket1")
+              .setTotalThreadCount(10).setNumOfReadOperations(5)
+              .setNumOfWriteOperations(0).setKeyCountForRead(5));
+      verifyFreonCommand(
+          new ParameterBuilder().setVolumeName("vol6").setBucketName("bucket1")
+              .setTotalThreadCount(20).setNumOfReadOperations(0)
+              .setNumOfWriteOperations(5).setKeyCountForRead(0)
+              .setKeyCountForWrite(5));
+
+    } finally {
+      shutdown();
+    }
+  }
+
+  private void verifyFreonCommand(ParameterBuilder parameterBuilder)
+      throws IOException {
+    store.createVolume(parameterBuilder.volumeName);
+    OzoneVolume volume = store.getVolume(parameterBuilder.volumeName);
+    volume.createBucket(parameterBuilder.bucketName);
+    OzoneBucket bucket = store.getVolume(parameterBuilder.volumeName)

Review Comment:
   I have made the changes, thank you for the review!



-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


[GitHub] [ozone] tanvipenumudy commented on a diff in pull request #3383: HDDS-6619. Add freon command to run r/w mix workload using ObjectStore APIs

Posted by GitBox <gi...@apache.org>.
tanvipenumudy commented on code in PR #3383:
URL: https://github.com/apache/ozone/pull/3383#discussion_r871228309


##########
hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/freon/AbstractOmBucketReadWriteOps.java:
##########
@@ -0,0 +1,241 @@
+/**
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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 org.apache.commons.lang3.RandomStringUtils;
+import org.apache.hadoop.hdds.conf.OzoneConfiguration;
+import org.apache.hadoop.ozone.OzoneConsts;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import picocli.CommandLine.Option;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.CompletionService;
+import java.util.concurrent.ExecutorCompletionService;
+
+/**
+ * Abstract class for OmBucketReadWriteFileOps/KeyOps Freon class
+ * implementations.
+ */
+public abstract class AbstractOmBucketReadWriteOps extends BaseFreonGenerator
+    implements Callable<Void> {
+
+  private static final Logger LOG =
+      LoggerFactory.getLogger(AbstractOmBucketReadWriteOps.class);
+
+  @Option(names = {"-g", "--size"},
+      description = "Generated data size (in bytes) of each key/file to be " +
+          "written.",
+      defaultValue = "256")
+  private long sizeInBytes;
+
+  @Option(names = {"--buffer"},
+      description = "Size of buffer used for generating the key/file content.",
+      defaultValue = "64")
+  private int bufferSize;
+
+  @Option(names = {"-l", "--name-len"},
+      description = "Length of the random name of path you want to create.",
+      defaultValue = "10")
+  private int length;
+
+  @Option(names = {"-c", "--total-thread-count"},
+      description = "Total number of threads to be executed.",
+      defaultValue = "100")
+  private int totalThreadCount;
+
+  @Option(names = {"-T", "--read-thread-percentage"},
+      description = "Percentage of the total number of threads to be " +
+          "allocated for read operations. The remaining percentage of " +
+          "threads will be allocated for write operations.",
+      defaultValue = "90")
+  private int readThreadPercentage;
+
+  @Option(names = {"-R", "--num-of-read-operations"},
+      description = "Number of read operations to be performed by each thread.",
+      defaultValue = "50")
+  private int numOfReadOperations;
+
+  @Option(names = {"-W", "--num-of-write-operations"},
+      description = "Number of write operations to be performed by each " +
+          "thread.",
+      defaultValue = "10")
+  private int numOfWriteOperations;
+
+  private OzoneConfiguration ozoneConfiguration;
+  private Timer timer;
+  private ContentGenerator contentGenerator;
+  private int readThreadCount;
+  private int writeThreadCount;
+
+  protected abstract void display();
+
+  protected abstract void initialize(OzoneConfiguration configuration)
+      throws Exception;
+
+  @Override
+  public Void call() throws Exception {
+    init();
+
+    readThreadCount = (readThreadPercentage * totalThreadCount) / 100;
+    writeThreadCount = totalThreadCount - readThreadCount;
+
+    display();
+    print("SizeInBytes: " + sizeInBytes);
+    print("bufferSize: " + bufferSize);
+    print("totalThreadCount: " + totalThreadCount);
+    print("readThreadPercentage: " + readThreadPercentage);
+    print("writeThreadPercentage: " + (100 - readThreadPercentage));
+    print("readThreadCount: " + readThreadCount);
+    print("writeThreadCount: " + writeThreadCount);
+    print("numOfReadOperations: " + numOfReadOperations);
+    print("numOfWriteOperations: " + numOfWriteOperations);
+
+    ozoneConfiguration = createOzoneConfiguration();
+    contentGenerator = new ContentGenerator(sizeInBytes, bufferSize);
+    timer = getMetrics().timer("om-bucket-read-write-ops");
+
+    initialize(ozoneConfiguration);
+
+    return null;
+  }
+
+  protected abstract String createPath(String path) throws IOException;
+
+  protected int readOperations(int keyCountForRead) throws Exception {
+
+    // Create keyCountForRead/fileCountForRead (defaultValue = 1000) keys/files
+    // under rootPath/readPath
+    String readPath = createPath("readPath");
+    create(readPath, keyCountForRead);
+
+    // Start readThreadCount (defaultValue = 90) concurrent read threads
+    // performing numOfReadOperations (defaultValue = 50) iterations
+    // of read operations (bucket.listKeys(readPath) or
+    // fileSystem.listStatus(rootPath/readPath))
+    ExecutorService readService = Executors.newFixedThreadPool(readThreadCount);
+    CompletionService<Integer> readExecutorCompletionService =
+        new ExecutorCompletionService<>(readService);
+    List<Future<Integer>> readFutures = new ArrayList<>();
+    for (int i = 0; i < readThreadCount; i++) {
+      readFutures.add(readExecutorCompletionService.submit(() -> {
+        int readCount = 0;
+        try {
+          for (int j = 0; j < numOfReadOperations; j++) {
+            readCount = getReadCount(readCount, "readPath");
+          }
+        } catch (IOException e) {
+          LOG.warn("Exception while listing keys/files ", e);
+        }
+        return readCount;
+      }));
+    }
+
+    int readResult = 0;
+    for (int i = 0; i < readFutures.size(); i++) {
+      try {
+        readResult += readExecutorCompletionService.take().get();

Review Comment:
   Thank you for the comment, I have removed the try-catch block.



##########
hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/freon/AbstractOmBucketReadWriteOps.java:
##########
@@ -0,0 +1,241 @@
+/**
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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 org.apache.commons.lang3.RandomStringUtils;
+import org.apache.hadoop.hdds.conf.OzoneConfiguration;
+import org.apache.hadoop.ozone.OzoneConsts;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import picocli.CommandLine.Option;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.CompletionService;
+import java.util.concurrent.ExecutorCompletionService;
+
+/**
+ * Abstract class for OmBucketReadWriteFileOps/KeyOps Freon class
+ * implementations.
+ */
+public abstract class AbstractOmBucketReadWriteOps extends BaseFreonGenerator
+    implements Callable<Void> {
+
+  private static final Logger LOG =
+      LoggerFactory.getLogger(AbstractOmBucketReadWriteOps.class);
+
+  @Option(names = {"-g", "--size"},
+      description = "Generated data size (in bytes) of each key/file to be " +
+          "written.",
+      defaultValue = "256")
+  private long sizeInBytes;
+
+  @Option(names = {"--buffer"},
+      description = "Size of buffer used for generating the key/file content.",
+      defaultValue = "64")
+  private int bufferSize;
+
+  @Option(names = {"-l", "--name-len"},
+      description = "Length of the random name of path you want to create.",
+      defaultValue = "10")
+  private int length;
+
+  @Option(names = {"-c", "--total-thread-count"},
+      description = "Total number of threads to be executed.",
+      defaultValue = "100")
+  private int totalThreadCount;
+
+  @Option(names = {"-T", "--read-thread-percentage"},
+      description = "Percentage of the total number of threads to be " +
+          "allocated for read operations. The remaining percentage of " +
+          "threads will be allocated for write operations.",
+      defaultValue = "90")
+  private int readThreadPercentage;
+
+  @Option(names = {"-R", "--num-of-read-operations"},
+      description = "Number of read operations to be performed by each thread.",
+      defaultValue = "50")
+  private int numOfReadOperations;
+
+  @Option(names = {"-W", "--num-of-write-operations"},
+      description = "Number of write operations to be performed by each " +
+          "thread.",
+      defaultValue = "10")
+  private int numOfWriteOperations;
+
+  private OzoneConfiguration ozoneConfiguration;
+  private Timer timer;
+  private ContentGenerator contentGenerator;
+  private int readThreadCount;
+  private int writeThreadCount;
+
+  protected abstract void display();
+
+  protected abstract void initialize(OzoneConfiguration configuration)
+      throws Exception;
+
+  @Override
+  public Void call() throws Exception {
+    init();
+
+    readThreadCount = (readThreadPercentage * totalThreadCount) / 100;
+    writeThreadCount = totalThreadCount - readThreadCount;
+
+    display();
+    print("SizeInBytes: " + sizeInBytes);
+    print("bufferSize: " + bufferSize);
+    print("totalThreadCount: " + totalThreadCount);
+    print("readThreadPercentage: " + readThreadPercentage);
+    print("writeThreadPercentage: " + (100 - readThreadPercentage));
+    print("readThreadCount: " + readThreadCount);
+    print("writeThreadCount: " + writeThreadCount);
+    print("numOfReadOperations: " + numOfReadOperations);
+    print("numOfWriteOperations: " + numOfWriteOperations);
+
+    ozoneConfiguration = createOzoneConfiguration();
+    contentGenerator = new ContentGenerator(sizeInBytes, bufferSize);
+    timer = getMetrics().timer("om-bucket-read-write-ops");
+
+    initialize(ozoneConfiguration);
+
+    return null;
+  }
+
+  protected abstract String createPath(String path) throws IOException;
+
+  protected int readOperations(int keyCountForRead) throws Exception {
+
+    // Create keyCountForRead/fileCountForRead (defaultValue = 1000) keys/files
+    // under rootPath/readPath
+    String readPath = createPath("readPath");
+    create(readPath, keyCountForRead);
+
+    // Start readThreadCount (defaultValue = 90) concurrent read threads
+    // performing numOfReadOperations (defaultValue = 50) iterations
+    // of read operations (bucket.listKeys(readPath) or
+    // fileSystem.listStatus(rootPath/readPath))
+    ExecutorService readService = Executors.newFixedThreadPool(readThreadCount);
+    CompletionService<Integer> readExecutorCompletionService =
+        new ExecutorCompletionService<>(readService);
+    List<Future<Integer>> readFutures = new ArrayList<>();
+    for (int i = 0; i < readThreadCount; i++) {
+      readFutures.add(readExecutorCompletionService.submit(() -> {
+        int readCount = 0;
+        try {
+          for (int j = 0; j < numOfReadOperations; j++) {
+            readCount = getReadCount(readCount, "readPath");
+          }
+        } catch (IOException e) {
+          LOG.warn("Exception while listing keys/files ", e);
+        }
+        return readCount;
+      }));
+    }
+
+    int readResult = 0;
+    for (int i = 0; i < readFutures.size(); i++) {
+      try {
+        readResult += readExecutorCompletionService.take().get();
+      } catch (InterruptedException e) {
+        e.printStackTrace();
+      } catch (ExecutionException e) {
+        e.printStackTrace();
+      }
+    }
+    readService.shutdown();
+
+    return readResult;
+  }
+
+  protected abstract int getReadCount(int readCount, String readPath)
+      throws IOException;
+
+  protected int writeOperations(int keyCountForWrite) throws Exception {
+
+    // Start writeThreadCount (defaultValue = 10) concurrent write threads
+    // performing numOfWriteOperations (defaultValue = 10) iterations
+    // of write operations (createKeys(writePath) or
+    // createFiles(rootPath/writePath))
+    String writePath = createPath("writePath");
+
+    ExecutorService writeService =
+        Executors.newFixedThreadPool(writeThreadCount);
+    CompletionService<Integer> writeExecutorCompletionService =
+        new ExecutorCompletionService<>(writeService);
+    List<Future<Integer>> writeFutures = new ArrayList<>();
+    for (int i = 0; i < writeThreadCount; i++) {
+      writeFutures.add(writeExecutorCompletionService.submit(() -> {
+        int writeCount = 0;
+        try {
+          for (int j = 0; j < numOfWriteOperations; j++) {
+            create(writePath, keyCountForWrite);
+            writeCount++;
+          }
+        } catch (IOException e) {
+          LOG.warn("Exception while creating keys/files ", e);
+        }
+        return writeCount;
+      }));
+    }
+
+    int writeResult = 0;
+    for (int i = 0; i < writeFutures.size(); i++) {
+      try {
+        writeResult += writeExecutorCompletionService.take().get();
+      } catch (InterruptedException e) {

Review Comment:
   Thank you for the comment, I have removed the try-catch block.



-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


[GitHub] [ozone] neils-dev commented on a diff in pull request #3383: HDDS-6619. Add freon command to run r/w mix workload using ObjectStore APIs

Posted by GitBox <gi...@apache.org>.
neils-dev commented on code in PR #3383:
URL: https://github.com/apache/ozone/pull/3383#discussion_r869812856


##########
hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/freon/TestOmBucketReadWriteKeyOps.java:
##########
@@ -0,0 +1,304 @@
+/**
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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 org.apache.commons.io.FileUtils;
+import org.apache.hadoop.hdds.conf.OzoneConfiguration;
+import org.apache.hadoop.ozone.MiniOzoneCluster;
+
+import org.apache.hadoop.ozone.client.ObjectStore;
+import org.apache.hadoop.ozone.client.OzoneBucket;
+import org.apache.hadoop.ozone.client.OzoneClientFactory;
+import org.apache.hadoop.ozone.client.OzoneVolume;
+import org.apache.hadoop.ozone.client.OzoneKey;
+import org.apache.hadoop.ozone.om.OMConfigKeys;
+import org.apache.hadoop.ozone.om.helpers.BucketLayout;
+import org.apache.hadoop.ozone.om.lock.OMLockMetrics;
+import org.apache.ozone.test.GenericTestUtils;
+import org.apache.ratis.server.RaftServer;
+import org.apache.ratis.server.raftlog.RaftLog;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.slf4j.event.Level;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.Iterator;
+
+/**
+ * Test for OmBucketReadWriteKeyOps.
+ */
+public class TestOmBucketReadWriteKeyOps {
+
+  private String path;
+  private OzoneConfiguration conf = null;
+  private MiniOzoneCluster cluster = null;
+  private ObjectStore store = null;
+  private static final Logger LOG =
+      LoggerFactory.getLogger(TestOmBucketReadWriteKeyOps.class);
+
+  @Before
+  public void setup() {
+    path = GenericTestUtils
+        .getTempPath(TestHadoopDirTreeGenerator.class.getSimpleName());
+    GenericTestUtils.setLogLevel(RaftLog.LOG, Level.DEBUG);
+    GenericTestUtils.setLogLevel(RaftServer.LOG, Level.DEBUG);
+    File baseDir = new File(path);
+    baseDir.mkdirs();
+  }
+
+  /**
+   * Shutdown MiniDFSCluster.
+   */
+  private void shutdown() {
+    if (cluster != null) {
+      cluster.shutdown();
+    }
+  }
+
+  /**
+   * Create a MiniDFSCluster for testing.
+   *
+   * @throws IOException
+   */
+  private void startCluster() throws Exception {
+    conf = getOzoneConfiguration();
+    conf.set(OMConfigKeys.OZONE_DEFAULT_BUCKET_LAYOUT,
+        BucketLayout.OBJECT_STORE.name());
+    cluster = MiniOzoneCluster.newBuilder(conf).setNumDatanodes(5).build();
+    cluster.waitForClusterToBeReady();
+    cluster.waitTobeOutOfSafeMode();
+
+    store = OzoneClientFactory.getRpcClient(conf).getObjectStore();
+  }
+
+  protected OzoneConfiguration getOzoneConfiguration() {

Review Comment:
   Thanks @tanvipenumudy for the needed freon tests.  A few comments follow.
   Method `getOzoneConfiguration` need not be '_protected_'.  Can be limited to class and declared as _private_.



##########
hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/freon/AbstractOmBucketReadWriteOps.java:
##########
@@ -0,0 +1,35 @@
+package org.apache.hadoop.ozone.freon;

Review Comment:
   Missing _ASF_ Licence header?  Cut'n paste header.



##########
hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/freon/TestOmBucketReadWriteKeyOps.java:
##########
@@ -0,0 +1,304 @@
+/**
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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 org.apache.commons.io.FileUtils;
+import org.apache.hadoop.hdds.conf.OzoneConfiguration;
+import org.apache.hadoop.ozone.MiniOzoneCluster;
+
+import org.apache.hadoop.ozone.client.ObjectStore;
+import org.apache.hadoop.ozone.client.OzoneBucket;
+import org.apache.hadoop.ozone.client.OzoneClientFactory;
+import org.apache.hadoop.ozone.client.OzoneVolume;
+import org.apache.hadoop.ozone.client.OzoneKey;
+import org.apache.hadoop.ozone.om.OMConfigKeys;
+import org.apache.hadoop.ozone.om.helpers.BucketLayout;
+import org.apache.hadoop.ozone.om.lock.OMLockMetrics;
+import org.apache.ozone.test.GenericTestUtils;
+import org.apache.ratis.server.RaftServer;
+import org.apache.ratis.server.raftlog.RaftLog;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.slf4j.event.Level;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.Iterator;
+
+/**
+ * Test for OmBucketReadWriteKeyOps.
+ */
+public class TestOmBucketReadWriteKeyOps {
+
+  private String path;
+  private OzoneConfiguration conf = null;
+  private MiniOzoneCluster cluster = null;
+  private ObjectStore store = null;
+  private static final Logger LOG =
+      LoggerFactory.getLogger(TestOmBucketReadWriteKeyOps.class);
+
+  @Before
+  public void setup() {
+    path = GenericTestUtils
+        .getTempPath(TestHadoopDirTreeGenerator.class.getSimpleName());
+    GenericTestUtils.setLogLevel(RaftLog.LOG, Level.DEBUG);
+    GenericTestUtils.setLogLevel(RaftServer.LOG, Level.DEBUG);
+    File baseDir = new File(path);
+    baseDir.mkdirs();
+  }
+
+  /**
+   * Shutdown MiniDFSCluster.
+   */
+  private void shutdown() {
+    if (cluster != null) {
+      cluster.shutdown();
+    }
+  }
+
+  /**
+   * Create a MiniDFSCluster for testing.
+   *
+   * @throws IOException
+   */
+  private void startCluster() throws Exception {
+    conf = getOzoneConfiguration();
+    conf.set(OMConfigKeys.OZONE_DEFAULT_BUCKET_LAYOUT,
+        BucketLayout.OBJECT_STORE.name());
+    cluster = MiniOzoneCluster.newBuilder(conf).setNumDatanodes(5).build();
+    cluster.waitForClusterToBeReady();
+    cluster.waitTobeOutOfSafeMode();
+
+    store = OzoneClientFactory.getRpcClient(conf).getObjectStore();
+  }
+
+  protected OzoneConfiguration getOzoneConfiguration() {
+    return new OzoneConfiguration();
+  }
+
+  @Test
+  public void testOmBucketReadWriteKeyOps() throws Exception {
+    try {
+      startCluster();
+      FileOutputStream out = FileUtils.openOutputStream(new File(path,
+          "conf"));
+      cluster.getConf().writeXml(out);
+      out.getFD().sync();
+      out.close();
+
+      verifyFreonCommand(new ParameterBuilder().setTotalThreadCount(10)
+          .setNumOfReadOperations(10).setNumOfWriteOperations(5)
+          .setKeyCountForRead(10).setKeyCountForWrite(5));
+      verifyFreonCommand(
+          new ParameterBuilder().setVolumeName("vol2").setBucketName("bucket1")
+              .setTotalThreadCount(10).setNumOfReadOperations(10)
+              .setNumOfWriteOperations(5).setKeyCountForRead(10)
+              .setKeyCountForWrite(5));
+      verifyFreonCommand(
+          new ParameterBuilder().setVolumeName("vol3").setBucketName("bucket1")
+              .setTotalThreadCount(15).setNumOfReadOperations(5)
+              .setNumOfWriteOperations(3).setKeyCountForRead(5)
+              .setKeyCountForWrite(3));
+      verifyFreonCommand(
+          new ParameterBuilder().setVolumeName("vol4").setBucketName("bucket1")
+              .setTotalThreadCount(10).setNumOfReadOperations(5)
+              .setNumOfWriteOperations(3).setKeyCountForRead(5)
+              .setKeyCountForWrite(3).setKeySizeInBytes(64)
+              .setBufferSize(16));
+      verifyFreonCommand(
+          new ParameterBuilder().setVolumeName("vol5").setBucketName("bucket1")
+              .setTotalThreadCount(10).setNumOfReadOperations(5)
+              .setNumOfWriteOperations(0).setKeyCountForRead(5));
+      verifyFreonCommand(
+          new ParameterBuilder().setVolumeName("vol6").setBucketName("bucket1")
+              .setTotalThreadCount(20).setNumOfReadOperations(0)
+              .setNumOfWriteOperations(5).setKeyCountForRead(0)
+              .setKeyCountForWrite(5));
+
+    } finally {
+      shutdown();
+    }
+  }
+
+  private void verifyFreonCommand(ParameterBuilder parameterBuilder)
+      throws IOException {
+    store.createVolume(parameterBuilder.volumeName);
+    OzoneVolume volume = store.getVolume(parameterBuilder.volumeName);
+    volume.createBucket(parameterBuilder.bucketName);
+    OzoneBucket bucket = store.getVolume(parameterBuilder.volumeName)

Review Comment:
   We have the volume already from line 144.  If that's the case, then it can be reused in line 146 instead of needlessly calling `store.getVolume(..) `again, so line 146 can be rewritten as:
   `OzoneBucket bucket = volume.getBucket(...);`



-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


[GitHub] [ozone] rakeshadr commented on a diff in pull request #3383: HDDS-6619. Add freon command to run r/w mix workload using ObjectStore APIs

Posted by GitBox <gi...@apache.org>.
rakeshadr commented on code in PR #3383:
URL: https://github.com/apache/ozone/pull/3383#discussion_r871201848


##########
hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/freon/AbstractOmBucketReadWriteOps.java:
##########
@@ -0,0 +1,241 @@
+/**
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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 org.apache.commons.lang3.RandomStringUtils;
+import org.apache.hadoop.hdds.conf.OzoneConfiguration;
+import org.apache.hadoop.ozone.OzoneConsts;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import picocli.CommandLine.Option;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.CompletionService;
+import java.util.concurrent.ExecutorCompletionService;
+
+/**
+ * Abstract class for OmBucketReadWriteFileOps/KeyOps Freon class
+ * implementations.
+ */
+public abstract class AbstractOmBucketReadWriteOps extends BaseFreonGenerator
+    implements Callable<Void> {
+
+  private static final Logger LOG =
+      LoggerFactory.getLogger(AbstractOmBucketReadWriteOps.class);
+
+  @Option(names = {"-g", "--size"},
+      description = "Generated data size (in bytes) of each key/file to be " +
+          "written.",
+      defaultValue = "256")
+  private long sizeInBytes;
+
+  @Option(names = {"--buffer"},
+      description = "Size of buffer used for generating the key/file content.",
+      defaultValue = "64")
+  private int bufferSize;
+
+  @Option(names = {"-l", "--name-len"},
+      description = "Length of the random name of path you want to create.",
+      defaultValue = "10")
+  private int length;
+
+  @Option(names = {"-c", "--total-thread-count"},
+      description = "Total number of threads to be executed.",
+      defaultValue = "100")
+  private int totalThreadCount;
+
+  @Option(names = {"-T", "--read-thread-percentage"},
+      description = "Percentage of the total number of threads to be " +
+          "allocated for read operations. The remaining percentage of " +
+          "threads will be allocated for write operations.",
+      defaultValue = "90")
+  private int readThreadPercentage;
+
+  @Option(names = {"-R", "--num-of-read-operations"},
+      description = "Number of read operations to be performed by each thread.",
+      defaultValue = "50")
+  private int numOfReadOperations;
+
+  @Option(names = {"-W", "--num-of-write-operations"},
+      description = "Number of write operations to be performed by each " +
+          "thread.",
+      defaultValue = "10")
+  private int numOfWriteOperations;
+
+  private OzoneConfiguration ozoneConfiguration;
+  private Timer timer;
+  private ContentGenerator contentGenerator;
+  private int readThreadCount;
+  private int writeThreadCount;
+
+  protected abstract void display();
+
+  protected abstract void initialize(OzoneConfiguration configuration)
+      throws Exception;
+
+  @Override
+  public Void call() throws Exception {
+    init();
+
+    readThreadCount = (readThreadPercentage * totalThreadCount) / 100;
+    writeThreadCount = totalThreadCount - readThreadCount;
+
+    display();
+    print("SizeInBytes: " + sizeInBytes);
+    print("bufferSize: " + bufferSize);
+    print("totalThreadCount: " + totalThreadCount);
+    print("readThreadPercentage: " + readThreadPercentage);
+    print("writeThreadPercentage: " + (100 - readThreadPercentage));
+    print("readThreadCount: " + readThreadCount);
+    print("writeThreadCount: " + writeThreadCount);
+    print("numOfReadOperations: " + numOfReadOperations);
+    print("numOfWriteOperations: " + numOfWriteOperations);
+
+    ozoneConfiguration = createOzoneConfiguration();
+    contentGenerator = new ContentGenerator(sizeInBytes, bufferSize);
+    timer = getMetrics().timer("om-bucket-read-write-ops");
+
+    initialize(ozoneConfiguration);
+
+    return null;
+  }
+
+  protected abstract String createPath(String path) throws IOException;
+
+  protected int readOperations(int keyCountForRead) throws Exception {
+
+    // Create keyCountForRead/fileCountForRead (defaultValue = 1000) keys/files
+    // under rootPath/readPath
+    String readPath = createPath("readPath");
+    create(readPath, keyCountForRead);
+
+    // Start readThreadCount (defaultValue = 90) concurrent read threads
+    // performing numOfReadOperations (defaultValue = 50) iterations
+    // of read operations (bucket.listKeys(readPath) or
+    // fileSystem.listStatus(rootPath/readPath))
+    ExecutorService readService = Executors.newFixedThreadPool(readThreadCount);
+    CompletionService<Integer> readExecutorCompletionService =
+        new ExecutorCompletionService<>(readService);
+    List<Future<Integer>> readFutures = new ArrayList<>();
+    for (int i = 0; i < readThreadCount; i++) {
+      readFutures.add(readExecutorCompletionService.submit(() -> {
+        int readCount = 0;
+        try {
+          for (int j = 0; j < numOfReadOperations; j++) {
+            readCount = getReadCount(readCount, "readPath");
+          }
+        } catch (IOException e) {
+          LOG.warn("Exception while listing keys/files ", e);
+        }
+        return readCount;
+      }));
+    }
+
+    int readResult = 0;
+    for (int i = 0; i < readFutures.size(); i++) {
+      try {
+        readResult += readExecutorCompletionService.take().get();

Review Comment:
   @tanvipenumudy we don't need this try-catch block. Lets throw exception back to the caller.
   
      ```
      } catch (InterruptedException e) {
           e.printStackTrace();
         } catch (ExecutionException e) {
           e.printStackTrace();
         }
   ```



##########
hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/freon/AbstractOmBucketReadWriteOps.java:
##########
@@ -0,0 +1,241 @@
+/**
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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 org.apache.commons.lang3.RandomStringUtils;
+import org.apache.hadoop.hdds.conf.OzoneConfiguration;
+import org.apache.hadoop.ozone.OzoneConsts;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import picocli.CommandLine.Option;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.CompletionService;
+import java.util.concurrent.ExecutorCompletionService;
+
+/**
+ * Abstract class for OmBucketReadWriteFileOps/KeyOps Freon class
+ * implementations.
+ */
+public abstract class AbstractOmBucketReadWriteOps extends BaseFreonGenerator
+    implements Callable<Void> {
+
+  private static final Logger LOG =
+      LoggerFactory.getLogger(AbstractOmBucketReadWriteOps.class);
+
+  @Option(names = {"-g", "--size"},
+      description = "Generated data size (in bytes) of each key/file to be " +
+          "written.",
+      defaultValue = "256")
+  private long sizeInBytes;
+
+  @Option(names = {"--buffer"},
+      description = "Size of buffer used for generating the key/file content.",
+      defaultValue = "64")
+  private int bufferSize;
+
+  @Option(names = {"-l", "--name-len"},
+      description = "Length of the random name of path you want to create.",
+      defaultValue = "10")
+  private int length;
+
+  @Option(names = {"-c", "--total-thread-count"},
+      description = "Total number of threads to be executed.",
+      defaultValue = "100")
+  private int totalThreadCount;
+
+  @Option(names = {"-T", "--read-thread-percentage"},
+      description = "Percentage of the total number of threads to be " +
+          "allocated for read operations. The remaining percentage of " +
+          "threads will be allocated for write operations.",
+      defaultValue = "90")
+  private int readThreadPercentage;
+
+  @Option(names = {"-R", "--num-of-read-operations"},
+      description = "Number of read operations to be performed by each thread.",
+      defaultValue = "50")
+  private int numOfReadOperations;
+
+  @Option(names = {"-W", "--num-of-write-operations"},
+      description = "Number of write operations to be performed by each " +
+          "thread.",
+      defaultValue = "10")
+  private int numOfWriteOperations;
+
+  private OzoneConfiguration ozoneConfiguration;
+  private Timer timer;
+  private ContentGenerator contentGenerator;
+  private int readThreadCount;
+  private int writeThreadCount;
+
+  protected abstract void display();
+
+  protected abstract void initialize(OzoneConfiguration configuration)
+      throws Exception;
+
+  @Override
+  public Void call() throws Exception {
+    init();
+
+    readThreadCount = (readThreadPercentage * totalThreadCount) / 100;
+    writeThreadCount = totalThreadCount - readThreadCount;
+
+    display();
+    print("SizeInBytes: " + sizeInBytes);
+    print("bufferSize: " + bufferSize);
+    print("totalThreadCount: " + totalThreadCount);
+    print("readThreadPercentage: " + readThreadPercentage);
+    print("writeThreadPercentage: " + (100 - readThreadPercentage));
+    print("readThreadCount: " + readThreadCount);
+    print("writeThreadCount: " + writeThreadCount);
+    print("numOfReadOperations: " + numOfReadOperations);
+    print("numOfWriteOperations: " + numOfWriteOperations);
+
+    ozoneConfiguration = createOzoneConfiguration();
+    contentGenerator = new ContentGenerator(sizeInBytes, bufferSize);
+    timer = getMetrics().timer("om-bucket-read-write-ops");
+
+    initialize(ozoneConfiguration);
+
+    return null;
+  }
+
+  protected abstract String createPath(String path) throws IOException;
+
+  protected int readOperations(int keyCountForRead) throws Exception {
+
+    // Create keyCountForRead/fileCountForRead (defaultValue = 1000) keys/files
+    // under rootPath/readPath
+    String readPath = createPath("readPath");
+    create(readPath, keyCountForRead);
+
+    // Start readThreadCount (defaultValue = 90) concurrent read threads
+    // performing numOfReadOperations (defaultValue = 50) iterations
+    // of read operations (bucket.listKeys(readPath) or
+    // fileSystem.listStatus(rootPath/readPath))
+    ExecutorService readService = Executors.newFixedThreadPool(readThreadCount);
+    CompletionService<Integer> readExecutorCompletionService =
+        new ExecutorCompletionService<>(readService);
+    List<Future<Integer>> readFutures = new ArrayList<>();
+    for (int i = 0; i < readThreadCount; i++) {
+      readFutures.add(readExecutorCompletionService.submit(() -> {
+        int readCount = 0;
+        try {
+          for (int j = 0; j < numOfReadOperations; j++) {
+            readCount = getReadCount(readCount, "readPath");
+          }
+        } catch (IOException e) {
+          LOG.warn("Exception while listing keys/files ", e);
+        }
+        return readCount;
+      }));
+    }
+
+    int readResult = 0;
+    for (int i = 0; i < readFutures.size(); i++) {
+      try {
+        readResult += readExecutorCompletionService.take().get();
+      } catch (InterruptedException e) {
+        e.printStackTrace();
+      } catch (ExecutionException e) {
+        e.printStackTrace();
+      }
+    }
+    readService.shutdown();
+
+    return readResult;
+  }
+
+  protected abstract int getReadCount(int readCount, String readPath)
+      throws IOException;
+
+  protected int writeOperations(int keyCountForWrite) throws Exception {
+
+    // Start writeThreadCount (defaultValue = 10) concurrent write threads
+    // performing numOfWriteOperations (defaultValue = 10) iterations
+    // of write operations (createKeys(writePath) or
+    // createFiles(rootPath/writePath))
+    String writePath = createPath("writePath");
+
+    ExecutorService writeService =
+        Executors.newFixedThreadPool(writeThreadCount);
+    CompletionService<Integer> writeExecutorCompletionService =
+        new ExecutorCompletionService<>(writeService);
+    List<Future<Integer>> writeFutures = new ArrayList<>();
+    for (int i = 0; i < writeThreadCount; i++) {
+      writeFutures.add(writeExecutorCompletionService.submit(() -> {
+        int writeCount = 0;
+        try {
+          for (int j = 0; j < numOfWriteOperations; j++) {
+            create(writePath, keyCountForWrite);
+            writeCount++;
+          }
+        } catch (IOException e) {
+          LOG.warn("Exception while creating keys/files ", e);
+        }
+        return writeCount;
+      }));
+    }
+
+    int writeResult = 0;
+    for (int i = 0; i < writeFutures.size(); i++) {
+      try {
+        writeResult += writeExecutorCompletionService.take().get();
+      } catch (InterruptedException e) {

Review Comment:
   @tanvipenumudy we don't need this try-catch block. Lets throw exception back to the caller.
   
   ```
   } catch (InterruptedException e) {
        e.printStackTrace();
      } catch (ExecutionException e) {
        e.printStackTrace();
      }
   ```



-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


[GitHub] [ozone] tanvipenumudy commented on a diff in pull request #3383: HDDS-6619. Add freon command to run r/w mix workload using ObjectStore APIs

Posted by GitBox <gi...@apache.org>.
tanvipenumudy commented on code in PR #3383:
URL: https://github.com/apache/ozone/pull/3383#discussion_r871209967


##########
hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/freon/OmBucketReadWriteKeyOps.java:
##########
@@ -0,0 +1,309 @@
+/**
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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 org.apache.commons.lang3.RandomStringUtils;
+import org.apache.hadoop.hdds.cli.HddsVersionProvider;
+import org.apache.hadoop.hdds.client.ReplicationConfig;
+import org.apache.hadoop.hdds.conf.OzoneConfiguration;
+import org.apache.hadoop.ozone.OzoneConsts;
+import org.apache.hadoop.ozone.client.OzoneBucket;
+import org.apache.hadoop.ozone.client.OzoneClient;
+import org.apache.hadoop.ozone.client.OzoneKey;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import picocli.CommandLine;
+import picocli.CommandLine.Command;
+import picocli.CommandLine.Option;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.CompletionService;
+import java.util.concurrent.ExecutorCompletionService;
+
+/**
+ * Synthetic read/write key operations workload generator tool.
+ */
+@Command(name = "obrwk",
+    aliases = "om-bucket-read-write-key-ops",
+    description = "Creates keys, performs respective read/write " +
+        "operations to measure lock performance.",
+    versionProvider = HddsVersionProvider.class,
+    mixinStandardHelpOptions = true,
+    showDefaultValues = true)
+
+public class OmBucketReadWriteKeyOps extends BaseFreonGenerator
+    implements Callable<Void> {
+
+  private static final Logger LOG =
+      LoggerFactory.getLogger(OmBucketReadWriteKeyOps.class);
+
+  @Option(names = {"-v", "--volume"},
+      description = "Name of the volume which contains the test data. Will be"
+          + " created if missing.",
+      defaultValue = "vol1")
+  private String volumeName;
+
+  @Option(names = {"-b", "--bucket"},
+      description = "Name of the bucket which contains the test data. Will be"
+          + " created if missing.",
+      defaultValue = "bucket1")
+  private String bucketName;
+
+  @Option(names = {"-k", "--key-count-for-read"},
+      description = "Number of keys to be created for read operations.",
+      defaultValue = "100")
+  private int keyCountForRead;
+
+  @Option(names = {"-w", "--key-count-for-write"},
+      description = "Number of keys to be created for write operations.",
+      defaultValue = "10")
+  private int keyCountForWrite;
+
+  @Option(names = {"-g", "--key-size"},
+      description = "Size of the generated key (in bytes).",
+      defaultValue = "256")
+  private long keySizeInBytes;
+
+  @Option(names = {"-B", "--buffer"},
+      description = "Size of buffer used to generated the key content.",
+      defaultValue = "64")
+  private int bufferSize;
+
+  @Option(names = {"-l", "--name-len"},
+      description = "Length of the random name of path you want to create.",
+      defaultValue = "10")
+  private int length;
+
+  @Option(names = {"-c", "--total-thread-count"},
+      description = "Total number of threads to be executed.",
+      defaultValue = "100")
+  private int totalThreadCount;
+
+  @Option(names = {"-T", "--read-thread-percentage"},
+      description = "Percentage of the total number of threads to be " +
+          "allocated for read operations. The remaining percentage of " +
+          "threads will be allocated for write operations.",
+      defaultValue = "90")
+  private int readThreadPercentage;
+
+  @Option(names = {"-R", "--num-of-read-operations"},
+      description = "Number of read operations to be performed by each thread.",
+      defaultValue = "50")
+  private int numOfReadOperations;
+
+  @Option(names = {"-W", "--num-of-write-operations"},
+      description = "Number of write operations to be performed by each " +
+          "thread.",
+      defaultValue = "10")
+  private int numOfWriteOperations;
+
+  @Option(names = {"-o", "--om-service-id"},
+      description = "OM Service ID"
+  )
+  private String omServiceID = null;
+
+  @CommandLine.Mixin
+  private FreonReplicationOptions replication;
+
+  private Timer timer;
+
+  private ContentGenerator contentGenerator;
+
+  private Map<String, String> metadata;
+
+  private ReplicationConfig replicationConfig;
+
+  private OzoneBucket bucket;
+
+  private int readThreadCount;
+  private int writeThreadCount;
+
+  @Override
+  public Void call() throws Exception {
+    init();
+
+    readThreadCount = (readThreadPercentage * totalThreadCount) / 100;
+    writeThreadCount = totalThreadCount - readThreadCount;
+
+    print("volumeName: " + volumeName);
+    print("bucketName: " + bucketName);
+    print("keyCountForRead: " + keyCountForRead);
+    print("keyCountForWrite: " + keyCountForWrite);
+    print("keySizeInBytes: " + keySizeInBytes);
+    print("bufferSize: " + bufferSize);
+    print("totalThreadCount: " + totalThreadCount);
+    print("readThreadPercentage: " + readThreadPercentage);
+    print("writeThreadPercentage: " + (100 - readThreadPercentage));
+    print("readThreadCount: " + readThreadCount);
+    print("writeThreadCount: " + writeThreadCount);
+    print("numOfReadOperations: " + numOfReadOperations);
+    print("numOfWriteOperations: " + numOfWriteOperations);
+    print("omServiceID: " + omServiceID);
+
+    OzoneConfiguration ozoneConfiguration = createOzoneConfiguration();
+    replicationConfig = replication.fromParamsOrConfig(ozoneConfiguration);
+
+    contentGenerator = new ContentGenerator(keySizeInBytes, bufferSize);
+    metadata = new HashMap<>();
+
+    try (OzoneClient rpcClient = createOzoneClient(omServiceID,
+        ozoneConfiguration)) {
+      ensureVolumeAndBucketExist(rpcClient, volumeName, bucketName);
+      bucket = rpcClient.getObjectStore().getVolume(volumeName)
+          .getBucket(bucketName);
+
+      timer = getMetrics().timer("key-create");
+
+      runTests(this::mainMethod);
+    }
+
+    return null;
+  }
+
+  private void mainMethod(long counter) throws Exception {
+
+    int readResult = readOperations();
+    int writeResult = writeOperations();
+
+    print("Total Keys Read: " + readResult);
+    print("Total Keys Written: " + writeResult * keyCountForWrite);
+
+    // TODO: print read/write lock metrics (HDDS-6435, HDDS-6436).
+  }
+
+  private int readOperations() throws Exception {
+
+    // Create keyCountForRead (defaultValue = 100) keys under
+    // rootPath/readPath
+    String readPath = "".concat(OzoneConsts.OM_KEY_PREFIX).concat("readPath");
+    createKeys(readPath, keyCountForRead);
+
+    // Start readThreadCount (defaultValue = 90) concurrent read threads
+    // performing numOfReadOperations (defaultValue = 50) iterations
+    // of read operations (bucket.listKeys(readPath))
+    ExecutorService readService = Executors.newFixedThreadPool(readThreadCount);

Review Comment:
   Thank you for the suggestions! I have made the necessary changes!



-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


[GitHub] [ozone] neils-dev commented on pull request #3383: HDDS-6619. Add freon command to run r/w mix workload using ObjectStore APIs

Posted by GitBox <gi...@apache.org>.
neils-dev commented on PR #3383:
URL: https://github.com/apache/ozone/pull/3383#issuecomment-1125248639

   Thanks @tanvipenumudy!


-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


[GitHub] [ozone] rakeshadr commented on a diff in pull request #3383: HDDS-6619. Add freon command to run r/w mix workload using ObjectStore APIs

Posted by GitBox <gi...@apache.org>.
rakeshadr commented on code in PR #3383:
URL: https://github.com/apache/ozone/pull/3383#discussion_r867761269


##########
hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/freon/OmBucketReadWriteKeyOps.java:
##########
@@ -0,0 +1,309 @@
+/**
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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 org.apache.commons.lang3.RandomStringUtils;
+import org.apache.hadoop.hdds.cli.HddsVersionProvider;
+import org.apache.hadoop.hdds.client.ReplicationConfig;
+import org.apache.hadoop.hdds.conf.OzoneConfiguration;
+import org.apache.hadoop.ozone.OzoneConsts;
+import org.apache.hadoop.ozone.client.OzoneBucket;
+import org.apache.hadoop.ozone.client.OzoneClient;
+import org.apache.hadoop.ozone.client.OzoneKey;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import picocli.CommandLine;
+import picocli.CommandLine.Command;
+import picocli.CommandLine.Option;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.CompletionService;
+import java.util.concurrent.ExecutorCompletionService;
+
+/**
+ * Synthetic read/write key operations workload generator tool.
+ */
+@Command(name = "obrwk",
+    aliases = "om-bucket-read-write-key-ops",
+    description = "Creates keys, performs respective read/write " +
+        "operations to measure lock performance.",
+    versionProvider = HddsVersionProvider.class,
+    mixinStandardHelpOptions = true,
+    showDefaultValues = true)
+
+public class OmBucketReadWriteKeyOps extends BaseFreonGenerator
+    implements Callable<Void> {
+
+  private static final Logger LOG =
+      LoggerFactory.getLogger(OmBucketReadWriteKeyOps.class);
+
+  @Option(names = {"-v", "--volume"},
+      description = "Name of the volume which contains the test data. Will be"
+          + " created if missing.",
+      defaultValue = "vol1")
+  private String volumeName;
+
+  @Option(names = {"-b", "--bucket"},
+      description = "Name of the bucket which contains the test data. Will be"
+          + " created if missing.",
+      defaultValue = "bucket1")
+  private String bucketName;
+
+  @Option(names = {"-k", "--key-count-for-read"},
+      description = "Number of keys to be created for read operations.",
+      defaultValue = "100")
+  private int keyCountForRead;
+
+  @Option(names = {"-w", "--key-count-for-write"},
+      description = "Number of keys to be created for write operations.",
+      defaultValue = "10")
+  private int keyCountForWrite;
+
+  @Option(names = {"-g", "--key-size"},
+      description = "Size of the generated key (in bytes).",
+      defaultValue = "256")
+  private long keySizeInBytes;
+
+  @Option(names = {"-B", "--buffer"},
+      description = "Size of buffer used to generated the key content.",
+      defaultValue = "64")
+  private int bufferSize;
+
+  @Option(names = {"-l", "--name-len"},
+      description = "Length of the random name of path you want to create.",
+      defaultValue = "10")
+  private int length;
+
+  @Option(names = {"-c", "--total-thread-count"},
+      description = "Total number of threads to be executed.",
+      defaultValue = "100")
+  private int totalThreadCount;
+
+  @Option(names = {"-T", "--read-thread-percentage"},
+      description = "Percentage of the total number of threads to be " +
+          "allocated for read operations. The remaining percentage of " +
+          "threads will be allocated for write operations.",
+      defaultValue = "90")
+  private int readThreadPercentage;
+
+  @Option(names = {"-R", "--num-of-read-operations"},
+      description = "Number of read operations to be performed by each thread.",
+      defaultValue = "50")
+  private int numOfReadOperations;
+
+  @Option(names = {"-W", "--num-of-write-operations"},
+      description = "Number of write operations to be performed by each " +
+          "thread.",
+      defaultValue = "10")
+  private int numOfWriteOperations;
+
+  @Option(names = {"-o", "--om-service-id"},
+      description = "OM Service ID"
+  )
+  private String omServiceID = null;
+
+  @CommandLine.Mixin
+  private FreonReplicationOptions replication;
+
+  private Timer timer;
+
+  private ContentGenerator contentGenerator;
+
+  private Map<String, String> metadata;
+
+  private ReplicationConfig replicationConfig;
+
+  private OzoneBucket bucket;
+
+  private int readThreadCount;
+  private int writeThreadCount;
+
+  @Override
+  public Void call() throws Exception {
+    init();
+
+    readThreadCount = (readThreadPercentage * totalThreadCount) / 100;
+    writeThreadCount = totalThreadCount - readThreadCount;
+
+    print("volumeName: " + volumeName);
+    print("bucketName: " + bucketName);
+    print("keyCountForRead: " + keyCountForRead);
+    print("keyCountForWrite: " + keyCountForWrite);
+    print("keySizeInBytes: " + keySizeInBytes);
+    print("bufferSize: " + bufferSize);
+    print("totalThreadCount: " + totalThreadCount);
+    print("readThreadPercentage: " + readThreadPercentage);
+    print("writeThreadPercentage: " + (100 - readThreadPercentage));
+    print("readThreadCount: " + readThreadCount);
+    print("writeThreadCount: " + writeThreadCount);
+    print("numOfReadOperations: " + numOfReadOperations);
+    print("numOfWriteOperations: " + numOfWriteOperations);
+    print("omServiceID: " + omServiceID);
+
+    OzoneConfiguration ozoneConfiguration = createOzoneConfiguration();
+    replicationConfig = replication.fromParamsOrConfig(ozoneConfiguration);
+
+    contentGenerator = new ContentGenerator(keySizeInBytes, bufferSize);
+    metadata = new HashMap<>();
+
+    try (OzoneClient rpcClient = createOzoneClient(omServiceID,
+        ozoneConfiguration)) {
+      ensureVolumeAndBucketExist(rpcClient, volumeName, bucketName);
+      bucket = rpcClient.getObjectStore().getVolume(volumeName)
+          .getBucket(bucketName);
+
+      timer = getMetrics().timer("key-create");
+
+      runTests(this::mainMethod);
+    }
+
+    return null;
+  }
+
+  private void mainMethod(long counter) throws Exception {
+
+    int readResult = readOperations();
+    int writeResult = writeOperations();
+
+    print("Total Keys Read: " + readResult);
+    print("Total Keys Written: " + writeResult * keyCountForWrite);
+
+    // TODO: print read/write lock metrics (HDDS-6435, HDDS-6436).
+  }
+
+  private int readOperations() throws Exception {
+
+    // Create keyCountForRead (defaultValue = 100) keys under
+    // rootPath/readPath
+    String readPath = "".concat(OzoneConsts.OM_KEY_PREFIX).concat("readPath");
+    createKeys(readPath, keyCountForRead);
+
+    // Start readThreadCount (defaultValue = 90) concurrent read threads
+    // performing numOfReadOperations (defaultValue = 50) iterations
+    // of read operations (bucket.listKeys(readPath))
+    ExecutorService readService = Executors.newFixedThreadPool(readThreadCount);

Review Comment:
   It looks like `OmBucketReadWriteFileOps` and `OmBucketReadWriteKeyOps` has similar behaviors except the FS and ObjectStore specific apis. How about to keep the common code to an abstract class and expose specific functions. Those functions can be overridden by `fileOps` and `keyOps` specific classes.
   
   ```
   AbstractOmBucketReadWriteOps 
       | -> OmBucketReadWriteFileOps : Here need to initialize fs and override r/w methods
       | -> OmBucketReadWriteKeyOps : Here need to initialize obs and override r/w methods
   ```
   ```
   
   abstract class AbstractOmBucketReadWriteOps  extends BaseFreonGenerator
       implements Callable<Void>{
   
   // Here we can keep all the common functions
   
   // Then expose abstract methods like,
   
   // for specific write logic
   protected createKey(String path);
   
   // for specific read logic
   protected int readOperations();
   
   }
   ```



-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


[GitHub] [ozone] rakeshadr merged pull request #3383: HDDS-6619. Add freon command to run r/w mix workload using ObjectStore APIs

Posted by GitBox <gi...@apache.org>.
rakeshadr merged PR #3383:
URL: https://github.com/apache/ozone/pull/3383


-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org