You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@hbase.apache.org by GitBox <gi...@apache.org> on 2020/07/10 12:50:54 UTC

[GitHub] [hbase] virajjasani commented on a change in pull request #2000: HBASE-24658 Update PolicyBasedChaosMonkey to handle uncaught exceptions

virajjasani commented on a change in pull request #2000:
URL: https://github.com/apache/hbase/pull/2000#discussion_r452815115



##########
File path: hbase-it/src/test/java/org/apache/hadoop/hbase/chaos/monkies/PolicyBasedChaosMonkey.java
##########
@@ -38,14 +42,16 @@
 
   private static final Logger LOG = LoggerFactory.getLogger(PolicyBasedChaosMonkey.class);

Review comment:
       nit: redundant

##########
File path: hbase-it/src/test/java/org/apache/hadoop/hbase/chaos/monkies/PolicyBasedChaosMonkey.java
##########
@@ -60,19 +66,30 @@ public PolicyBasedChaosMonkey(IntegrationTestingUtility util, Collection<Policy>
   }
 
   public PolicyBasedChaosMonkey(Properties monkeyProps, IntegrationTestingUtility util,
-    Policy... policies) {
-    this.monkeyProps = monkeyProps;
-    this.util = util;
-    this.policies = policies;
+    Collection<Policy> policies) {
+    this(monkeyProps, util, policies.toArray(new Policy[0]));
   }
 
   public PolicyBasedChaosMonkey(Properties monkeyProps, IntegrationTestingUtility util,
-    Collection<Policy> policies) {
+    Policy... policies) {
     this.monkeyProps = monkeyProps;
-    this.util = util;
-    this.policies = policies.toArray(new Policy[policies.size()]);
+    this.util = Objects.requireNonNull(util);
+    this.policies = Objects.requireNonNull(policies);
+    if (policies.length == 0) {
+      throw new IllegalArgumentException("policies may not be empty");
+    }
+    this.monkeyThreadPool = buildMonkeyThreadPool(policies.length);
   }
 
+  private static ExecutorService buildMonkeyThreadPool(final int size) {
+    return Executors.newFixedThreadPool(size, new ThreadFactoryBuilder()

Review comment:
       Would you prefer using our internal 
   `Threads.newDaemonThreadFactory(String prefix, UncaughtExceptionHandler handler)` ?




----------------------------------------------------------------
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:
users@infra.apache.org