3030import java .io .StringWriter ;
3131import java .util .concurrent .CountDownLatch ;
3232import java .util .concurrent .ThreadPoolExecutor ;
33+ import java .util .concurrent .TimeUnit ;
3334import java .util .concurrent .atomic .AtomicBoolean ;
3435import java .util .concurrent .atomic .AtomicInteger ;
3536import org .apache .hadoop .conf .Configuration ;
@@ -231,9 +232,11 @@ public void testSnapshotHandlers() throws Exception {
231232 executorService .startExecutorService (ExecutorType .MASTER_SNAPSHOT_OPERATIONS , 1 );
232233
233234 CountDownLatch latch = new CountDownLatch (1 );
235+ CountDownLatch waitForEventToStart = new CountDownLatch (1 );
234236 executorService .submit (new EventHandler (server , EventType .C_M_SNAPSHOT_TABLE ) {
235237 @ Override
236238 public void process () throws IOException {
239+ waitForEventToStart .countDown ();
237240 try {
238241 latch .await ();
239242 } catch (InterruptedException e ) {
@@ -242,9 +245,11 @@ public void process() throws IOException {
242245 }
243246 });
244247
248+ //Wait EventHandler to start
249+ waitForEventToStart .await (10 , TimeUnit .SECONDS );
245250 int activeCount = executorService .getExecutor (ExecutorType .MASTER_SNAPSHOT_OPERATIONS )
246251 .getThreadPoolExecutor ().getActiveCount ();
247- Assert .assertEquals (activeCount , 1 );
252+ Assert .assertEquals (1 , activeCount );
248253 latch .countDown ();
249254 Waiter .waitFor (conf , 3000 , () -> {
250255 int count = executorService .getExecutor (ExecutorType .MASTER_SNAPSHOT_OPERATIONS )
0 commit comments