use of com.dtp.common.dto.AlarmInfo in project dynamic-tp by dromara.
the class AlarmManager method doAlarm.
public static void doAlarm(DtpExecutor executor, NotifyTypeEnum typeEnum) {
if (!preCheck(executor, typeEnum)) {
return;
}
boolean ifAlarm = AlarmLimiter.ifAlarm(executor, typeEnum.getValue());
if (!ifAlarm) {
log.debug("DynamicTp notify, alarm limit, dtpName: {}, type: {}", executor.getThreadPoolName(), typeEnum.getValue());
return;
}
DtpProperties dtpProperties = ApplicationContextHolder.getBean(DtpProperties.class);
NotifyItem notifyItem = NotifyHelper.getNotifyItem(executor, typeEnum);
if (Objects.isNull(notifyItem)) {
return;
}
synchronized (SEND_LOCK) {
// recheck alarm limit.
ifAlarm = AlarmLimiter.ifAlarm(executor, typeEnum.getValue());
if (!ifAlarm) {
log.warn("DynamicTp notify, concurrent send, alarm limit, dtpName: {}, type: {}", executor.getThreadPoolName(), typeEnum.getValue());
return;
}
AlarmLimiter.putVal(executor, typeEnum.getValue());
}
AlarmInfo alarmInfo = AlarmCounter.getAlarmInfo(executor.getThreadPoolName(), notifyItem.getType());
DtpContext dtpContext = DtpContext.builder().dtpExecutor(executor).platforms(dtpProperties.getPlatforms()).notifyItem(notifyItem).alarmInfo(alarmInfo).build();
DtpContextHolder.set(dtpContext);
NotifierHandler.getInstance().sendAlarm(typeEnum);
AlarmCounter.reset(executor.getThreadPoolName(), notifyItem.getType());
}
use of com.dtp.common.dto.AlarmInfo 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.AlarmInfo 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.AlarmInfo 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();
}
Aggregations