Make all backend thread pools daemon (#2181)

* feat:make command center thread daemon
* feat:make all NamedThreadFactory thread daemon
This commit is contained in:
wutingjia 2021-06-04 13:32:21 +08:00 committed by Eric Zhao
parent f342022ee2
commit 9a612508ff
7 changed files with 10 additions and 10 deletions

View File

@ -62,7 +62,7 @@ public class NettyTransportClient implements ClusterTransportClient {
@SuppressWarnings("PMD.ThreadPoolCreationRule")
private static final ScheduledExecutorService SCHEDULER = Executors.newScheduledThreadPool(1,
new NamedThreadFactory("sentinel-cluster-transport-client-scheduler"));
new NamedThreadFactory("sentinel-cluster-transport-client-scheduler", true));
public static final int RECONNECT_DELAY_MS = 2000;

View File

@ -66,7 +66,7 @@ public class RegularExpireStrategy implements ExpireStrategy {
@SuppressWarnings("PMD.ThreadPoolCreationRule")
private static ScheduledExecutorService executor = Executors.newScheduledThreadPool(1,
new NamedThreadFactory("regular clear expired token thread"));
new NamedThreadFactory("regular clear expired token thread", true));
public RegularExpireStrategy(ConcurrentLinkedHashMap<Long, TokenCacheNode> localCache) {

View File

@ -89,7 +89,7 @@ public class MetricFetcher {
@SuppressWarnings("PMD.ThreadPoolCreationRule")
private ScheduledExecutorService fetchScheduleService = Executors.newScheduledThreadPool(1,
new NamedThreadFactory("sentinel-dashboard-metrics-fetch-task"));
new NamedThreadFactory("sentinel-dashboard-metrics-fetch-task", true));
private ExecutorService fetchService;
private ExecutorService fetchWorker;
@ -100,10 +100,10 @@ public class MetricFetcher {
RejectedExecutionHandler handler = new DiscardPolicy();
fetchService = new ThreadPoolExecutor(cores, cores,
keepAliveTime, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<>(queueSize),
new NamedThreadFactory("sentinel-dashboard-metrics-fetchService"), handler);
new NamedThreadFactory("sentinel-dashboard-metrics-fetchService", true), handler);
fetchWorker = new ThreadPoolExecutor(cores, cores,
keepAliveTime, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<>(queueSize),
new NamedThreadFactory("sentinel-dashboard-metrics-fetchWorker"), handler);
new NamedThreadFactory("sentinel-dashboard-metrics-fetchWorker",true), handler);
IOReactorConfig ioConfig = IOReactorConfig.custom()
.setConnectTimeout(3000)
.setSoTimeout(3000)

View File

@ -47,7 +47,7 @@ public class NacosDataSource<T> extends AbstractDataSource<String, T> {
* Single-thread pool. Once the thread pool is blocked, we throw up the old task.
*/
private final ExecutorService pool = new ThreadPoolExecutor(1, 1, 0, TimeUnit.MILLISECONDS,
new ArrayBlockingQueue<Runnable>(1), new NamedThreadFactory("sentinel-nacos-ds-update"),
new ArrayBlockingQueue<Runnable>(1), new NamedThreadFactory("sentinel-nacos-ds-update", true),
new ThreadPoolExecutor.DiscardOldestPolicy());
private final Listener configListener;

View File

@ -37,7 +37,7 @@ public class ZookeeperDataSource<T> extends AbstractDataSource<String, T> {
private final ExecutorService pool = new ThreadPoolExecutor(1, 1, 0, TimeUnit.MILLISECONDS,
new ArrayBlockingQueue<Runnable>(1), new NamedThreadFactory("sentinel-zookeeper-ds-update"),
new ArrayBlockingQueue<Runnable>(1), new NamedThreadFactory("sentinel-zookeeper-ds-update", true),
new ThreadPoolExecutor.DiscardOldestPolicy());
private NodeCacheListener listener;

View File

@ -39,7 +39,7 @@ public class NettyHttpCommandCenter implements CommandCenter {
@SuppressWarnings("PMD.ThreadPoolCreationRule")
private final ExecutorService pool = Executors.newSingleThreadExecutor(
new NamedThreadFactory("sentinel-netty-command-center-executor"));
new NamedThreadFactory("sentinel-netty-command-center-executor", true));
@Override
public void start() throws Exception {

View File

@ -57,7 +57,7 @@ public class SimpleHttpCommandCenter implements CommandCenter {
@SuppressWarnings("PMD.ThreadPoolCreationRule")
private ExecutorService executor = Executors.newSingleThreadExecutor(
new NamedThreadFactory("sentinel-command-center-executor"));
new NamedThreadFactory("sentinel-command-center-executor", true));
private ExecutorService bizExecutor;
private ServerSocket socketReference;
@ -75,7 +75,7 @@ public class SimpleHttpCommandCenter implements CommandCenter {
int nThreads = Runtime.getRuntime().availableProcessors();
this.bizExecutor = new ThreadPoolExecutor(nThreads, nThreads, 0L, TimeUnit.MILLISECONDS,
new ArrayBlockingQueue<Runnable>(10),
new NamedThreadFactory("sentinel-command-center-service-executor"),
new NamedThreadFactory("sentinel-command-center-service-executor", true),
new RejectedExecutionHandler() {
@Override
public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) {