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 2019/11/01 17:36:28 UTC

[GitHub] [hbase] bharathv commented on a change in pull request #782: HBASE-23241 TestExecutorService sometimes fail

bharathv commented on a change in pull request #782: HBASE-23241 TestExecutorService sometimes fail
URL: https://github.com/apache/hbase/pull/782#discussion_r341675654
 
 

 ##########
 File path: hbase-server/src/test/java/org/apache/hadoop/hbase/executor/TestExecutorService.java
 ##########
 @@ -231,9 +231,11 @@ public void testSnapshotHandlers() throws Exception {
     executorService.startExecutorService(ExecutorType.MASTER_SNAPSHOT_OPERATIONS, 1);
 
     CountDownLatch latch = new CountDownLatch(1);
+    final AtomicInteger counter = new AtomicInteger(0);
 
 Review comment:
   I think you can simplify this with another CountDownLatch instead of busy polling. Something like follows.
   
       CountDownLatch latch = new CountDownLatch(1);
       CountDownLatch waitForEventToStart = new CountDownLatch(1);
       executorService.submit(new EventHandler(server, EventType.C_M_SNAPSHOT_TABLE) {
         @Override
         public void process() throws IOException {
           waitForEventToStart.countDown();
           try {
             latch.await();
           } catch (InterruptedException e) {
             Thread.currentThread().interrupt();
           }
         }
       });
       waitForEventToStart.await(10, TimeUnit.SECONDS);  <== Add a timeout as you wish.
       int activeCount = executorService.getExecutor(ExecutorType.MASTER_SNAPSHOT_OPERATIONS)
           .getThreadPoolExecutor().getActiveCount();
       Assert.assertEquals(activeCount, 1);
       latch.countDown();
   
   Doesn't probably matter that much because this is just a test.

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


With regards,
Apache Git Services