summaryrefslogtreecommitdiffstats
path: root/rulemgt/src/main/java/org/onap
diff options
context:
space:
mode:
authorGuangrong Fu <fu.guangrong@zte.com.cn>2017-11-08 12:35:22 +0800
committerGuangrong Fu <fu.guangrong@zte.com.cn>2017-11-08 12:35:22 +0800
commit126cfb2bef37fff35e6c1e3f3c7b03787fd923d8 (patch)
tree93a935d69f2657dd3ffe465e4acc99cc80f22cce /rulemgt/src/main/java/org/onap
parent4ffb3501b062976124862ff929c41419894d1866 (diff)
Add the MD5 Check to Avoid Duplicated Deployment
Change-Id: I99d234c81e1aa9ae947e4661b8a05e5dd6c2a60c Issue-ID: HOLMES-86 Signed-off-by: Guangrong Fu <fu.guangrong@zte.com.cn>
Diffstat (limited to 'rulemgt/src/main/java/org/onap')
-rw-r--r--rulemgt/src/main/java/org/onap/holmes/rulemgt/dcae/DcaeConfigurationPolling.java13
1 files changed, 12 insertions, 1 deletions
diff --git a/rulemgt/src/main/java/org/onap/holmes/rulemgt/dcae/DcaeConfigurationPolling.java b/rulemgt/src/main/java/org/onap/holmes/rulemgt/dcae/DcaeConfigurationPolling.java
index 95b28b6..493011c 100644
--- a/rulemgt/src/main/java/org/onap/holmes/rulemgt/dcae/DcaeConfigurationPolling.java
+++ b/rulemgt/src/main/java/org/onap/holmes/rulemgt/dcae/DcaeConfigurationPolling.java
@@ -29,6 +29,7 @@ import org.onap.holmes.common.dcae.entity.DcaeConfigurations;
import org.onap.holmes.common.dcae.entity.Rule;
import org.onap.holmes.common.dcae.utils.DcaeConfigurationParser;
import org.onap.holmes.common.exception.CorrelationException;
+import org.onap.holmes.common.utils.Md5Util;
import org.onap.holmes.rulemgt.bean.request.RuleCreateRequest;
import org.onap.holmes.rulemgt.bean.response.RuleQueryListResponse;
import org.onap.holmes.rulemgt.bean.response.RuleResult4API;
@@ -46,13 +47,23 @@ public class DcaeConfigurationPolling implements Runnable {
this.hostname = hostname;
}
+ private String prevConfigMd5 = Md5Util.md5(null);
+
@Override
public void run() {
DcaeConfigurations dcaeConfigurations = null;
try {
dcaeConfigurations = DcaeConfigurationQuery.getDcaeConfigurations(hostname);
+ String md5 = Md5Util.md5(dcaeConfigurations);
+ if (prevConfigMd5.equals(md5)){
+ log.info("Operation aborted due to identical Configurations.");
+ return;
+ }
+ prevConfigMd5 = md5;
} catch (CorrelationException e) {
log.error("Failed to fetch DCAE configurations. " + e.getMessage(), e);
+ } catch (JsonProcessingException e) {
+ log.info("Failed to generate the MD5 information for new configurations.", e);
}
if (dcaeConfigurations != null) {
RuleQueryListResponse ruleQueryListResponse = getAllCorrelationRules();
@@ -61,7 +72,7 @@ public class DcaeConfigurationPolling implements Runnable {
try {
addAllCorrelationRules(dcaeConfigurations);
} catch (CorrelationException e) {
- log.error("Failed to add rules. " + e.getMessage());
+ log.error("Failed to add rules. " + e.getMessage(), e);
}
}
}