summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortang peng <tang.peng5@zte.com.cn>2017-11-08 04:40:20 +0000
committerGerrit Code Review <gerrit@onap.org>2017-11-08 04:40:20 +0000
commitaf1347f3aeb77096ef6a588ac4e6ed01300d64bc (patch)
treeaf7713196724277c82a4112e1e0ae77d4b1af22c
parentc8103b3d39394ba98a03a9938835a94ea8cbd3fd (diff)
parent37122ee276b137470f4a002e4dd3bf466f5ef3b8 (diff)
Merge "Add the MD5 Check to Avoid Duplicated Deployment"
-rw-r--r--engine-d/src/main/java/org/onap/holmes/engine/dcae/DcaeConfigurationPolling.java15
1 files changed, 13 insertions, 2 deletions
diff --git a/engine-d/src/main/java/org/onap/holmes/engine/dcae/DcaeConfigurationPolling.java b/engine-d/src/main/java/org/onap/holmes/engine/dcae/DcaeConfigurationPolling.java
index 9f892de..01a98a4 100644
--- a/engine-d/src/main/java/org/onap/holmes/engine/dcae/DcaeConfigurationPolling.java
+++ b/engine-d/src/main/java/org/onap/holmes/engine/dcae/DcaeConfigurationPolling.java
@@ -15,12 +15,14 @@
*/
package org.onap.holmes.engine.dcae;
+import com.fasterxml.jackson.core.JsonProcessingException;
import lombok.extern.slf4j.Slf4j;
import org.onap.holmes.common.dcae.DcaeConfigurationQuery;
import org.onap.holmes.common.dcae.DcaeConfigurationsCache;
import org.onap.holmes.common.dcae.entity.DcaeConfigurations;
import org.onap.holmes.common.dropwizard.ioc.utils.ServiceLocatorHolder;
import org.onap.holmes.common.exception.CorrelationException;
+import org.onap.holmes.common.utils.Md5Util;
import org.onap.holmes.dsa.dmaappolling.Subscriber;
import org.onap.holmes.engine.dmaap.SubscriberAction;
@@ -31,6 +33,8 @@ public class DcaeConfigurationPolling implements Runnable {
public static long POLLING_PERIOD = 30 * 1000L;
+ private String prevConfigMd5 = Md5Util.md5(null);
+
public DcaeConfigurationPolling(String hostname) {
this.hostname = hostname;
}
@@ -39,10 +43,17 @@ public class DcaeConfigurationPolling implements Runnable {
public void run() {
DcaeConfigurations dcaeConfigurations = null;
try {
- dcaeConfigurations = DcaeConfigurationQuery
- .getDcaeConfigurations(hostname);
+ 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 poll the DCAE configurations. " + e.getMessage());
+ } catch (JsonProcessingException e) {
+ log.info("Failed to generate the MD5 information for new configurations.", e);
}
if (dcaeConfigurations != null) {
DcaeConfigurationsCache.setDcaeConfigurations(dcaeConfigurations);