Supplemental code comments (#860)

pull/863/head
马称 2 years ago committed by GitHub
parent 28a7af8b72
commit 23a9b2617e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -27,12 +27,27 @@ import java.util.concurrent.ConcurrentHashMap;
*/ */
public class GlobalNotifyAlarmManage { public class GlobalNotifyAlarmManage {
/**
* Notify alarm map.
*/
private static final Map<String, ThreadPoolNotifyAlarm> NOTIFY_ALARM_MAP = new ConcurrentHashMap(); private static final Map<String, ThreadPoolNotifyAlarm> NOTIFY_ALARM_MAP = new ConcurrentHashMap();
/**
* Get thread-pool notify alarm.
*
* @param key thread-pool key
* @return thread-pool notify alarm
*/
public static ThreadPoolNotifyAlarm get(String key) { public static ThreadPoolNotifyAlarm get(String key) {
return NOTIFY_ALARM_MAP.get(key); return NOTIFY_ALARM_MAP.get(key);
} }
/**
* Put thread-pool notify alarm.
*
* @param key thread-pool key
* @param val thread-pool notify alarm
*/
public static void put(String key, ThreadPoolNotifyAlarm val) { public static void put(String key, ThreadPoolNotifyAlarm val) {
NOTIFY_ALARM_MAP.put(key, val); NOTIFY_ALARM_MAP.put(key, val);
} }

@ -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();

Loading…
Cancel
Save