Merge pull request #490 from mabaiwan/develop

Change the name of the alarm field
pull/442/head
小马哥 3 years ago committed by GitHub
commit f23a6b7f2c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -78,7 +78,7 @@ public class DefaultPublisher extends Thread implements EventPublisher {
private void openEventHandler() { private void openEventHandler() {
try { try {
int waitTimes = 60; int waitTimes = 60;
for (; ; ) { for (;;) {
if (shutdown || hasSubscriber() || waitTimes <= 0) { if (shutdown || hasSubscriber() || waitTimes <= 0) {
break; break;
} }
@ -89,7 +89,7 @@ public class DefaultPublisher extends Thread implements EventPublisher {
} }
waitTimes--; waitTimes--;
} }
for (; ; ) { for (;;) {
if (shutdown) { if (shutdown) {
break; break;
} }

@ -85,7 +85,7 @@ public class ThreadPoolNotifyAlarmHandler implements Runnable, CommandLineRunner
List<String> listThreadPoolId = GlobalThreadPoolManage.listThreadPoolId(); List<String> listThreadPoolId = GlobalThreadPoolManage.listThreadPoolId();
listThreadPoolId.forEach(threadPoolId -> { listThreadPoolId.forEach(threadPoolId -> {
ThreadPoolNotifyAlarm threadPoolNotifyAlarm = GlobalNotifyAlarmManage.get(threadPoolId); ThreadPoolNotifyAlarm threadPoolNotifyAlarm = GlobalNotifyAlarmManage.get(threadPoolId);
if (threadPoolNotifyAlarm != null && threadPoolNotifyAlarm.getIsAlarm()) { if (threadPoolNotifyAlarm != null && threadPoolNotifyAlarm.getAlarm()) {
DynamicThreadPoolWrapper wrapper = GlobalThreadPoolManage.getExecutorService(threadPoolId); DynamicThreadPoolWrapper wrapper = GlobalThreadPoolManage.getExecutorService(threadPoolId);
ThreadPoolExecutor executor = wrapper.getExecutor(); ThreadPoolExecutor executor = wrapper.getExecutor();
checkPoolCapacityAlarm(threadPoolId, executor); checkPoolCapacityAlarm(threadPoolId, executor);
@ -109,7 +109,7 @@ public class ThreadPoolNotifyAlarmHandler implements Runnable, CommandLineRunner
int queueSize = blockingQueue.size(); int queueSize = blockingQueue.size();
int capacity = queueSize + blockingQueue.remainingCapacity(); int capacity = queueSize + blockingQueue.remainingCapacity();
int divide = CalculateUtil.divide(queueSize, capacity); int divide = CalculateUtil.divide(queueSize, capacity);
boolean isSend = threadPoolNotifyAlarm.getIsAlarm() boolean isSend = threadPoolNotifyAlarm.getAlarm()
&& divide > threadPoolNotifyAlarm.getCapacityAlarm(); && divide > threadPoolNotifyAlarm.getCapacityAlarm();
if (isSend) { if (isSend) {
AlarmNotifyRequest alarmNotifyRequest = buildAlarmNotifyReq(threadPoolExecutor); AlarmNotifyRequest alarmNotifyRequest = buildAlarmNotifyReq(threadPoolExecutor);
@ -129,7 +129,7 @@ public class ThreadPoolNotifyAlarmHandler implements Runnable, CommandLineRunner
int maximumPoolSize = threadPoolExecutor.getMaximumPoolSize(); int maximumPoolSize = threadPoolExecutor.getMaximumPoolSize();
int divide = CalculateUtil.divide(activeCount, maximumPoolSize); int divide = CalculateUtil.divide(activeCount, maximumPoolSize);
ThreadPoolNotifyAlarm threadPoolNotifyAlarm = GlobalNotifyAlarmManage.get(threadPoolId); ThreadPoolNotifyAlarm threadPoolNotifyAlarm = GlobalNotifyAlarmManage.get(threadPoolId);
boolean isSend = threadPoolNotifyAlarm.getIsAlarm() boolean isSend = threadPoolNotifyAlarm.getAlarm()
&& divide > threadPoolNotifyAlarm.getActiveAlarm(); && divide > threadPoolNotifyAlarm.getActiveAlarm();
if (isSend) { if (isSend) {
AlarmNotifyRequest alarmNotifyRequest = buildAlarmNotifyReq(threadPoolExecutor); AlarmNotifyRequest alarmNotifyRequest = buildAlarmNotifyReq(threadPoolExecutor);
@ -145,7 +145,7 @@ public class ThreadPoolNotifyAlarmHandler implements Runnable, CommandLineRunner
*/ */
public void checkPoolRejectedAlarm(String threadPoolId) { public void checkPoolRejectedAlarm(String threadPoolId) {
ThreadPoolNotifyAlarm threadPoolNotifyAlarm = GlobalNotifyAlarmManage.get(threadPoolId); ThreadPoolNotifyAlarm threadPoolNotifyAlarm = GlobalNotifyAlarmManage.get(threadPoolId);
if (Objects.isNull(threadPoolNotifyAlarm) || !threadPoolNotifyAlarm.getIsAlarm()) { if (Objects.isNull(threadPoolNotifyAlarm) || !threadPoolNotifyAlarm.getAlarm()) {
return; return;
} }
ThreadPoolExecutor threadPoolExecutor = GlobalThreadPoolManage.getExecutorService(threadPoolId).getExecutor(); ThreadPoolExecutor threadPoolExecutor = GlobalThreadPoolManage.getExecutorService(threadPoolId).getExecutor();
@ -176,7 +176,7 @@ public class ThreadPoolNotifyAlarmHandler implements Runnable, CommandLineRunner
*/ */
public void asyncSendExecuteTimeOutAlarm(String threadPoolId, long executeTime, long executeTimeOut, ThreadPoolExecutor threadPoolExecutor) { public void asyncSendExecuteTimeOutAlarm(String threadPoolId, long executeTime, long executeTimeOut, ThreadPoolExecutor threadPoolExecutor) {
ThreadPoolNotifyAlarm threadPoolNotifyAlarm = GlobalNotifyAlarmManage.get(threadPoolId); ThreadPoolNotifyAlarm threadPoolNotifyAlarm = GlobalNotifyAlarmManage.get(threadPoolId);
if (Objects.isNull(threadPoolNotifyAlarm) || !threadPoolNotifyAlarm.getIsAlarm()) { if (Objects.isNull(threadPoolNotifyAlarm) || !threadPoolNotifyAlarm.getAlarm()) {
return; return;
} }
if (threadPoolExecutor instanceof DynamicThreadPoolExecutor) { if (threadPoolExecutor instanceof DynamicThreadPoolExecutor) {

@ -33,10 +33,10 @@ import java.util.Map;
public class ThreadPoolNotifyAlarm { public class ThreadPoolNotifyAlarm {
/** /**
* Is alarm * Whether to enable thread pool running alarm
*/ */
@NonNull @NonNull
private Boolean isAlarm; private Boolean alarm;
/** /**
* Active alarm * Active alarm

@ -56,7 +56,7 @@ public class CoreNotifyConfigBuilder implements NotifyConfigBuilder {
log.warn("Failed to build notify, executors configuration is empty."); log.warn("Failed to build notify, executors configuration is empty.");
return resultMap; return resultMap;
} }
List<ExecutorProperties> actual = executors.stream().filter(each -> Optional.ofNullable(each.getNotify()).map(notify -> notify.getIsAlarm()).orElse(false)).collect(Collectors.toList()); List<ExecutorProperties> actual = executors.stream().filter(each -> Optional.ofNullable(each.getNotify()).map(notify -> notify.getAlarm()).orElse(false)).collect(Collectors.toList());
if (!globalAlarm && CollectionUtil.isEmpty(actual)) { if (!globalAlarm && CollectionUtil.isEmpty(actual)) {
return resultMap; return resultMap;
} }

@ -110,7 +110,7 @@ public class ZookeeperRefresherHandler extends AbstractCoreThreadPoolDynamicRefr
public void registerNotifyAlarmManage() { public void registerNotifyAlarmManage() {
bootstrapCoreProperties.getExecutors().forEach(executorProperties -> { bootstrapCoreProperties.getExecutors().forEach(executorProperties -> {
ThreadPoolNotifyAlarm threadPoolNotifyAlarm = new ThreadPoolNotifyAlarm( ThreadPoolNotifyAlarm threadPoolNotifyAlarm = new ThreadPoolNotifyAlarm(
executorProperties.getNotify().getIsAlarm(), executorProperties.getNotify().getAlarm(),
executorProperties.getNotify().getCapacityAlarm(), executorProperties.getNotify().getCapacityAlarm(),
executorProperties.getNotify().getActiveAlarm()); executorProperties.getNotify().getActiveAlarm());
threadPoolNotifyAlarm.setInterval(executorProperties.getNotify().getInterval()); threadPoolNotifyAlarm.setInterval(executorProperties.getNotify().getInterval());

@ -165,14 +165,14 @@ public class ExecutorsListener implements ApplicationListener<Hippo4jCoreDynamic
ThreadPoolNotifyAlarm threadPoolNotifyAlarm = GlobalNotifyAlarmManage.get(properties.getThreadPoolId()); ThreadPoolNotifyAlarm threadPoolNotifyAlarm = GlobalNotifyAlarmManage.get(properties.getThreadPoolId());
if (threadPoolNotifyAlarm != null && properties.getNotify() != null) { if (threadPoolNotifyAlarm != null && properties.getNotify() != null) {
ThreadPoolNotifyAlarm notify = properties.getNotify(); ThreadPoolNotifyAlarm notify = properties.getNotify();
boolean isAlarm = notify.getIsAlarm(); boolean isAlarm = notify.getAlarm();
Integer activeAlarm = notify.getActiveAlarm(); Integer activeAlarm = notify.getActiveAlarm();
Integer capacityAlarm = notify.getCapacityAlarm(); Integer capacityAlarm = notify.getCapacityAlarm();
if (threadPoolNotifyAlarm.getIsAlarm() != isAlarm if (threadPoolNotifyAlarm.getAlarm() != isAlarm
|| threadPoolNotifyAlarm.getActiveAlarm() != activeAlarm || threadPoolNotifyAlarm.getActiveAlarm() != activeAlarm
|| threadPoolNotifyAlarm.getCapacityAlarm() != capacityAlarm) { || threadPoolNotifyAlarm.getCapacityAlarm() != capacityAlarm) {
checkNotifyAlarm = true; checkNotifyAlarm = true;
threadPoolNotifyAlarm.setIsAlarm(isAlarm); threadPoolNotifyAlarm.setAlarm(isAlarm);
threadPoolNotifyAlarm.setActiveAlarm(activeAlarm); threadPoolNotifyAlarm.setActiveAlarm(activeAlarm);
threadPoolNotifyAlarm.setCapacityAlarm(capacityAlarm); threadPoolNotifyAlarm.setCapacityAlarm(capacityAlarm);
} }

@ -134,7 +134,7 @@ public final class DynamicThreadPoolPostProcessor implements BeanPostProcessor {
if (dynamicThreadPoolWrapper.getExecutor() instanceof AbstractDynamicExecutorSupport) { if (dynamicThreadPoolWrapper.getExecutor() instanceof AbstractDynamicExecutorSupport) {
ThreadPoolNotifyAlarm notify = Optional.ofNullable(executorProperties).map(ExecutorProperties::getNotify).orElse(null); ThreadPoolNotifyAlarm notify = Optional.ofNullable(executorProperties).map(ExecutorProperties::getNotify).orElse(null);
boolean isAlarm = Optional.ofNullable(notify) boolean isAlarm = Optional.ofNullable(notify)
.map(each -> each.getIsAlarm()).orElseGet(() -> bootstrapCoreProperties.getAlarm() != null ? bootstrapCoreProperties.getAlarm() : true); .map(each -> each.getAlarm()).orElseGet(() -> bootstrapCoreProperties.getAlarm() != null ? bootstrapCoreProperties.getAlarm() : true);
int activeAlarm = Optional.ofNullable(notify) int activeAlarm = Optional.ofNullable(notify)
.map(each -> each.getActiveAlarm()).orElseGet(() -> bootstrapCoreProperties.getActiveAlarm() != null ? bootstrapCoreProperties.getActiveAlarm() : 80); .map(each -> each.getActiveAlarm()).orElseGet(() -> bootstrapCoreProperties.getActiveAlarm() != null ? bootstrapCoreProperties.getActiveAlarm() : 80);
int capacityAlarm = Optional.ofNullable(notify) int capacityAlarm = Optional.ofNullable(notify)

Loading…
Cancel
Save