|
|
|
@ -48,8 +48,8 @@ public class GlobalThreadPoolManage {
|
|
|
|
|
/**
|
|
|
|
|
* Get the dynamic thread pool wrapper class.
|
|
|
|
|
*
|
|
|
|
|
* @param threadPoolId
|
|
|
|
|
* @return
|
|
|
|
|
* @param threadPoolId thread-pool id
|
|
|
|
|
* @return dynamic thread-pool wrapper
|
|
|
|
|
*/
|
|
|
|
|
public static DynamicThreadPoolWrapper getExecutorService(String threadPoolId) {
|
|
|
|
|
return EXECUTOR_MAP.get(threadPoolId);
|
|
|
|
@ -58,8 +58,8 @@ public class GlobalThreadPoolManage {
|
|
|
|
|
/**
|
|
|
|
|
* Get the dynamic thread pool wrapper class.
|
|
|
|
|
*
|
|
|
|
|
* @param threadPoolId
|
|
|
|
|
* @return
|
|
|
|
|
* @param threadPoolId thread-pool id
|
|
|
|
|
* @return thread-pool executor
|
|
|
|
|
*/
|
|
|
|
|
public static ThreadPoolExecutor getExecutor(String threadPoolId) {
|
|
|
|
|
return Optional.ofNullable(EXECUTOR_MAP.get(threadPoolId)).map(each -> each.getExecutor()).orElse(null);
|
|
|
|
@ -68,8 +68,8 @@ public class GlobalThreadPoolManage {
|
|
|
|
|
/**
|
|
|
|
|
* Get dynamic thread pool parameters.
|
|
|
|
|
*
|
|
|
|
|
* @param threadPoolId
|
|
|
|
|
* @return
|
|
|
|
|
* @param threadPoolId thread-pool id
|
|
|
|
|
* @return thread-pool parameter
|
|
|
|
|
*/
|
|
|
|
|
public static ThreadPoolParameter getPoolParameter(String threadPoolId) {
|
|
|
|
|
return POOL_PARAMETER.get(threadPoolId);
|
|
|
|
@ -78,9 +78,9 @@ public class GlobalThreadPoolManage {
|
|
|
|
|
/**
|
|
|
|
|
* Register dynamic thread pool wrapper and parameters.
|
|
|
|
|
*
|
|
|
|
|
* @param threadPoolId
|
|
|
|
|
* @param threadPoolParameter
|
|
|
|
|
* @param executor
|
|
|
|
|
* @param threadPoolId thread-pool id
|
|
|
|
|
* @param threadPoolParameter thread-pool parameter
|
|
|
|
|
* @param executor executor
|
|
|
|
|
*/
|
|
|
|
|
public static void register(String threadPoolId, ThreadPoolParameter threadPoolParameter, DynamicThreadPoolWrapper executor) {
|
|
|
|
|
registerPool(threadPoolId, executor);
|
|
|
|
@ -90,8 +90,8 @@ public class GlobalThreadPoolManage {
|
|
|
|
|
/**
|
|
|
|
|
* Register dynamic thread pool.
|
|
|
|
|
*
|
|
|
|
|
* @param threadPoolId
|
|
|
|
|
* @param executor
|
|
|
|
|
* @param threadPoolId thread-pool id
|
|
|
|
|
* @param executor executor
|
|
|
|
|
*/
|
|
|
|
|
public static void registerPool(String threadPoolId, DynamicThreadPoolWrapper executor) {
|
|
|
|
|
EXECUTOR_MAP.put(threadPoolId, executor);
|
|
|
|
@ -100,17 +100,17 @@ public class GlobalThreadPoolManage {
|
|
|
|
|
/**
|
|
|
|
|
* Register dynamic thread pool parameters.
|
|
|
|
|
*
|
|
|
|
|
* @param threadPoolId
|
|
|
|
|
* @param poolParameter
|
|
|
|
|
* @param threadPoolId thread-pool id
|
|
|
|
|
* @param threadPoolParameter thread-pool parameter
|
|
|
|
|
*/
|
|
|
|
|
public static void registerPoolParameter(String threadPoolId, ThreadPoolParameter poolParameter) {
|
|
|
|
|
POOL_PARAMETER.put(threadPoolId, poolParameter);
|
|
|
|
|
public static void registerPoolParameter(String threadPoolId, ThreadPoolParameter threadPoolParameter) {
|
|
|
|
|
POOL_PARAMETER.put(threadPoolId, threadPoolParameter);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Dynamically register thread pool records and notification records.
|
|
|
|
|
*
|
|
|
|
|
* @param registerWrapper
|
|
|
|
|
* @param registerWrapper register wrapper
|
|
|
|
|
*/
|
|
|
|
|
public static ThreadPoolExecutor dynamicRegister(DynamicThreadPoolRegisterWrapper registerWrapper) {
|
|
|
|
|
DynamicThreadPoolService dynamicThreadPoolService = ApplicationContextHolder.getBean(DynamicThreadPoolService.class);
|
|
|
|
@ -120,7 +120,7 @@ public class GlobalThreadPoolManage {
|
|
|
|
|
/**
|
|
|
|
|
* Get the dynamic thread pool identifier collection.
|
|
|
|
|
*
|
|
|
|
|
* @return
|
|
|
|
|
* @return thread-pool id list
|
|
|
|
|
*/
|
|
|
|
|
public static List<String> listThreadPoolId() {
|
|
|
|
|
return new ArrayList<>(EXECUTOR_MAP.keySet());
|
|
|
|
@ -128,11 +128,10 @@ public class GlobalThreadPoolManage {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get the number of dynamic thread pools.
|
|
|
|
|
* <p>
|
|
|
|
|
* The data may be inaccurate when the project is initially
|
|
|
|
|
* <p> The data may be inaccurate when the project is initially
|
|
|
|
|
* launched because registration is done asynchronously.
|
|
|
|
|
*
|
|
|
|
|
* @return
|
|
|
|
|
* @return thread-pool num
|
|
|
|
|
*/
|
|
|
|
|
public static Integer getThreadPoolNum() {
|
|
|
|
|
return listThreadPoolId().size();
|
|
|
|
|