summaryrefslogtreecommitdiffstats
path: root/engine-d/src/main/java/org/onap
diff options
context:
space:
mode:
authorGuangrong Fu <fu.guangrong@zte.com.cn>2017-11-08 12:35:57 +0800
committerGuangrong Fu <fu.guangrong@zte.com.cn>2017-11-08 12:35:57 +0800
commit37122ee276b137470f4a002e4dd3bf466f5ef3b8 (patch)
tree2fa5f6faa1502c87c761ff9364dd5f3eb26719bc /engine-d/src/main/java/org/onap
parentbac6fc133444c383d72a7a6c3e2ceca390239c86 (diff)
Add the MD5 Check to Avoid Duplicated Deployment
Change-Id: I0119a15db0cce7ce264063487b80ae77b5388153 Issue-ID: HOLMES-86 Signed-off-by: Guangrong Fu <fu.guangrong@zte.com.cn>
Diffstat (limited to 'engine-d/src/main/java/org/onap')
-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);