|
|
@ -66,7 +66,7 @@ public class ThreadPoolNotifyAlarmHandler implements Runnable, CommandLineRunner
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
r -> new Thread(r, "client.alarm.notify"));
|
|
|
|
r -> new Thread(r, "client.alarm.notify"));
|
|
|
|
|
|
|
|
|
|
|
|
private final ExecutorService EXECUTE_TIMEOUT_EXECUTOR = ThreadPoolBuilder.builder()
|
|
|
|
private final ExecutorService ASYNC_ALARM_NOTIFY_EXECUTOR = ThreadPoolBuilder.builder()
|
|
|
|
.poolThreadSize(2, 4)
|
|
|
|
.poolThreadSize(2, 4)
|
|
|
|
.threadFactory("client.execute.timeout.alarm")
|
|
|
|
.threadFactory("client.execute.timeout.alarm")
|
|
|
|
.allowCoreThreadTimeOut(true)
|
|
|
|
.allowCoreThreadTimeOut(true)
|
|
|
@ -139,31 +139,24 @@ public class ThreadPoolNotifyAlarmHandler implements Runnable, CommandLineRunner
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Check pool rejected alarm.
|
|
|
|
* Async send rejected alarm.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @param threadPoolId
|
|
|
|
* @param threadPoolId
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public void checkPoolRejectedAlarm(String threadPoolId) {
|
|
|
|
public void asyncSendRejectedAlarm(String threadPoolId) {
|
|
|
|
ThreadPoolNotifyAlarm threadPoolNotifyAlarm = GlobalNotifyAlarmManage.get(threadPoolId);
|
|
|
|
Runnable checkPoolRejectedAlarmTask = () -> {
|
|
|
|
if (Objects.isNull(threadPoolNotifyAlarm) || !threadPoolNotifyAlarm.getAlarm()) {
|
|
|
|
ThreadPoolNotifyAlarm threadPoolNotifyAlarm = GlobalNotifyAlarmManage.get(threadPoolId);
|
|
|
|
return;
|
|
|
|
if (Objects.isNull(threadPoolNotifyAlarm) || !threadPoolNotifyAlarm.getAlarm()) {
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
ThreadPoolExecutor threadPoolExecutor = GlobalThreadPoolManage.getExecutorService(threadPoolId).getExecutor();
|
|
|
|
}
|
|
|
|
checkPoolRejectedAlarm(threadPoolId, threadPoolExecutor);
|
|
|
|
ThreadPoolExecutor threadPoolExecutor = GlobalThreadPoolManage.getExecutorService(threadPoolId).getExecutor();
|
|
|
|
}
|
|
|
|
if (threadPoolExecutor instanceof DynamicThreadPoolExecutor) {
|
|
|
|
|
|
|
|
AlarmNotifyRequest alarmNotifyRequest = buildAlarmNotifyReq(threadPoolExecutor);
|
|
|
|
/**
|
|
|
|
alarmNotifyRequest.setThreadPoolId(threadPoolId);
|
|
|
|
* Check pool rejected alarm.
|
|
|
|
hippoSendMessageService.sendAlarmMessage(NotifyTypeEnum.REJECT, alarmNotifyRequest);
|
|
|
|
*
|
|
|
|
}
|
|
|
|
* @param threadPoolId
|
|
|
|
};
|
|
|
|
* @param threadPoolExecutor
|
|
|
|
ASYNC_ALARM_NOTIFY_EXECUTOR.execute(checkPoolRejectedAlarmTask);
|
|
|
|
*/
|
|
|
|
|
|
|
|
public void checkPoolRejectedAlarm(String threadPoolId, ThreadPoolExecutor threadPoolExecutor) {
|
|
|
|
|
|
|
|
if (threadPoolExecutor instanceof DynamicThreadPoolExecutor) {
|
|
|
|
|
|
|
|
AlarmNotifyRequest alarmNotifyRequest = buildAlarmNotifyReq(threadPoolExecutor);
|
|
|
|
|
|
|
|
alarmNotifyRequest.setThreadPoolId(threadPoolId);
|
|
|
|
|
|
|
|
hippoSendMessageService.sendAlarmMessage(NotifyTypeEnum.REJECT, alarmNotifyRequest);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
@ -190,7 +183,7 @@ public class ThreadPoolNotifyAlarmHandler implements Runnable, CommandLineRunner
|
|
|
|
alarmNotifyRequest.setExecuteTimeoutTrace(executeTimeoutTrace);
|
|
|
|
alarmNotifyRequest.setExecuteTimeoutTrace(executeTimeoutTrace);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Runnable task = () -> hippoSendMessageService.sendAlarmMessage(NotifyTypeEnum.TIMEOUT, alarmNotifyRequest);
|
|
|
|
Runnable task = () -> hippoSendMessageService.sendAlarmMessage(NotifyTypeEnum.TIMEOUT, alarmNotifyRequest);
|
|
|
|
EXECUTE_TIMEOUT_EXECUTOR.execute(task);
|
|
|
|
ASYNC_ALARM_NOTIFY_EXECUTOR.execute(task);
|
|
|
|
} catch (Throwable ex) {
|
|
|
|
} catch (Throwable ex) {
|
|
|
|
log.error("Send thread pool execution timeout alarm error.", ex);
|
|
|
|
log.error("Send thread pool execution timeout alarm error.", ex);
|
|
|
|
}
|
|
|
|
}
|
|
|
|