You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by wu...@apache.org on 2018/12/05 12:56:13 UTC

[incubator-skywalking] branch master updated: Fix the alarm being started too many times. (#2003)

This is an automated email from the ASF dual-hosted git repository.

wusheng pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-skywalking.git


The following commit(s) were added to refs/heads/master by this push:
     new 5f5be77  Fix the alarm being started too many times. (#2003)
5f5be77 is described below

commit 5f5be776015e16ccad1184730c23f6276022ee08
Author: 吴晟 Wu Sheng <wu...@foxmail.com>
AuthorDate: Wed Dec 5 20:56:08 2018 +0800

    Fix the alarm being started too many times. (#2003)
    
    * Fix the alarm being started too many times.
    
    * Remove unnecessary interface.
    
    * Fix wrong status changed
---
 .../apache/skywalking/oap/server/core/alarm/provider/AlarmCore.java   | 2 +-
 .../oap/server/core/alarm/provider/AlarmModuleProvider.java           | 4 +++-
 .../skywalking/oap/server/core/alarm/provider/NotifyHandler.java      | 1 -
 .../org/apache/skywalking/oap/server/core/alarm/AlarmEntrance.java    | 1 -
 .../org/apache/skywalking/oap/server/core/alarm/IndicatorNotify.java  | 2 --
 5 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/oap-server/server-alarm-plugin/src/main/java/org/apache/skywalking/oap/server/core/alarm/provider/AlarmCore.java b/oap-server/server-alarm-plugin/src/main/java/org/apache/skywalking/oap/server/core/alarm/provider/AlarmCore.java
index b43e18c..a0a735c 100644
--- a/oap-server/server-alarm-plugin/src/main/java/org/apache/skywalking/oap/server/core/alarm/provider/AlarmCore.java
+++ b/oap-server/server-alarm-plugin/src/main/java/org/apache/skywalking/oap/server/core/alarm/provider/AlarmCore.java
@@ -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());
                         }
                     }
diff --git a/oap-server/server-alarm-plugin/src/main/java/org/apache/skywalking/oap/server/core/alarm/provider/AlarmModuleProvider.java b/oap-server/server-alarm-plugin/src/main/java/org/apache/skywalking/oap/server/core/alarm/provider/AlarmModuleProvider.java
index 3c228a5..f536caa 100644
--- a/oap-server/server-alarm-plugin/src/main/java/org/apache/skywalking/oap/server/core/alarm/provider/AlarmModuleProvider.java
+++ b/oap-server/server-alarm-plugin/src/main/java/org/apache/skywalking/oap/server/core/alarm/provider/AlarmModuleProvider.java
@@ -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 {
diff --git a/oap-server/server-alarm-plugin/src/main/java/org/apache/skywalking/oap/server/core/alarm/provider/NotifyHandler.java b/oap-server/server-alarm-plugin/src/main/java/org/apache/skywalking/oap/server/core/alarm/provider/NotifyHandler.java
index 408f9ee..b0cb665 100644
--- a/oap-server/server-alarm-plugin/src/main/java/org/apache/skywalking/oap/server/core/alarm/provider/NotifyHandler.java
+++ b/oap-server/server-alarm-plugin/src/main/java/org/apache/skywalking/oap/server/core/alarm/provider/NotifyHandler.java
@@ -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) {
diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/alarm/AlarmEntrance.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/alarm/AlarmEntrance.java
index b2d0e41..207ec3e 100644
--- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/alarm/AlarmEntrance.java
+++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/alarm/AlarmEntrance.java
@@ -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();
diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/alarm/IndicatorNotify.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/alarm/IndicatorNotify.java
index d146ab2..4d05622 100644
--- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/alarm/IndicatorNotify.java
+++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/alarm/IndicatorNotify.java
@@ -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);
 }