You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by sh...@apache.org on 2019/04/16 13:38:22 UTC

[hadoop] branch trunk updated: HDDS-1380. Add functonality to write from multiple clients in MiniOzoneChaosCluster. Contributed by Shashikant Banerjee.

This is an automated email from the ASF dual-hosted git repository.

shashikant pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/hadoop.git


The following commit(s) were added to refs/heads/trunk by this push:
     new bfcb653  HDDS-1380. Add functonality to write from multiple clients in MiniOzoneChaosCluster. Contributed by Shashikant Banerjee.
bfcb653 is described below

commit bfcb6534cd59b8e3d20f335d5833202c45b95a9c
Author: Shashikant Banerjee <sh...@apache.org>
AuthorDate: Tue Apr 16 18:52:07 2019 +0530

    HDDS-1380. Add functonality to write from multiple clients in MiniOzoneChaosCluster. Contributed by Shashikant Banerjee.
---
 .../org/apache/hadoop/ozone/MiniOzoneLoadGenerator.java    | 13 ++++++++-----
 .../org/apache/hadoop/ozone/TestMiniChaosOzoneCluster.java | 14 +++++++++++---
 2 files changed, 19 insertions(+), 8 deletions(-)

diff --git a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/MiniOzoneLoadGenerator.java b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/MiniOzoneLoadGenerator.java
index 005a528..3623747 100644
--- a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/MiniOzoneLoadGenerator.java
+++ b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/MiniOzoneLoadGenerator.java
@@ -56,10 +56,11 @@ public class MiniOzoneLoadGenerator {
 
   private AtomicBoolean isWriteThreadRunning;
 
-  private final OzoneBucket ozoneBucket;
+  private final List<OzoneBucket> ozoneBuckets;
 
-  MiniOzoneLoadGenerator(OzoneBucket bucket, int numThreads, int numBuffers) {
-    this.ozoneBucket = bucket;
+  MiniOzoneLoadGenerator(List<OzoneBucket> bucket, int numThreads,
+      int numBuffers) {
+    this.ozoneBuckets = bucket;
     this.numWriteThreads = numThreads;
     this.numBuffers = numBuffers;
     this.writeExecutor = new ThreadPoolExecutor(numThreads, numThreads, 100,
@@ -94,7 +95,9 @@ public class MiniOzoneLoadGenerator {
       int bufferCapacity = buffer.capacity();
 
       String keyName = threadName + "-" + index;
-      try (OzoneOutputStream stream = ozoneBucket.createKey(keyName,
+      OzoneBucket bucket =
+          ozoneBuckets.get((int) (Math.random() * ozoneBuckets.size()));
+      try (OzoneOutputStream stream = bucket.createKey(keyName,
           bufferCapacity, ReplicationType.RATIS, ReplicationFactor.THREE,
           new HashMap<>())) {
         stream.write(buffer.array());
@@ -106,7 +109,7 @@ public class MiniOzoneLoadGenerator {
         //  to closed container. add a break here once that is fixed.
       }
 
-      try (OzoneInputStream stream = ozoneBucket.readKey(keyName)) {
+      try (OzoneInputStream stream = bucket.readKey(keyName)) {
         byte[] readBuffer = new byte[bufferCapacity];
         int readLen = stream.read(readBuffer);
 
diff --git a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/TestMiniChaosOzoneCluster.java b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/TestMiniChaosOzoneCluster.java
index a979c40..8bc3a52 100644
--- a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/TestMiniChaosOzoneCluster.java
+++ b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/TestMiniChaosOzoneCluster.java
@@ -29,7 +29,8 @@ import picocli.CommandLine.Command;
 import picocli.CommandLine.Option;
 import picocli.CommandLine;
 
-
+import java.util.ArrayList;
+import java.util.List;
 import java.util.concurrent.TimeUnit;
 
 /**
@@ -55,6 +56,10 @@ public class TestMiniChaosOzoneCluster implements Runnable {
       description = "total run time")
   private static int numMinutes = 1440; // 1 day by default
 
+  @Option(names = {"-n", "--numClients"},
+      description = "no of clients writing to OM")
+  private static int numClients = 3;
+
   @Option(names = {"-i", "--failureInterval"},
       description = "time between failure events in seconds")
   private static int failureInterval = 5; // 5 second period between failures.
@@ -74,9 +79,12 @@ public class TestMiniChaosOzoneCluster implements Runnable {
     store.createVolume(volumeName);
     OzoneVolume volume = store.getVolume(volumeName);
     volume.createBucket(bucketName);
-    OzoneBucket ozoneBucket = volume.getBucket(bucketName);
+    List<OzoneBucket> ozoneBuckets = new ArrayList<>(numClients);
+    for (int i = 0; i < numClients; i++) {
+      ozoneBuckets.add(volume.getBucket(bucketName));
+    }
     loadGenerator =
-        new MiniOzoneLoadGenerator(ozoneBucket, numThreads, numBuffers);
+        new MiniOzoneLoadGenerator(ozoneBuckets, numThreads, numBuffers);
   }
 
   /**


---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org