|
|
@@ -3,12 +3,11 @@ package com.jay.monitor.data.server.report.alert.rule;
|
|
|
import com.jay.monitor.data.core.enums.MsgTypeEnums;
|
|
|
import com.jay.monitor.data.core.model.serializable.base.BaseDTO;
|
|
|
import com.jay.monitor.data.core.model.serializable.base.RequestDataData;
|
|
|
-import com.jay.monitor.data.server.config.props.AlertProperties;
|
|
|
import com.jay.monitor.data.server.enums.AlertRuleEnums;
|
|
|
-import com.jay.monitor.data.server.models.config.AlertConfigModel;
|
|
|
+import com.jay.monitor.data.server.models.config.AlertRuleConfigModel;
|
|
|
+import com.jay.monitor.data.server.store.ConfigStoreManager;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
-import org.springframework.beans.factory.InitializingBean;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
@@ -19,14 +18,12 @@ import org.springframework.stereotype.Component;
|
|
|
* @Date 2021/1/14 10:49
|
|
|
*/
|
|
|
@Component
|
|
|
-public class RequestTimeAlertRule implements AlertRule, InitializingBean {
|
|
|
+public class RequestTimeAlertRule implements AlertRule {
|
|
|
|
|
|
private Logger logger = LoggerFactory.getLogger(getClass());
|
|
|
|
|
|
@Autowired
|
|
|
- private AlertProperties alertProperties;
|
|
|
-
|
|
|
- private volatile boolean isEnableRule = false;
|
|
|
+ private ConfigStoreManager configStoreManager;
|
|
|
|
|
|
@Override
|
|
|
public AlertRuleEnums ruleType() {
|
|
|
@@ -36,7 +33,7 @@ public class RequestTimeAlertRule implements AlertRule, InitializingBean {
|
|
|
@Override
|
|
|
public boolean isTrigger(BaseDTO baseDTO) {
|
|
|
|
|
|
- if (!this.isEnableRule) {
|
|
|
+ if (!configStoreManager.alertEnable()) {
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
@@ -45,7 +42,7 @@ public class RequestTimeAlertRule implements AlertRule, InitializingBean {
|
|
|
RequestDataData requestData = (RequestDataData) baseDTO;
|
|
|
Long requestTime = requestData.getRequestTime();
|
|
|
if (requestTime != null) {
|
|
|
- AlertConfigModel alertConfigModel = alertProperties.getAlertConfigMap().get(type);
|
|
|
+ AlertRuleConfigModel alertConfigModel = configStoreManager.getAlertRuleConfigModel(type);
|
|
|
if (alertConfigModel != null) {
|
|
|
Integer maxTime = alertConfigModel.getMaxTime();
|
|
|
if (requestTime >= maxTime) {
|
|
|
@@ -59,10 +56,4 @@ public class RequestTimeAlertRule implements AlertRule, InitializingBean {
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
- public void afterPropertiesSet() throws Exception {
|
|
|
- if (alertProperties.isEnable() && alertProperties.getAlertConfigMap().size() > 0) {
|
|
|
- this.isEnableRule = true;
|
|
|
- }
|
|
|
- }
|
|
|
}
|