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:
parent
d75a1472b5
commit
5f5be77601
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue