Package com.alipay.sofa.common.thread
Class ThreadPoolGovernor
java.lang.Object
com.alipay.sofa.common.thread.ThreadPoolGovernor
The governor to manager the
ThreadPoolExecutor
s- Author:
- Alaneuler Created on 2020/3/17
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionlong
The period of the dump taskstatic ThreadPoolGovernor
The thread pool to executor the monitor tasksint
getSpaceNameThreadPoolNumber
(String spaceName) return the spaceName thread pool number,it will increase after witch get return 0 when the spaceName has not registeredgetThreadPoolExecutor
(String identity) Get theThreadPoolExecutor
by it's identitygetThreadPoolMonitorWrapper
(String identity) Get theThreadPoolMonitorWrapper
by it's identityboolean
The log switch of the all monitor taskboolean
The log switch of the dump taskvoid
registerThreadPoolExecutor
(ThreadPoolExecutor threadPoolExecutor, ThreadPoolConfig threadPoolConfig, ThreadPoolStatistics threadPoolStatistics) void
restartMonitorThreadPool
(String identity) Restart the monitor theThreadPoolExecutor
registered in the governorvoid
setGlobalMonitorLoggable
(boolean globalMonitorLoggable) Update the log switch of the all monitor taskvoid
setGovernorLoggable
(boolean governorLoggable) Update the log switch of the dump taskvoid
setGovernorPeriod
(long governorPeriod) update the period of the dump task, then restart the taskvoid
setMonitorThreadPoolBySpaceName
(String spaceName, long period) update the monitor params and restart all thread pool in the spaceNamevoid
Start the governor info dump taskvoid
startMonitorThreadPool
(String identity) Start the monitor theThreadPoolExecutor
registered in the governorvoid
startMonitorThreadPoolBySpaceName
(String spaceName) start monitor all thread pool in the spaceNamevoid
Stop the governor info dump taskvoid
stopMonitorThreadPool
(String identity) Stop to monitor theThreadPoolExecutor
registered in the governorvoid
stopMonitorThreadPoolBySpaceName
(String spaceName) stop monitor all thread pool in the spaceNamevoid
unregisterThreadPoolExecutor
(ThreadPoolConfig threadPoolConfig) Unregister theThreadPoolExecutor
by it'sThreadPoolConfig
-
Field Details
-
CLASS_NAME
-
-
Method Details
-
getInstance
-
startGovernorSchedule
public void startGovernorSchedule()Start the governor info dump task -
stopGovernorSchedule
public void stopGovernorSchedule()Stop the governor info dump task -
getGovernorPeriod
public long getGovernorPeriod()The period of the dump task- Returns:
- the period
-
setGovernorPeriod
public void setGovernorPeriod(long governorPeriod) update the period of the dump task, then restart the task- Parameters:
governorPeriod
- the dump task period
-
isGovernorLoggable
public boolean isGovernorLoggable()The log switch of the dump task- Returns:
- whether log the dump
-
setGovernorLoggable
public void setGovernorLoggable(boolean governorLoggable) Update the log switch of the dump task- Parameters:
governorLoggable
- whether log the dump
-
isGlobalMonitorLoggable
public boolean isGlobalMonitorLoggable()The log switch of the all monitor task- Returns:
- whether log monitor task
-
setGlobalMonitorLoggable
public void setGlobalMonitorLoggable(boolean globalMonitorLoggable) Update the log switch of the all monitor task- Parameters:
globalMonitorLoggable
- whether log monitor task
-
registerThreadPoolExecutor
public void registerThreadPoolExecutor(ThreadPoolExecutor threadPoolExecutor, ThreadPoolConfig threadPoolConfig, ThreadPoolStatistics threadPoolStatistics) - Parameters:
threadPoolExecutor
- the base thread poolthreadPoolConfig
- the description of the thread poolthreadPoolStatistics
- the running statistics of the thread pool
-
unregisterThreadPoolExecutor
Unregister theThreadPoolExecutor
by it'sThreadPoolConfig
- Parameters:
threadPoolConfig
- the description of the thread pool, it's identity is unique
-
getThreadPoolExecutor
Get theThreadPoolExecutor
by it's identity- Parameters:
identity
- the unique identity- Returns:
- the
ThreadPoolExecutor
-
getThreadPoolMonitorWrapper
Get theThreadPoolMonitorWrapper
by it's identity- Parameters:
identity
- the unique identity- Returns:
- the
ThreadPoolMonitorWrapper
-
startMonitorThreadPool
Start the monitor theThreadPoolExecutor
registered in the governor- Parameters:
identity
- the unique identity
-
stopMonitorThreadPool
Stop to monitor theThreadPoolExecutor
registered in the governor- Parameters:
identity
- the unique identity
-
restartMonitorThreadPool
Restart the monitor theThreadPoolExecutor
registered in the governor- Parameters:
identity
- the unique identity
-
getMonitorScheduler
The thread pool to executor the monitor tasks- Returns:
- the
ScheduledExecutorService
-
getSpaceNameThreadPoolNumber
return the spaceName thread pool number,it will increase after witch get return 0 when the spaceName has not registered- Parameters:
spaceName
- the spaceName- Returns:
- the spaceName thread pool number
-
startMonitorThreadPoolBySpaceName
start monitor all thread pool in the spaceName- Parameters:
spaceName
- the spaceName
-
stopMonitorThreadPoolBySpaceName
stop monitor all thread pool in the spaceName- Parameters:
spaceName
- the spaceName
-
setMonitorThreadPoolBySpaceName
update the monitor params and restart all thread pool in the spaceName- Parameters:
spaceName
- the spaceName
-