* Use named thread factory with all thread pools for identification Signed-off-by: Eric Zhao <sczyh16@gmail.com>master
@@ -20,6 +20,7 @@ import java.util.concurrent.ScheduledExecutorService; | |||
import java.util.concurrent.TimeUnit; | |||
import java.util.concurrent.atomic.AtomicLong; | |||
import com.alibaba.csp.sentinel.concurrent.NamedThreadFactory; | |||
import com.alibaba.csp.sentinel.context.Context; | |||
import com.alibaba.csp.sentinel.node.ClusterNode; | |||
import com.alibaba.csp.sentinel.node.DefaultNode; | |||
@@ -56,7 +57,7 @@ public class DegradeRule extends AbstractRule { | |||
private static final int RT_MAX_EXCEED_N = 5; | |||
private static ScheduledExecutorService pool = Executors.newScheduledThreadPool( | |||
Runtime.getRuntime().availableProcessors()); | |||
Runtime.getRuntime().availableProcessors(), new NamedThreadFactory("sentinel-degrade-reset-task", true)); | |||
/** | |||
* RT threshold or exception ratio threshold count. | |||
@@ -23,6 +23,7 @@ import java.util.concurrent.Executors; | |||
import java.util.concurrent.ScheduledExecutorService; | |||
import java.util.concurrent.TimeUnit; | |||
import com.alibaba.csp.sentinel.concurrent.NamedThreadFactory; | |||
import com.alibaba.csp.sentinel.log.RecordLog; | |||
import com.alibaba.csp.sentinel.util.StringUtil; | |||
import com.alibaba.csp.sentinel.context.Context; | |||
@@ -54,7 +55,8 @@ import com.alibaba.csp.sentinel.slots.block.flow.controller.WarmUpController; | |||
public class FlowRuleManager { | |||
private static final Map<String, List<FlowRule>> flowRules = new ConcurrentHashMap<String, List<FlowRule>>(); | |||
private final static ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); | |||
private final static ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1, | |||
new NamedThreadFactory("sentinel-metrics-record-task", true)); | |||
private final static FlowPropertyListener listener = new FlowPropertyListener(); | |||
private static SentinelProperty<List<FlowRule>> currentProperty = new DynamicSentinelProperty<List<FlowRule>>(); | |||
@@ -24,6 +24,7 @@ import java.util.concurrent.atomic.AtomicBoolean; | |||
import com.alibaba.csp.sentinel.Constants; | |||
import com.alibaba.csp.sentinel.EntryType; | |||
import com.alibaba.csp.sentinel.concurrent.NamedThreadFactory; | |||
import com.alibaba.csp.sentinel.log.RecordLog; | |||
import com.alibaba.csp.sentinel.property.DynamicSentinelProperty; | |||
import com.alibaba.csp.sentinel.property.SentinelProperty; | |||
@@ -82,7 +83,8 @@ public class SystemRuleManager { | |||
private final static SystemPropertyListener listener = new SystemPropertyListener(); | |||
private static SentinelProperty<List<SystemRule>> currentProperty = new DynamicSentinelProperty<List<SystemRule>>(); | |||
private final static ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); | |||
private final static ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1, | |||
new NamedThreadFactory("sentinel-system-status-record-task", true)); | |||
static { | |||
checkSystemStatus.set(false); | |||
@@ -83,7 +83,8 @@ public class MetricFetcher { | |||
private AppManagement appManagement; | |||
private CloseableHttpAsyncClient httpclient; | |||
private ScheduledExecutorService fetchScheduleService = Executors.newScheduledThreadPool(1); | |||
private ScheduledExecutorService fetchScheduleService = Executors.newScheduledThreadPool(1, | |||
new NamedThreadFactory("sentinel-dashboard-metrics-fetch-task")); | |||
private ExecutorService fetchService; | |||
private ExecutorService fetchWorker; | |||
@@ -94,10 +95,10 @@ public class MetricFetcher { | |||
RejectedExecutionHandler handler = new DiscardPolicy(); | |||
fetchService = new ThreadPoolExecutor(cores, cores, | |||
keepAliveTime, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<>(queueSize), | |||
new NamedThreadFactory("fetchService"), handler); | |||
new NamedThreadFactory("sentinel-dashboard-metrics-fetchService"), handler); | |||
fetchWorker = new ThreadPoolExecutor(cores, cores, | |||
keepAliveTime, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<>(queueSize), | |||
new NamedThreadFactory("fetchWorker"), handler); | |||
new NamedThreadFactory("sentinel-dashboard-metrics-fetchWorker"), handler); | |||
IOReactorConfig ioConfig = IOReactorConfig.custom() | |||
.setConnectTimeout(3000) | |||
.setSoTimeout(3000) | |||
@@ -19,6 +19,7 @@ import java.util.concurrent.Executors; | |||
import java.util.concurrent.ScheduledExecutorService; | |||
import java.util.concurrent.TimeUnit; | |||
import com.alibaba.csp.sentinel.concurrent.NamedThreadFactory; | |||
import com.alibaba.csp.sentinel.log.RecordLog; | |||
/** | |||
@@ -48,7 +49,8 @@ public abstract class AutoRefreshDataSource<S, T> extends AbstractDataSource<S, | |||
} | |||
private void startTimerService() { | |||
service = Executors.newScheduledThreadPool(1); | |||
service = Executors.newScheduledThreadPool(1, | |||
new NamedThreadFactory("sentinel-datasource-auto-refresh-task", true)); | |||
service.scheduleAtFixedRate(new Runnable() { | |||
@Override | |||
public void run() { | |||
@@ -21,6 +21,7 @@ import java.util.concurrent.Executors; | |||
import java.util.concurrent.ScheduledExecutorService; | |||
import java.util.concurrent.TimeUnit; | |||
import com.alibaba.csp.sentinel.concurrent.NamedThreadFactory; | |||
import com.alibaba.csp.sentinel.init.InitFunc; | |||
import com.alibaba.csp.sentinel.log.RecordLog; | |||
import com.alibaba.csp.sentinel.transport.HeartbeatSender; | |||
@@ -33,7 +34,8 @@ import com.alibaba.csp.sentinel.transport.config.TransportConfig; | |||
*/ | |||
public class HeartbeatSenderInitFunc implements InitFunc { | |||
private static ScheduledExecutorService pool = Executors.newScheduledThreadPool(2); | |||
private static ScheduledExecutorService pool = Executors.newScheduledThreadPool(2, | |||
new NamedThreadFactory("sentinel-heartbeat-send-task", true)); | |||
@Override | |||
public void init() throws Exception { | |||
@@ -21,6 +21,7 @@ import java.util.concurrent.Executors; | |||
import com.alibaba.csp.sentinel.command.CommandHandler; | |||
import com.alibaba.csp.sentinel.command.CommandHandlerProvider; | |||
import com.alibaba.csp.sentinel.concurrent.NamedThreadFactory; | |||
import com.alibaba.csp.sentinel.transport.command.netty.HttpServer; | |||
import com.alibaba.csp.sentinel.log.RecordLog; | |||
import com.alibaba.csp.sentinel.transport.CommandCenter; | |||
@@ -34,7 +35,8 @@ public class NettyHttpCommandCenter implements CommandCenter { | |||
private final HttpServer server = new HttpServer(); | |||
private final ExecutorService pool = Executors.newSingleThreadExecutor(); | |||
private final ExecutorService pool = Executors.newSingleThreadExecutor( | |||
new NamedThreadFactory("sentinel-netty-command-center-executor")); | |||
@Override | |||
public void start() throws Exception { | |||