ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mpapirkovs...@apache.org
Subject [ambari] branch trunk updated: AMBARI-23117. Missing 'hash' in alert update message. (mpapirkovskyy)
Date Thu, 01 Mar 2018 14:09:27 GMT
This is an automated email from the ASF dual-hosted git repository.

mpapirkovskyy pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ambari.git


The following commit(s) were added to refs/heads/trunk by this push:
     new 4ffb348  AMBARI-23117. Missing 'hash' in alert update message. (mpapirkovskyy)
4ffb348 is described below

commit 4ffb34821b3d3e6510413a804a727fca7198278a
Author: Myroslav Papirkovskyi <mpapirkovskyy@apache.org>
AuthorDate: Thu Mar 1 14:23:02 2018 +0200

    AMBARI-23117. Missing 'hash' in alert update message. (mpapirkovskyy)
---
 .../org/apache/ambari/server/agent/stomp/AgentConfigsHolder.java    | 6 ++++++
 .../java/org/apache/ambari/server/agent/stomp/AgentDataHolder.java  | 5 +++++
 .../org/apache/ambari/server/agent/stomp/AgentHostDataHolder.java   | 6 ++++++
 3 files changed, 17 insertions(+)

diff --git a/ambari-server/src/main/java/org/apache/ambari/server/agent/stomp/AgentConfigsHolder.java
b/ambari-server/src/main/java/org/apache/ambari/server/agent/stomp/AgentConfigsHolder.java
index 338bad9..68b9b68 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/agent/stomp/AgentConfigsHolder.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/agent/stomp/AgentConfigsHolder.java
@@ -26,6 +26,7 @@ import org.apache.ambari.server.state.Clusters;
 import org.apache.ambari.server.state.ConfigHelper;
 import org.apache.ambari.server.state.Host;
 import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.lang.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -93,6 +94,11 @@ public class AgentConfigsHolder extends AgentHostDataHolder<AgentConfigsUpdateEv
   }
 
   @Override
+  protected boolean isIdentifierValid(AgentConfigsUpdateEvent data) {
+    return StringUtils.isNotEmpty(data.getHash()) && data.getTimestamp() != null;
+  }
+
+  @Override
   protected void setIdentifiersToEventUpdate(AgentConfigsUpdateEvent update, AgentConfigsUpdateEvent
hostData) {
     super.setIdentifiersToEventUpdate(update, hostData);
     update.setTimestamp(hostData.getTimestamp());
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/agent/stomp/AgentDataHolder.java
b/ambari-server/src/main/java/org/apache/ambari/server/agent/stomp/AgentDataHolder.java
index 3896a68..ec41447 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/agent/stomp/AgentDataHolder.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/agent/stomp/AgentDataHolder.java
@@ -23,6 +23,7 @@ import java.security.MessageDigest;
 import java.security.NoSuchAlgorithmException;
 
 import org.apache.ambari.server.agent.stomp.dto.Hashable;
+import org.apache.commons.lang.StringUtils;
 
 import com.google.gson.Gson;
 
@@ -40,6 +41,10 @@ public abstract class AgentDataHolder<T extends Hashable> {
     data.setHash(getHash(data));
   }
 
+  protected boolean isIdentifierValid(T data) {
+    return StringUtils.isNotEmpty(data.getHash());
+  }
+
   protected String getHash(T data) {
     String json = new Gson().toJson(data);
     String generatedPassword = null;
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/agent/stomp/AgentHostDataHolder.java
b/ambari-server/src/main/java/org/apache/ambari/server/agent/stomp/AgentHostDataHolder.java
index 23ab4ff..055128a 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/agent/stomp/AgentHostDataHolder.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/agent/stomp/AgentHostDataHolder.java
@@ -71,6 +71,12 @@ public abstract class AgentHostDataHolder<T extends AmbariHostUpdateEvent
& Hash
       regenerateDataIdentifiers(hostData);
       setIdentifiersToEventUpdate(update, hostData);
       stateUpdateEventPublisher.publish(update);
+    } else {
+      // in case update does not have changes empty identifiers should be populated anyway
+      T hostData = getData(update.getHostId());
+      if (!isIdentifierValid(hostData)) {
+        regenerateDataIdentifiers(hostData);
+      }
     }
   }
 

-- 
To stop receiving notification emails like this one, please contact
mpapirkovskyy@apache.org.

Mime
View raw message