Merge pull request #490 from mabaiwan/develop

Change the name of the alarm field
pull/442/head
小马哥 2 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() {
try {
int waitTimes = 60;
for (; ; ) {
for (;;) {
if (shutdown || hasSubscriber() || waitTimes <= 0) {
break;
}
@ -89,7 +89,7 @@ public class DefaultPublisher extends Thread implements EventPublisher {
}
waitTimes--;
}
for (; ; ) {
for (;;) {
if (shutdown) {
break;
}

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

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

@ -56,7 +56,7 @@ public class CoreNotifyConfigBuilder implements NotifyConfigBuilder {
log.warn("Failed to build notify, executors configuration is empty.");
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)) {
return resultMap;
}

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

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

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

Loading…
Cancel
Save