use of com.dtp.common.dto.NotifyItem in project dynamic-tp by dromara.
the class AlarmManager method checkReject.
private static boolean checkReject(DtpExecutor executor) {
NotifyItem notifyItem = NotifyHelper.getNotifyItem(executor, NotifyTypeEnum.REJECT);
if (Objects.isNull(notifyItem)) {
return false;
}
AlarmInfo alarmInfo = AlarmCounter.getAlarmInfo(executor.getThreadPoolName(), notifyItem.getType());
int rejectCount = alarmInfo.getCount();
return satisfyBaseCondition(notifyItem) && rejectCount >= notifyItem.getThreshold();
}
use of com.dtp.common.dto.NotifyItem in project dynamic-tp by dromara.
the class AlarmManager method checkQueueTimeout.
private static boolean checkQueueTimeout(DtpExecutor executor) {
NotifyItem notifyItem = NotifyHelper.getNotifyItem(executor, NotifyTypeEnum.QUEUE_TIMEOUT);
if (Objects.isNull(notifyItem)) {
return false;
}
AlarmInfo alarmInfo = AlarmCounter.getAlarmInfo(executor.getThreadPoolName(), notifyItem.getType());
int queueTimeoutTaskCount = alarmInfo.getCount();
return satisfyBaseCondition(notifyItem) && queueTimeoutTaskCount >= notifyItem.getThreshold();
}
use of com.dtp.common.dto.NotifyItem in project dynamic-tp by dromara.
the class AlarmManager method checkLiveness.
private static boolean checkLiveness(DtpExecutor executor) {
NotifyItem notifyItem = NotifyHelper.getNotifyItem(executor, NotifyTypeEnum.LIVENESS);
if (Objects.isNull(notifyItem)) {
return false;
}
int maximumPoolSize = executor.getMaximumPoolSize();
double div = NumberUtil.div(executor.getActiveCount(), maximumPoolSize, 2) * 100;
return satisfyBaseCondition(notifyItem) && div >= notifyItem.getThreshold();
}
use of com.dtp.common.dto.NotifyItem in project dynamic-tp by dromara.
the class AlarmManager method checkRunTimeout.
private static boolean checkRunTimeout(DtpExecutor executor) {
NotifyItem notifyItem = NotifyHelper.getNotifyItem(executor, NotifyTypeEnum.RUN_TIMEOUT);
if (Objects.isNull(notifyItem)) {
return false;
}
AlarmInfo alarmInfo = AlarmCounter.getAlarmInfo(executor.getThreadPoolName(), notifyItem.getType());
int runTimeoutTaskCount = alarmInfo.getCount();
return satisfyBaseCondition(notifyItem) && runTimeoutTaskCount >= notifyItem.getThreshold();
}
use of com.dtp.common.dto.NotifyItem in project dynamic-tp by dromara.
the class NotifyHelper method updateNotifyItems.
public static void updateNotifyItems(DtpExecutor executor, DtpProperties dtpProperties, ThreadPoolProperties tpp) {
if (CollUtil.isEmpty(dtpProperties.getPlatforms())) {
executor.setNotifyItems(Collections.emptyList());
return;
}
fillPlatforms(dtpProperties.getPlatforms(), tpp.getNotifyItems());
List<NotifyItem> oldNotifyItems = executor.getNotifyItems();
Map<String, NotifyItem> oldNotifyItemMap = StreamUtil.toMap(oldNotifyItems, NotifyItem::getType);
tpp.getNotifyItems().forEach(x -> {
NotifyItem oldNotifyItem = oldNotifyItemMap.get(x.getType());
if (Objects.nonNull(oldNotifyItem) && oldNotifyItem.getInterval() == x.getInterval()) {
return;
}
AlarmLimiter.initAlarmLimiter(executor.getThreadPoolName(), x);
AlarmCounter.init(executor.getThreadPoolName(), x.getType());
});
executor.setNotifyItems(tpp.getNotifyItems());
}
Aggregations