|
|
@ -2,11 +2,14 @@ package com.github.dynamic.threadpool.starter.alarm;
|
|
|
|
|
|
|
|
|
|
|
|
import com.github.dynamic.threadpool.common.config.ApplicationContextHolder;
|
|
|
|
import com.github.dynamic.threadpool.common.config.ApplicationContextHolder;
|
|
|
|
import com.github.dynamic.threadpool.common.model.PoolParameterInfo;
|
|
|
|
import com.github.dynamic.threadpool.common.model.PoolParameterInfo;
|
|
|
|
|
|
|
|
import com.github.dynamic.threadpool.starter.config.MessageAlarmConfig;
|
|
|
|
import com.github.dynamic.threadpool.starter.toolkit.CalculateUtil;
|
|
|
|
import com.github.dynamic.threadpool.starter.toolkit.CalculateUtil;
|
|
|
|
import com.github.dynamic.threadpool.starter.toolkit.thread.CustomThreadPoolExecutor;
|
|
|
|
import com.github.dynamic.threadpool.starter.toolkit.thread.CustomThreadPoolExecutor;
|
|
|
|
import com.github.dynamic.threadpool.starter.toolkit.thread.ResizableCapacityLinkedBlockIngQueue;
|
|
|
|
import com.github.dynamic.threadpool.starter.toolkit.thread.ResizableCapacityLinkedBlockIngQueue;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.Optional;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Alarm manage.
|
|
|
|
* Alarm manage.
|
|
|
|
*
|
|
|
|
*
|
|
|
@ -19,7 +22,9 @@ public class ThreadPoolAlarmManage {
|
|
|
|
private static final SendMessageService SEND_MESSAGE_SERVICE;
|
|
|
|
private static final SendMessageService SEND_MESSAGE_SERVICE;
|
|
|
|
|
|
|
|
|
|
|
|
static {
|
|
|
|
static {
|
|
|
|
SEND_MESSAGE_SERVICE = ApplicationContextHolder.getBean("sendMessageService", SendMessageService.class);
|
|
|
|
SEND_MESSAGE_SERVICE = Optional.ofNullable(ApplicationContextHolder.getInstance())
|
|
|
|
|
|
|
|
.map(each -> each.getBean(MessageAlarmConfig.SEND_MESSAGE_BEAN_NAME, SendMessageService.class))
|
|
|
|
|
|
|
|
.orElse(null);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
@ -47,7 +52,7 @@ public class ThreadPoolAlarmManage {
|
|
|
|
* @param threadPoolExecutor
|
|
|
|
* @param threadPoolExecutor
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public static void checkPoolLivenessAlarm(boolean isCore, CustomThreadPoolExecutor threadPoolExecutor) {
|
|
|
|
public static void checkPoolLivenessAlarm(boolean isCore, CustomThreadPoolExecutor threadPoolExecutor) {
|
|
|
|
if (isCore) {
|
|
|
|
if (isCore || SEND_MESSAGE_SERVICE == null) {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
int activeCount = threadPoolExecutor.getActiveCount();
|
|
|
|
int activeCount = threadPoolExecutor.getActiveCount();
|
|
|
@ -64,8 +69,10 @@ public class ThreadPoolAlarmManage {
|
|
|
|
* @param threadPoolExecutor
|
|
|
|
* @param threadPoolExecutor
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public static void checkPoolRejectAlarm(CustomThreadPoolExecutor threadPoolExecutor) {
|
|
|
|
public static void checkPoolRejectAlarm(CustomThreadPoolExecutor threadPoolExecutor) {
|
|
|
|
|
|
|
|
if (SEND_MESSAGE_SERVICE != null) {
|
|
|
|
SEND_MESSAGE_SERVICE.sendAlarmMessage(threadPoolExecutor);
|
|
|
|
SEND_MESSAGE_SERVICE.sendAlarmMessage(threadPoolExecutor);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Send thread pool configuration change message.
|
|
|
|
* Send thread pool configuration change message.
|
|
|
@ -73,7 +80,9 @@ public class ThreadPoolAlarmManage {
|
|
|
|
* @param parameter
|
|
|
|
* @param parameter
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public static void sendPoolConfigChange(PoolParameterInfo parameter) {
|
|
|
|
public static void sendPoolConfigChange(PoolParameterInfo parameter) {
|
|
|
|
|
|
|
|
if (SEND_MESSAGE_SERVICE != null) {
|
|
|
|
SEND_MESSAGE_SERVICE.sendChangeMessage(parameter);
|
|
|
|
SEND_MESSAGE_SERVICE.sendChangeMessage(parameter);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|