未验证 提交 5f5be776 编写于 作者: wu-sheng's avatar wu-sheng 提交者: GitHub

Fix the alarm being started too many times. (#2003)

* Fix the alarm being started too many times.

* Remove unnecessary interface.

* Fix wrong status changed
上级 d75a1472
......@@ -74,12 +74,12 @@ public class AlarmCore {
boolean[] hasExecute = new boolean[] {false};
runningContext.values().forEach(ruleList -> ruleList.forEach(runningRule -> {
if (minutes > 0) {
hasExecute[0] = true;
runningRule.moveTo(checkTime);
/**
* Don't run in the first quarter per min, avoid to trigger false alarm.
*/
if (checkTime.getSecondOfMinute() > 15) {
hasExecute[0] = true;
alarmMessageList.addAll(runningRule.check());
}
}
......
......@@ -46,7 +46,9 @@ public class AlarmModuleProvider extends ModuleProvider {
}
RulesReader reader = new RulesReader(applicationReader);
Rules rules = reader.readRules();
this.registerServiceImplementation(IndicatorNotify.class, new NotifyHandler(rules));
NotifyHandler notifyHandler = new NotifyHandler(rules);
notifyHandler.init(new AlarmStandardPersistence());
this.registerServiceImplementation(IndicatorNotify.class, notifyHandler);
}
@Override public void start() throws ServiceNotProvidedException, ModuleStartException {
......
......@@ -53,7 +53,6 @@ public class NotifyHandler implements IndicatorNotify {
runningRules.forEach(rule -> rule.in(meta, indicator));
}
@Override
public void init(AlarmCallback... callbacks) {
List<AlarmCallback> allCallbacks = new ArrayList<>();
for (AlarmCallback callback : callbacks) {
......
......@@ -105,7 +105,6 @@ public class AlarmEntrance {
serviceInstanceInventoryCache = moduleManager.find(CoreModule.NAME).provider().getService(ServiceInstanceInventoryCache.class);
endpointInventoryCache = moduleManager.find(CoreModule.NAME).provider().getService(EndpointInventoryCache.class);
indicatorNotify = moduleManager.find(AlarmModule.NAME).provider().getService(IndicatorNotify.class);
indicatorNotify.init(new AlarmStandardPersistence());
}
} finally {
initLock.unlock();
......
......@@ -33,6 +33,4 @@ import org.apache.skywalking.oap.server.library.module.Service;
*/
public interface IndicatorNotify extends Service {
void notify(MetaInAlarm indicatorName, Indicator indicator);
void init(AlarmCallback... callbacks);
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册