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_r394942892
 
 

 ##########
 File path: 
hadoop-ozone/fault-injection-test/mini-chaos-tests/src/test/java/org/apache/hadoop/ozone/loadgenerators/LoadExecutors.java
 ##########
 @@ -0,0 +1,81 @@
+/**
+ * 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.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.ArrayBlockingQueue;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.ThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * Load executors for Ozone, this class provides a plugable
+ * executor for different load generators.
+ */
+public class LoadExecutors {
+  private static final Logger LOG =
+      LoggerFactory.getLogger(LoadExecutors.class);
+
+  private final LoadGenerator generator;
+  private final int numThreads;
+  private final ThreadPoolExecutor executor;
+  private final List<CompletableFuture<Void>> futures = new ArrayList<>();
+
+  public LoadExecutors(int numThreads, LoadGenerator generator) {
+    this.numThreads = numThreads;
+    this.generator = generator;
+    this.executor = new ThreadPoolExecutor(numThreads, numThreads,
+        100, TimeUnit.SECONDS, new ArrayBlockingQueue<>(1024),
+        new ThreadPoolExecutor.CallerRunsPolicy());
 
 Review comment:
   Since the number of threads (both core and max) and number of tasks is the 
same, do we need to specify keepAliveTime, queue limit and policy?  I don't 
think these parameters will be applied in any case.  I think using 
`Executors.newFixedThreadPool(numThreads)` would be simpler.  Sure, 
`ExecutorService` provides no way to prestart threads, but this is not a 
short-running performance test, so the overhead of starting threads as tasks 
are added does not seem to matter.

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