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