eagle-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jinh...@apache.org
Subject eagle git commit: [MINOR] optimize sla publisher
Date Tue, 07 Mar 2017 13:16:50 GMT
Repository: eagle
Updated Branches:
  refs/heads/master af6dd7d4c -> 25dfff7b0


[MINOR] optimize sla publisher

Author: wujinhu <wujinhu920@126.com>

Closes #858 from wujinhu/EAGLE-850.


Project: http://git-wip-us.apache.org/repos/asf/eagle/repo
Commit: http://git-wip-us.apache.org/repos/asf/eagle/commit/25dfff7b
Tree: http://git-wip-us.apache.org/repos/asf/eagle/tree/25dfff7b
Diff: http://git-wip-us.apache.org/repos/asf/eagle/diff/25dfff7b

Branch: refs/heads/master
Commit: 25dfff7b092c7a65df167ba8e98094d2c0306721
Parents: af6dd7d
Author: wujinhu <wujinhu920@126.com>
Authored: Tue Mar 7 21:16:43 2017 +0800
Committer: wujinhu <wujinhu920@126.com>
Committed: Tue Mar 7 21:16:43 2017 +0800

----------------------------------------------------------------------
 .../jpm/analyzer/publisher/EmailPublisher.java    | 18 +++++++++++-------
 .../eagle/jpm/analyzer/publisher/Result.java      | 17 +++++++++--------
 .../src/main/resources/AnalyzerReportTemplate.vm  |  2 +-
 3 files changed, 21 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/eagle/blob/25dfff7b/eagle-jpm/eagle-jpm-analyzer/src/main/java/org/apache/eagle/jpm/analyzer/publisher/EmailPublisher.java
----------------------------------------------------------------------
diff --git a/eagle-jpm/eagle-jpm-analyzer/src/main/java/org/apache/eagle/jpm/analyzer/publisher/EmailPublisher.java
b/eagle-jpm/eagle-jpm-analyzer/src/main/java/org/apache/eagle/jpm/analyzer/publisher/EmailPublisher.java
index 737279f..85804ff 100644
--- a/eagle-jpm/eagle-jpm-analyzer/src/main/java/org/apache/eagle/jpm/analyzer/publisher/EmailPublisher.java
+++ b/eagle-jpm/eagle-jpm-analyzer/src/main/java/org/apache/eagle/jpm/analyzer/publisher/EmailPublisher.java
@@ -26,12 +26,14 @@ import org.apache.eagle.common.mail.AlertEmailConstants;
 import org.apache.eagle.common.mail.AlertEmailContext;
 import org.apache.eagle.jpm.analyzer.meta.model.AnalyzerEntity;
 import org.apache.eagle.jpm.analyzer.meta.model.UserEmailEntity;
+import org.apache.eagle.jpm.analyzer.mr.sla.SLAJobEvaluator;
 import org.apache.eagle.jpm.analyzer.util.Constants;
 import org.apache.eagle.jpm.analyzer.util.Utils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import java.io.Serializable;
+import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -40,9 +42,12 @@ public class EmailPublisher implements Publisher, Serializable {
     private static final Logger LOG = LoggerFactory.getLogger(EmailPublisher.class);
 
     private Config config;
+    private List<Class<?>> publishResult4Evaluators = new ArrayList<>();
 
     public EmailPublisher(Config config) {
         this.config = config;
+        //TODO
+        publishResult4Evaluators.add(SLAJobEvaluator.class);
     }
 
     @Override
@@ -53,13 +58,13 @@ public class EmailPublisher implements Publisher, Serializable {
             return;
         }
 
-        if (result.getAlertMessages().size() == 0) {
-            return;
-        }
+        Map<String, List<Result.ProcessorResult>> extend = new HashMap<>();
+        publishResult4Evaluators
+                .stream()
+                .filter(item -> result.getAlertMessages().containsKey(item.getName()))
+                .forEach(item -> extend.put(item.getName(), result.getAlertMessages().get(item.getName())));
 
-        if (analyzerJobEntity.getJobMeta() == null) {
-            //do not need send email
-            //TODO, framework should know which publishers that job should uses. Just work
around here
+        if (extend.size() == 0) {
             return;
         }
 
@@ -79,7 +84,6 @@ public class EmailPublisher implements Publisher, Serializable {
         basic.put("progress", progress + "%");
         basic.put("detail", getJobLink(analyzerJobEntity));
 
-        Map<String, List<Result.ProcessorResult>> extend = result.getAlertMessages();
         Map<String, Object> alertData = new HashMap<>();
         for (String evaluator : extend.keySet()) {
             for (Result.ProcessorResult message : extend.get(evaluator)) {

http://git-wip-us.apache.org/repos/asf/eagle/blob/25dfff7b/eagle-jpm/eagle-jpm-analyzer/src/main/java/org/apache/eagle/jpm/analyzer/publisher/Result.java
----------------------------------------------------------------------
diff --git a/eagle-jpm/eagle-jpm-analyzer/src/main/java/org/apache/eagle/jpm/analyzer/publisher/Result.java
b/eagle-jpm/eagle-jpm-analyzer/src/main/java/org/apache/eagle/jpm/analyzer/publisher/Result.java
index 748a5d5..27da4b9 100644
--- a/eagle-jpm/eagle-jpm-analyzer/src/main/java/org/apache/eagle/jpm/analyzer/publisher/Result.java
+++ b/eagle-jpm/eagle-jpm-analyzer/src/main/java/org/apache/eagle/jpm/analyzer/publisher/Result.java
@@ -17,6 +17,7 @@
 
 package org.apache.eagle.jpm.analyzer.publisher;
 
+import org.apache.commons.lang3.StringUtils;
 import org.apache.eagle.log.base.taggedlog.TaggedLogAPIEntity;
 
 import java.util.ArrayList;
@@ -46,7 +47,7 @@ public class Result {
                 alertMessages.put(typeName, new ArrayList<>());
                 alertEntities.put(typeName, new ArrayList<>());
             }
-            //normalizeResult(processorResult);
+            normalizeResult(processorResult);
             alertMessages.get(typeName).add(processorResult);
             alertEntities.get(typeName).add(processorEntities.get(processorType));
 
@@ -62,11 +63,11 @@ public class Result {
     }
 
     private void normalizeResult(ProcessorResult processorResult) {
-        /*String settingList = "";
+        String settingList = "";
         if (processorResult.getSettings() != null && !processorResult.getSettings().isEmpty())
{
             settingList = StringUtils.join(processorResult.getSettings(), "\n");
         }
-        processorResult.setSettingList(settingList);*/
+        processorResult.setSettingList(settingList);
     }
 
     /**
@@ -109,20 +110,20 @@ public class Result {
         private ResultLevel resultLevel;
         private String message;
         private List<String> settings;
-        //private String settingList;
+        private String settingList;
 
         public ProcessorResult(RuleType ruleType, ResultLevel resultLevel, String message,
List<String> settings) {
             this.ruleType = ruleType;
             this.resultLevel = resultLevel;
             this.message = message;
-            //this.settings = settings;
+            this.settings = settings;
         }
 
         public ProcessorResult(RuleType ruleType, ResultLevel resultLevel, String message)
{
             this.ruleType = ruleType;
             this.resultLevel = resultLevel;
             this.message = message;
-            //this.settings = new ArrayList<>();
+            this.settings = new ArrayList<>();
         }
 
         public RuleType getRuleType() {
@@ -157,13 +158,13 @@ public class Result {
             this.settings = settings;
         }
 
-        /*public String getSettingList() {
+        public String getSettingList() {
             return settingList;
         }
 
         public void setSettingList(String settingList) {
             this.settingList = settingList;
-        }*/
+        }
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/eagle/blob/25dfff7b/eagle-jpm/eagle-jpm-analyzer/src/main/resources/AnalyzerReportTemplate.vm
----------------------------------------------------------------------
diff --git a/eagle-jpm/eagle-jpm-analyzer/src/main/resources/AnalyzerReportTemplate.vm b/eagle-jpm/eagle-jpm-analyzer/src/main/resources/AnalyzerReportTemplate.vm
index 0486a33..5507a23 100644
--- a/eagle-jpm/eagle-jpm-analyzer/src/main/resources/AnalyzerReportTemplate.vm
+++ b/eagle-jpm/eagle-jpm-analyzer/src/main/resources/AnalyzerReportTemplate.vm
@@ -228,7 +228,7 @@
                                         Detail:
                                     </td>
                                     <td style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif;
box-sizing: border-box; font-size: 14px; vertical-align: top; margin: 0;"
-                                        valign="top"> <a href=${alert["basic"].get("detail")}>${alert["basic"].get("detail")}</a>
+                                        valign="top"> <a href=${alert["basic"].get("detail")}>Job
Detail</a>
                                     </td>
                                 </tr>
                             </table>


Mime
View raw message