Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -855,6 +855,14 @@ public ThreadPoolExecutor getExecutorService() {
return executorService;
}

@Override
public void shutdown() {
if (executorService != null) {
executorService.shutdown();
}
super.shutdown();
}

/**
* In YARN Federation mode, We allow users to mark subClusters
* With no heartbeat for a long time as SC_LOST state.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,12 @@
import java.util.Set;
import java.util.HashSet;
import java.util.Random;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;

/**
Expand Down Expand Up @@ -187,6 +190,25 @@ public void tearDown() {
super.tearDown();
}

@Test
public void testShutdownThreadPool() throws Exception {
ThreadPoolExecutor executor = interceptor.getExecutorService();
try {
executor.submit(() -> { }).get(5, TimeUnit.SECONDS);
interceptor.shutdown();
assertTrue(executor.isShutdown());
assertTrue(executor.awaitTermination(5, TimeUnit.SECONDS));
interceptor.shutdown();
} finally {
executor.shutdownNow();
}
}

@Test
public void testShutdownBeforeInit() {
new FederationRMAdminInterceptor().shutdown();
}

@Test
public void testRefreshQueues() throws Exception {
// We will test 2 cases:
Expand Down
Loading