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

* Fix the alarm being started too many times.

* Remove unnecessary interface.

* Fix wrong status changed
This commit is contained in:
吴晟 Wu Sheng 2018-12-05 20:56:08 +08:00 committed by GitHub
parent d75a1472b5
commit 5f5be77601
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 4 additions and 6 deletions

View File

@ -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());
}
}

View File

@ -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 {

View File

@ -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) {

View File

@ -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();

View File

@ -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);
}